Skip to content
  1. Jul 27, 2023
    • Suren Baghdasaryan's avatar
      sched/psi: use kernfs polling functions for PSI trigger polling · 92cc0153
      Suren Baghdasaryan authored
      [ Upstream commit aff03707 ]
      
      Destroying psi trigger in cgroup_file_release causes UAF issues when
      a cgroup is removed from under a polling process. This is happening
      because cgroup removal causes a call to cgroup_file_release while the
      actual file is still alive. Destroying the trigger at this point would
      also destroy its waitqueue head and if there is still a polling process
      on that file accessing the waitqueue, it will step on the freed pointer:
      
      do_select
        vfs_poll
                                 do_rmdir
                                   cgroup_rmdir
                                     kernfs_drain_open_files
                                       cgroup_file_release
                                         cgroup_pressure_release
                                           psi_trigger_destroy
                                             wake_up_pollfree(&t->event_wait)
      // vfs_poll is unblocked
                                             synchronize_rcu
                                             kfree(t)
        poll_freewait -> UAF access to the trigger's waitqueue head
      
      Patch [1] fixed this issue for epoll() case using wake_up_pollfree(),
      however the same issue exists for synchronous poll() case.
      The root cause of this issue is that the lifecycles of the psi trigger's
      waitqueue and of the file associated with the trigger are different. Fix
      this by using kernfs_generic_poll function when polling on cgroup-specific
      psi triggers. It internally uses kernfs_open_node->poll waitqueue head
      with its lifecycle tied to the file's lifecycle. This also renders the
      fix in [1] obsolete, so revert it.
      
      [1] commit c2dbe32d ("sched/psi: Fix use-after-free in ep_remove_wait_queue()")
      
      Fixes: 0e94682b ("psi: introduce psi monitor")
      Closes: https://lore.kernel.org/all/20230613062306.101831-1-lujialin4@huawei.com/
      
      
      Reported-by: default avatarLu Jialin <lujialin4@huawei.com>
      Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20230630005612.1014540-1-surenb@google.com
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      92cc0153
    • Domenico Cerasuolo's avatar
      sched/psi: Allow unprivileged polling of N*2s period · d5dca197
      Domenico Cerasuolo authored
      [ Upstream commit d82caa27
      
       ]
      
      PSI offers 2 mechanisms to get information about a specific resource
      pressure. One is reading from /proc/pressure/<resource>, which gives
      average pressures aggregated every 2s. The other is creating a pollable
      fd for a specific resource and cgroup.
      
      The trigger creation requires CAP_SYS_RESOURCE, and gives the
      possibility to pick specific time window and threshold, spawing an RT
      thread to aggregate the data.
      
      Systemd would like to provide containers the option to monitor pressure
      on their own cgroup and sub-cgroups. For example, if systemd launches a
      container that itself then launches services, the container should have
      the ability to poll() for pressure in individual services. But neither
      the container nor the services are privileged.
      
      This patch implements a mechanism to allow unprivileged users to create
      pressure triggers. The difference with privileged triggers creation is
      that unprivileged ones must have a time window that's a multiple of 2s.
      This is so that we can avoid unrestricted spawning of rt threads, and
      use instead the same aggregation mechanism done for the averages, which
      runs independently of any triggers.
      
      Suggested-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: default avatarDomenico Cerasuolo <cerasuolodomenico@gmail.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Link: https://lore.kernel.org/r/20230330105418.77061-5-cerasuolodomenico@gmail.com
      Stable-dep-of: aff03707
      
       ("sched/psi: use kernfs polling functions for PSI trigger polling")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d5dca197
    • Domenico Cerasuolo's avatar
      sched/psi: Extract update_triggers side effect · fb4bc32f
      Domenico Cerasuolo authored
      [ Upstream commit 4468fcae
      
       ]
      
      This change moves update_total flag out of update_triggers function,
      currently called only in psi_poll_work.
      In the next patch, update_triggers will be called also in psi_avgs_work,
      but the total update information is specific to psi_poll_work.
      Returning update_total value to the caller let us avoid differentiating
      the implementation of update_triggers for different aggregators.
      
      Suggested-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: default avatarDomenico Cerasuolo <cerasuolodomenico@gmail.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Link: https://lore.kernel.org/r/20230330105418.77061-4-cerasuolodomenico@gmail.com
      Stable-dep-of: aff03707
      
       ("sched/psi: use kernfs polling functions for PSI trigger polling")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fb4bc32f
    • Domenico Cerasuolo's avatar
      sched/psi: Rename existing poll members in preparation · c1623d4d
      Domenico Cerasuolo authored
      [ Upstream commit 65457b74
      
       ]
      
      Renaming in PSI implementation to make a clear distinction between
      privileged and unprivileged triggers code to be implemented in the
      next patch.
      
      Suggested-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: default avatarDomenico Cerasuolo <cerasuolodomenico@gmail.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Link: https://lore.kernel.org/r/20230330105418.77061-3-cerasuolodomenico@gmail.com
      Stable-dep-of: aff03707
      
       ("sched/psi: use kernfs polling functions for PSI trigger polling")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c1623d4d
    • Domenico Cerasuolo's avatar
      sched/psi: Rearrange polling code in preparation · c176dda0
      Domenico Cerasuolo authored
      [ Upstream commit 7fab21fa
      
       ]
      
      Move a few functions up in the file to avoid forward declaration needed
      in the patch implementing unprivileged PSI triggers.
      
      Suggested-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: default avatarDomenico Cerasuolo <cerasuolodomenico@gmail.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Link: https://lore.kernel.org/r/20230330105418.77061-2-cerasuolodomenico@gmail.com
      Stable-dep-of: aff03707
      
       ("sched/psi: use kernfs polling functions for PSI trigger polling")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c176dda0
    • Chengming Zhou's avatar
      sched/psi: Fix avgs_work re-arm in psi_avgs_work() · 7d8bba4d
      Chengming Zhou authored
      [ Upstream commit 2fcd7bba ]
      
      Pavan reported a problem that PSI avgs_work idle shutoff is not
      working at all. Because PSI_NONIDLE condition would be observed in
      psi_avgs_work()->collect_percpu_times()->get_recent_times() even if
      only the kworker running avgs_work on the CPU.
      
      Although commit 1b69ac6b
      
       ("psi: fix aggregation idle shut-off")
      avoided the ping-pong wake problem when the worker sleep, psi_avgs_work()
      still will always re-arm the avgs_work, so shutoff is not working.
      
      This patch changes to use PSI_STATE_RESCHEDULE to flag whether to
      re-arm avgs_work in get_recent_times(). For the current CPU, we re-arm
      avgs_work only when (NR_RUNNING > 1 || NR_IOWAIT > 0 || NR_MEMSTALL > 0),
      for other CPUs we can just check PSI_NONIDLE delta. The new flag
      is only used in psi_avgs_work(), so we check in get_recent_times()
      that current_work() is avgs_work.
      
      One potential problem is that the brief period of non-idle time
      incurred between the aggregation run and the kworker's dequeue will
      be stranded in the per-cpu buckets until avgs_work run next time.
      The buckets can hold 4s worth of time, and future activity will wake
      the avgs_work with a 2s delay, giving us 2s worth of data we can leave
      behind when shut off the avgs_work. If the kworker run other works after
      avgs_work shut off and doesn't have any scheduler activities for 2s,
      this maybe a problem.
      
      Reported-by: default avatarPavan Kondeti <quic_pkondeti@quicinc.com>
      Signed-off-by: default avatarChengming Zhou <zhouchengming@bytedance.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Acked-by: default avatarSuren Baghdasaryan <surenb@google.com>
      Tested-by: default avatarChengming Zhou <zhouchengming@bytedance.com>
      Link: https://lore.kernel.org/r/20221014110551.22695-1-zhouchengming@bytedance.com
      Stable-dep-of: aff03707
      
       ("sched/psi: use kernfs polling functions for PSI trigger polling")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7d8bba4d
    • Miaohe Lin's avatar
      sched/fair: Use recent_used_cpu to test p->cpus_ptr · 45f739e8
      Miaohe Lin authored
      [ Upstream commit ae2ad293 ]
      
      When checking whether a recently used CPU can be a potential idle
      candidate, recent_used_cpu should be used to test p->cpus_ptr as
      p->recent_used_cpu is not equal to recent_used_cpu and candidate
      decision is made based on recent_used_cpu here.
      
      Fixes: 89aafd67
      
       ("sched/fair: Use prev instead of new target as recent_used_cpu")
      Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarPhil Auld <pauld@redhat.com>
      Acked-by: default avatarMel Gorman <mgorman@suse.de>
      Link: https://lore.kernel.org/r/20230620080747.359122-1-linmiaohe@huawei.com
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      45f739e8
    • Srinivas Kandagatla's avatar
      ASoC: qcom: q6apm: do not close GPR port before closing graph · 6ede0d0f
      Srinivas Kandagatla authored
      [ Upstream commit c1be6292 ]
      
      Closing GPR port before graph close can result in un handled notifications
      from DSP, this results in spam of errors from GPR driver as there is no
      one to handle these notification at that point in time.
      
      Fix this by closing GPR port after graph close is finished.
      
      Fixes: 5477518b
      
       ("ASoC: qdsp6: audioreach: add q6apm support")
      Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Link: https://lore.kernel.org/r/20230705131842.41584-1-srinivas.kandagatla@linaro.org
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6ede0d0f
    • Srinivas Kandagatla's avatar
      ASoC: codecs: wcd938x: fix dB range for HPHL and HPHR · 5da98d04
      Srinivas Kandagatla authored
      [ Upstream commit c03226ba ]
      
      dB range for HPHL and HPHR gains are from +6dB to -30dB in steps of
      1.5dB with register values range from 0 to 24.
      
      Current code maps these dB ranges incorrectly, fix them to allow proper
      volume setting.
      
      Fixes: e8ba1e05
      
       ("ASoC: codecs: wcd938x: add basic controls")
      Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Link: https://lore.kernel.org/r/20230705125723.40464-1-srinivas.kandagatla@linaro.org
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5da98d04
    • Johan Hovold's avatar
      ASoC: codecs: wcd938x: fix mbhc impedance loglevel · e3495bc9
      Johan Hovold authored
      [ Upstream commit e5ce198b ]
      
      Demote the MBHC impedance measurement printk, which is not an error
      message, from error to debug level.
      
      While at it, fix the capitalisation of "ohm" and add the missing space
      before the opening parenthesis.
      
      Fixes: bcee7ed0
      
       ("ASoC: codecs: wcd938x: add Multi Button Headset Control support")
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Reviewed-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Link: https://lore.kernel.org/r/20230630142717.5314-2-johan+linaro@kernel.org
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e3495bc9
    • Vijendar Mukunda's avatar
      ASoC: amd: acp: fix for invalid dai id handling in acp_get_byte_count() · 3122e90b
      Vijendar Mukunda authored
      [ Upstream commit 85aeab36 ]
      
      For invalid dai id, instead of returning -EINVAL
      return bytes count as zero in acp_get_byte_count() function.
      
      Fixes: 623621a9
      
       ("ASoC: amd: Add common framework to support I2S on ACP SOC")
      
      Signed-off-by: default avatarVijendar Mukunda <Vijendar.Mukunda@amd.com>
      Link: https://lore.kernel.org/r/20230626105356.2580125-6-Vijendar.Mukunda@amd.com
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3122e90b
    • Hao Chen's avatar
      net: hns3: fix strncpy() not using dest-buf length as length issue · da64c888
      Hao Chen authored
      [ Upstream commit 1cf3d556
      
       ]
      
      Now, strncpy() in hns3_dbg_fill_content() use src-length as copy-length,
      it may result in dest-buf overflow.
      
      This patch is to fix intel compile warning for csky-linux-gcc (GCC) 12.1.0
      compiler.
      
      The warning reports as below:
      
      hclge_debugfs.c:92:25: warning: 'strncpy' specified bound depends on
      the length of the source argument [-Wstringop-truncation]
      
      strncpy(pos, items[i].name, strlen(items[i].name));
      
      hclge_debugfs.c:90:25: warning: 'strncpy' output truncated before
      terminating nul copying as many bytes from a string as its length
      [-Wstringop-truncation]
      
      strncpy(pos, result[i], strlen(result[i]));
      
      strncpy() use src-length as copy-length, it may result in
      dest-buf overflow.
      
      So,this patch add some values check to avoid this issue.
      
      Signed-off-by: default avatarHao Chen <chenhao418@huawei.com>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Closes: https://lore.kernel.org/lkml/202207170606.7WtHs9yS-lkp@intel.com/T/
      
      
      Signed-off-by: default avatarHao Lan <lanhao@huawei.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      da64c888
    • Ying Hsu's avatar
      igb: Fix igb_down hung on surprise removal · 39695e87
      Ying Hsu authored
      [ Upstream commit 004d2506
      
       ]
      
      In a setup where a Thunderbolt hub connects to Ethernet and a display
      through USB Type-C, users may experience a hung task timeout when they
      remove the cable between the PC and the Thunderbolt hub.
      This is because the igb_down function is called multiple times when
      the Thunderbolt hub is unplugged. For example, the igb_io_error_detected
      triggers the first call, and the igb_remove triggers the second call.
      The second call to igb_down will block at napi_synchronize.
      Here's the call trace:
          __schedule+0x3b0/0xddb
          ? __mod_timer+0x164/0x5d3
          schedule+0x44/0xa8
          schedule_timeout+0xb2/0x2a4
          ? run_local_timers+0x4e/0x4e
          msleep+0x31/0x38
          igb_down+0x12c/0x22a [igb 6615058754948bfde0bf01429257eb59f13030d4]
          __igb_close+0x6f/0x9c [igb 6615058754948bfde0bf01429257eb59f13030d4]
          igb_close+0x23/0x2b [igb 6615058754948bfde0bf01429257eb59f13030d4]
          __dev_close_many+0x95/0xec
          dev_close_many+0x6e/0x103
          unregister_netdevice_many+0x105/0x5b1
          unregister_netdevice_queue+0xc2/0x10d
          unregister_netdev+0x1c/0x23
          igb_remove+0xa7/0x11c [igb 6615058754948bfde0bf01429257eb59f13030d4]
          pci_device_remove+0x3f/0x9c
          device_release_driver_internal+0xfe/0x1b4
          pci_stop_bus_device+0x5b/0x7f
          pci_stop_bus_device+0x30/0x7f
          pci_stop_bus_device+0x30/0x7f
          pci_stop_and_remove_bus_device+0x12/0x19
          pciehp_unconfigure_device+0x76/0xe9
          pciehp_disable_slot+0x6e/0x131
          pciehp_handle_presence_or_link_change+0x7a/0x3f7
          pciehp_ist+0xbe/0x194
          irq_thread_fn+0x22/0x4d
          ? irq_thread+0x1fd/0x1fd
          irq_thread+0x17b/0x1fd
          ? irq_forced_thread_fn+0x5f/0x5f
          kthread+0x142/0x153
          ? __irq_get_irqchip_state+0x46/0x46
          ? kthread_associate_blkcg+0x71/0x71
          ret_from_fork+0x1f/0x30
      
      In this case, igb_io_error_detected detaches the network interface
      and requests a PCIE slot reset, however, the PCIE reset callback is
      not being invoked and thus the Ethernet connection breaks down.
      As the PCIE error in this case is a non-fatal one, requesting a
      slot reset can be avoided.
      This patch fixes the task hung issue and preserves Ethernet
      connection by ignoring non-fatal PCIE errors.
      
      Signed-off-by: default avatarYing Hsu <yinghsu@chromium.org>
      Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Link: https://lore.kernel.org/r/20230620174732.4145155-1-anthony.l.nguyen@intel.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      39695e87
    • Yi Kuo's avatar
      wifi: iwlwifi: pcie: add device id 51F1 for killer 1675 · 6887f358
      Yi Kuo authored
      [ Upstream commit f4daceae
      
       ]
      
      Intel Killer AX1675i/s with device id 51f1 would show
      "No config found for PCI dev 51f1/1672" in dmesg and refuse to work.
      Add the new device id 51F1 for 1675i/s to fix the issue.
      
      Signed-off-by: default avatarYi Kuo <yi@yikuo.dev>
      Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
      Link: https://lore.kernel.org/r/20230621130444.ee224675380b.I921c905e21e8d041ad808def8f454f27b5ebcd8b@changeid
      
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6887f358
    • Johannes Berg's avatar
      wifi: iwlwifi: mvm: avoid baid size integer overflow · 6862557e
      Johannes Berg authored
      [ Upstream commit 1a528ab1
      
       ]
      
      Roee reported various hard-to-debug crashes with pings in
      EHT aggregation scenarios. Enabling KASAN showed that we
      access the BAID allocation out of bounds, and looking at
      the code a bit shows that since the reorder buffer entry
      (struct iwl_mvm_reorder_buf_entry) is 128 bytes if debug
      such as lockdep is enabled, then staring from an agg size
      512 we overflow the size calculation, and allocate a much
      smaller structure than we should, causing slab corruption
      once we initialize this.
      
      Fix this by simply using u32 instead of u16.
      
      Reported-by: default avatarRoee Goldfiner <roee.h.goldfiner@intel.com>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
      Link: https://lore.kernel.org/r/20230620125813.f428c856030d.I2c2bb808e945adb71bc15f5b2bac2d8957ea90eb@changeid
      
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6862557e
    • Mukesh Sisodiya's avatar
    • Gustavo A. R. Silva's avatar
      wifi: wext-core: Fix -Wstringop-overflow warning in ioctl_standard_iw_point() · 8e0a94e3
      Gustavo A. R. Silva authored
      [ Upstream commit 71e7552c ]
      
      -Wstringop-overflow is legitimately warning us about extra_size
      pontentially being zero at some point, hence potenially ending
      up _allocating_ zero bytes of memory for extra pointer and then
      trying to access such object in a call to copy_from_user().
      
      Fix this by adding a sanity check to ensure we never end up
      trying to allocate zero bytes of data for extra pointer, before
      continue executing the rest of the code in the function.
      
      Address the following -Wstringop-overflow warning seen when built
      m68k architecture with allyesconfig configuration:
                       from net/wireless/wext-core.c:11:
      In function '_copy_from_user',
          inlined from 'copy_from_user' at include/linux/uaccess.h:183:7,
          inlined from 'ioctl_standard_iw_point' at net/wireless/wext-core.c:825:7:
      arch/m68k/include/asm/string.h:48:25: warning: '__builtin_memset' writing 1 or more bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
         48 | #define memset(d, c, n) __builtin_memset(d, c, n)
            |                         ^~~~~~~~~~~~~~~~~~~~~~~~~
      include/linux/uaccess.h:153:17: note: in expansion of macro 'memset'
        153 |                 memset(to + (n - res), 0, res);
            |                 ^~~~~~
      In function 'kmalloc',
          inlined from 'kzalloc' at include/linux/slab.h:694:9,
          inlined from 'ioctl_standard_iw_point' at net/wireless/wext-core.c:819:10:
      include/linux/slab.h:577:16: note: at offset 1 into destination object of size 0 allocated by '__kmalloc'
        577 |         return __kmalloc(size, flags);
            |                ^~~~~~~~~~~~~~~~~~~~~~
      
      This help with the ongoing efforts to globally enable
      -Wstringop-overflow.
      
      Link: https://github.com/KSPP/linux/issues/315
      
      
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Link: https://lore.kernel.org/r/ZItSlzvIpjdjNfd8@work
      
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8e0a94e3
    • Petr Oros's avatar
      devlink: report devlink_port_type_warn source device · 408d40c7
      Petr Oros authored
      [ Upstream commit a52305a8
      
       ]
      
      devlink_port_type_warn is scheduled for port devlink and warning
      when the port type is not set. But from this warning it is not easy
      found out which device (driver) has no devlink port set.
      
      [ 3709.975552] Type was not set for devlink port.
      [ 3709.975579] WARNING: CPU: 1 PID: 13092 at net/devlink/leftover.c:6775 devlink_port_type_warn+0x11/0x20
      [ 3709.993967] Modules linked in: openvswitch nf_conncount nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nfnetlink bluetooth rpcsec_gss_krb5 auth_rpcgss nfsv4 dns_resolver nfs lockd grace fscache netfs vhost_net vhost vhost_iotlb tap tun bridge stp llc qrtr intel_rapl_msr intel_rapl_common i10nm_edac nfit libnvdimm x86_pkg_temp_thermal mlx5_ib intel_powerclamp coretemp dell_wmi ledtrig_audio sparse_keymap ipmi_ssif kvm_intel ib_uverbs rfkill ib_core video kvm iTCO_wdt acpi_ipmi intel_vsec irqbypass ipmi_si iTCO_vendor_support dcdbas ipmi_devintf mei_me ipmi_msghandler rapl mei intel_cstate isst_if_mmio isst_if_mbox_pci dell_smbios intel_uncore isst_if_common i2c_i801 dell_wmi_descriptor wmi_bmof i2c_smbus intel_pch_thermal pcspkr acpi_power_meter xfs libcrc32c sd_mod sg nvme_tcp mgag200 i2c_algo_bit nvme_fabrics drm_shmem_helper drm_kms_helper nvme syscopyarea ahci sysfillrect sysimgblt nvme_core fb_sys_fops crct10dif_pclmul libahci mlx5_core sfc crc32_pclmul nvme_common drm
      [ 3709.994030]  crc32c_intel mtd t10_pi mlxfw libata tg3 mdio megaraid_sas psample ghash_clmulni_intel pci_hyperv_intf wmi dm_multipath sunrpc dm_mirror dm_region_hash dm_log dm_mod be2iscsi bnx2i cnic uio cxgb4i cxgb4 tls libcxgbi libcxgb qla4xxx iscsi_boot_sysfs iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi fuse
      [ 3710.108431] CPU: 1 PID: 13092 Comm: kworker/1:1 Kdump: loaded Not tainted 5.14.0-319.el9.x86_64 #1
      [ 3710.108435] Hardware name: Dell Inc. PowerEdge R750/0PJ80M, BIOS 1.8.2 09/14/2022
      [ 3710.108437] Workqueue: events devlink_port_type_warn
      [ 3710.108440] RIP: 0010:devlink_port_type_warn+0x11/0x20
      [ 3710.108443] Code: 84 76 fe ff ff 48 c7 03 20 0e 1a ad 31 c0 e9 96 fd ff ff 66 0f 1f 44 00 00 0f 1f 44 00 00 48 c7 c7 18 24 4e ad e8 ef 71 62 ff <0f> 0b c3 cc cc cc cc 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 f6 87
      [ 3710.108445] RSP: 0018:ff3b6d2e8b3c7e90 EFLAGS: 00010282
      [ 3710.108447] RAX: 0000000000000000 RBX: ff366d6580127080 RCX: 0000000000000027
      [ 3710.108448] RDX: 0000000000000027 RSI: 00000000ffff86de RDI: ff366d753f41f8c8
      [ 3710.108449] RBP: ff366d658ff5a0c0 R08: ff366d753f41f8c0 R09: ff3b6d2e8b3c7e18
      [ 3710.108450] R10: 0000000000000001 R11: 0000000000000023 R12: ff366d753f430600
      [ 3710.108451] R13: ff366d753f436900 R14: 0000000000000000 R15: ff366d753f436905
      [ 3710.108452] FS:  0000000000000000(0000) GS:ff366d753f400000(0000) knlGS:0000000000000000
      [ 3710.108453] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [ 3710.108454] CR2: 00007f1c57bc74e0 CR3: 000000111d26a001 CR4: 0000000000773ee0
      [ 3710.108456] PKRU: 55555554
      [ 3710.108457] Call Trace:
      [ 3710.108458]  <TASK>
      [ 3710.108459]  process_one_work+0x1e2/0x3b0
      [ 3710.108466]  ? rescuer_thread+0x390/0x390
      [ 3710.108468]  worker_thread+0x50/0x3a0
      [ 3710.108471]  ? rescuer_thread+0x390/0x390
      [ 3710.108473]  kthread+0xdd/0x100
      [ 3710.108477]  ? kthread_complete_and_exit+0x20/0x20
      [ 3710.108479]  ret_from_fork+0x1f/0x30
      [ 3710.108485]  </TASK>
      [ 3710.108486] ---[ end trace 1b4b23cd0c65d6a0 ]---
      
      After patch:
      [  402.473064] ice 0000:41:00.0: Type was not set for devlink port.
      [  402.473064] ice 0000:41:00.1: Type was not set for devlink port.
      
      Signed-off-by: default avatarPetr Oros <poros@redhat.com>
      Reviewed-by: default avatarPavan Chebbi <pavan.chebbi@broadcom.com>
      Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
      Link: https://lore.kernel.org/r/20230615095447.8259-1-poros@redhat.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      408d40c7
    • Jisheng Zhang's avatar
      net: ethernet: litex: add support for 64 bit stats · 0d142641
      Jisheng Zhang authored
      [ Upstream commit 18da174d
      
       ]
      
      Implement 64 bit per cpu stats to fix the overflow of netdev->stats
      on 32 bit platforms. To simplify the code, we use net core
      pcpu_sw_netstats infrastructure. One small drawback is some memory
      overhead because litex uses just one queue, but we allocate the
      counters per cpu.
      
      Signed-off-by: default avatarJisheng Zhang <jszhang@kernel.org>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Acked-by: default avatarGabriel Somlo <gsomlo@gmail.com>
      Link: https://lore.kernel.org/r/20230614162035.300-1-jszhang@kernel.org
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0d142641
    • P Praneesh's avatar
      wifi: ath11k: fix memory leak in WMI firmware stats · 86f9330a
      P Praneesh authored
      [ Upstream commit 6aafa1c2
      
       ]
      
      Memory allocated for firmware pdev, vdev and beacon statistics
      are not released during rmmod.
      
      Fix it by calling ath11k_fw_stats_free() function before hardware
      unregister.
      
      While at it, avoid calling ath11k_fw_stats_free() while processing
      the firmware stats received in the WMI event because the local list
      is getting spliced and reinitialised and hence there are no elements
      in the list after splicing.
      
      Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
      
      Signed-off-by: default avatarP Praneesh <quic_ppranees@quicinc.com>
      Signed-off-by: default avatarAditya Kumar Singh <quic_adisi@quicinc.com>
      Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
      Link: https://lore.kernel.org/r/20230606091128.14202-1-quic_adisi@quicinc.com
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      86f9330a
    • Abe Kohandel's avatar
      spi: dw: Add compatible for Intel Mount Evans SoC · 766e6065
      Abe Kohandel authored
      [ Upstream commit 0760d5d0
      
       ]
      
      The Intel Mount Evans SoC's Integrated Management Complex uses the SPI
      controller for access to a NOR SPI FLASH. However, the SoC doesn't
      provide a mechanism to override the native chip select signal.
      
      This driver doesn't use DMA for memory operations when a chip select
      override is not provided due to the native chip select timing behavior.
      As a result no DMA configuration is done for the controller and this
      configuration is not tested.
      
      The controller also has an errata where a full TX FIFO can result in
      data corruption. The suggested workaround is to never completely fill
      the FIFO. The TX FIFO has a size of 32 so the fifo_len is set to 31.
      
      Signed-off-by: default avatarAbe Kohandel <abe.kohandel@intel.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Link: https://lore.kernel.org/r/20230606145402.474866-2-abe.kohandel@intel.com
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      766e6065
    • Ilan Peer's avatar
      wifi: mac80211_hwsim: Fix possible NULL dereference · d0124848
      Ilan Peer authored
      [ Upstream commit 0cc80943
      
       ]
      
      In a call to mac80211_hwsim_select_tx_link() the sta pointer might
      be NULL, thus need to check that it is not NULL before accessing it.
      
      Signed-off-by: default avatarIlan Peer <ilan.peer@intel.com>
      Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
      Link: https://lore.kernel.org/r/20230604120651.f4d889fc98c4.Iae85f527ed245a37637a874bb8b8c83d79812512@changeid
      
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d0124848
    • Wen Gong's avatar
      wifi: ath11k: add support default regdb while searching board-2.bin for WCN6855 · 8656b31d
      Wen Gong authored
      [ Upstream commit 88ca8920
      
       ]
      
      Sometimes board-2.bin does not have the regdb data which matched the
      parameters such as vendor, device, subsystem-vendor, subsystem-device
      and etc. Add default regdb data with 'bus=%s' into board-2.bin for
      WCN6855, then ath11k use 'bus=pci' to search regdb data in board-2.bin
      for WCN6855.
      
      kernel: [  122.515808] ath11k_pci 0000:03:00.0: boot using board name 'bus=pci,vendor=17cb,device=1103,subsystem-vendor=17cb,subsystem-device=3374,qmi-chip-id=2,qmi-board-id=262'
      kernel: [  122.517240] ath11k_pci 0000:03:00.0: boot firmware request ath11k/WCN6855/hw2.0/board-2.bin size 6179564
      kernel: [  122.517280] ath11k_pci 0000:03:00.0: failed to fetch regdb data for bus=pci,vendor=17cb,device=1103,subsystem-vendor=17cb,subsystem-device=3374,qmi-chip-id=2,qmi-board-id=262 from ath11k/WCN6855/hw2.0/board-2.bin
      kernel: [  122.517464] ath11k_pci 0000:03:00.0: boot using board name 'bus=pci'
      kernel: [  122.518901] ath11k_pci 0000:03:00.0: boot firmware request ath11k/WCN6855/hw2.0/board-2.bin size 6179564
      kernel: [  122.518915] ath11k_pci 0000:03:00.0: board name
      kernel: [  122.518917] ath11k_pci 0000:03:00.0: 00000000: 62 75 73 3d 70 63 69                             bus=pci
      kernel: [  122.518918] ath11k_pci 0000:03:00.0: boot found match regdb data for name 'bus=pci'
      kernel: [  122.518920] ath11k_pci 0000:03:00.0: boot found regdb data for 'bus=pci'
      kernel: [  122.518921] ath11k_pci 0000:03:00.0: fetched regdb
      
      Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3
      
      Signed-off-by: default avatarWen Gong <quic_wgong@quicinc.com>
      Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
      Link: https://lore.kernel.org/r/20230517133959.8224-1-quic_wgong@quicinc.com
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8656b31d
    • Aditi Ghag's avatar
      bpf: tcp: Avoid taking fast sock lock in iterator · 4e291a07
      Aditi Ghag authored
      [ Upstream commit 9378096e
      
       ]
      
      This is a preparatory commit to replace `lock_sock_fast` with
      `lock_sock`,and facilitate BPF programs executed from the TCP sockets
      iterator to be able to destroy TCP sockets using the bpf_sock_destroy
      kfunc (implemented in follow-up commits).
      
      Previously, BPF TCP iterator was acquiring the sock lock with BH
      disabled. This led to scenarios where the sockets hash table bucket lock
      can be acquired with BH enabled in some path versus disabled in other.
      In such situation, kernel issued a warning since it thinks that in the
      BH enabled path the same bucket lock *might* be acquired again in the
      softirq context (BH disabled), which will lead to a potential dead lock.
      Since bpf_sock_destroy also happens in a process context, the potential
      deadlock warning is likely a false alarm.
      
      Here is a snippet of annotated stack trace that motivated this change:
      
      ```
      
      Possible interrupt unsafe locking scenario:
      
            CPU0                    CPU1
            ----                    ----
       lock(&h->lhash2[i].lock);
                                    local_bh_disable();
                                    lock(&h->lhash2[i].lock);
      kernel imagined possible scenario:
        local_bh_disable();  /* Possible softirq */
        lock(&h->lhash2[i].lock);
      *** Potential Deadlock ***
      
      process context:
      
      lock_acquire+0xcd/0x330
      _raw_spin_lock+0x33/0x40
      ------> Acquire (bucket) lhash2.lock with BH enabled
      __inet_hash+0x4b/0x210
      inet_csk_listen_start+0xe6/0x100
      inet_listen+0x95/0x1d0
      __sys_listen+0x69/0xb0
      __x64_sys_listen+0x14/0x20
      do_syscall_64+0x3c/0x90
      entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      bpf_sock_destroy run from iterator:
      
      lock_acquire+0xcd/0x330
      _raw_spin_lock+0x33/0x40
      ------> Acquire (bucket) lhash2.lock with BH disabled
      inet_unhash+0x9a/0x110
      tcp_set_state+0x6a/0x210
      tcp_abort+0x10d/0x200
      bpf_prog_6793c5ca50c43c0d_iter_tcp6_server+0xa4/0xa9
      bpf_iter_run_prog+0x1ff/0x340
      ------> lock_sock_fast that acquires sock lock with BH disabled
      bpf_iter_tcp_seq_show+0xca/0x190
      bpf_seq_read+0x177/0x450
      
      ```
      
      Also, Yonghong reported a deadlock for non-listening TCP sockets that
      this change resolves. Previously, `lock_sock_fast` held the sock spin
      lock with BH which was again being acquired in `tcp_abort`:
      
      ```
      watchdog: BUG: soft lockup - CPU#0 stuck for 86s! [test_progs:2331]
      RIP: 0010:queued_spin_lock_slowpath+0xd8/0x500
      Call Trace:
       <TASK>
       _raw_spin_lock+0x84/0x90
       tcp_abort+0x13c/0x1f0
       bpf_prog_88539c5453a9dd47_iter_tcp6_client+0x82/0x89
       bpf_iter_run_prog+0x1aa/0x2c0
       ? preempt_count_sub+0x1c/0xd0
       ? from_kuid_munged+0x1c8/0x210
       bpf_iter_tcp_seq_show+0x14e/0x1b0
       bpf_seq_read+0x36c/0x6a0
      
      bpf_iter_tcp_seq_show
         lock_sock_fast
           __lock_sock_fast
             spin_lock_bh(&sk->sk_lock.slock);
      	/* * Fast path return with bottom halves disabled and * sock::sk_lock.slock held.* */
      
       ...
       tcp_abort
         local_bh_disable();
         spin_lock(&((sk)->sk_lock.slock)); // from bh_lock_sock(sk)
      
      ```
      
      With the switch to `lock_sock`, it calls `spin_unlock_bh` before returning:
      
      ```
      lock_sock
          lock_sock_nested
             spin_lock_bh(&sk->sk_lock.slock);
             :
             spin_unlock_bh(&sk->sk_lock.slock);
      ```
      
      Acked-by: default avatarYonghong Song <yhs@meta.com>
      Acked-by: default avatarStanislav Fomichev <sdf@google.com>
      Signed-off-by: default avatarAditi Ghag <aditi.ghag@isovalent.com>
      Link: https://lore.kernel.org/r/20230519225157.760788-2-aditi.ghag@isovalent.com
      
      
      Signed-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4e291a07
    • Martin KaFai Lau's avatar
      bpf: Address KCSAN report on bpf_lru_list · c006fe36
      Martin KaFai Lau authored
      [ Upstream commit ee9fd0ac
      
       ]
      
      KCSAN reported a data-race when accessing node->ref.
      Although node->ref does not have to be accurate,
      take this chance to use a more common READ_ONCE() and WRITE_ONCE()
      pattern instead of data_race().
      
      There is an existing bpf_lru_node_is_ref() and bpf_lru_node_set_ref().
      This patch also adds bpf_lru_node_clear_ref() to do the
      WRITE_ONCE(node->ref, 0) also.
      
      ==================================================================
      BUG: KCSAN: data-race in __bpf_lru_list_rotate / __htab_lru_percpu_map_update_elem
      
      write to 0xffff888137038deb of 1 bytes by task 11240 on cpu 1:
      __bpf_lru_node_move kernel/bpf/bpf_lru_list.c:113 [inline]
      __bpf_lru_list_rotate_active kernel/bpf/bpf_lru_list.c:149 [inline]
      __bpf_lru_list_rotate+0x1bf/0x750 kernel/bpf/bpf_lru_list.c:240
      bpf_lru_list_pop_free_to_local kernel/bpf/bpf_lru_list.c:329 [inline]
      bpf_common_lru_pop_free kernel/bpf/bpf_lru_list.c:447 [inline]
      bpf_lru_pop_free+0x638/0xe20 kernel/bpf/bpf_lru_list.c:499
      prealloc_lru_pop kernel/bpf/hashtab.c:290 [inline]
      __htab_lru_percpu_map_update_elem+0xe7/0x820 kernel/bpf/hashtab.c:1316
      bpf_percpu_hash_update+0x5e/0x90 kernel/bpf/hashtab.c:2313
      bpf_map_update_value+0x2a9/0x370 kernel/bpf/syscall.c:200
      generic_map_update_batch+0x3ae/0x4f0 kernel/bpf/syscall.c:1687
      bpf_map_do_batch+0x2d9/0x3d0 kernel/bpf/syscall.c:4534
      __sys_bpf+0x338/0x810
      __do_sys_bpf kernel/bpf/syscall.c:5096 [inline]
      __se_sys_bpf kernel/bpf/syscall.c:5094 [inline]
      __x64_sys_bpf+0x43/0x50 kernel/bpf/syscall.c:5094
      do_syscall_x64 arch/x86/entry/common.c:50 [inline]
      do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
      entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      read to 0xffff888137038deb of 1 bytes by task 11241 on cpu 0:
      bpf_lru_node_set_ref kernel/bpf/bpf_lru_list.h:70 [inline]
      __htab_lru_percpu_map_update_elem+0x2f1/0x820 kernel/bpf/hashtab.c:1332
      bpf_percpu_hash_update+0x5e/0x90 kernel/bpf/hashtab.c:2313
      bpf_map_update_value+0x2a9/0x370 kernel/bpf/syscall.c:200
      generic_map_update_batch+0x3ae/0x4f0 kernel/bpf/syscall.c:1687
      bpf_map_do_batch+0x2d9/0x3d0 kernel/bpf/syscall.c:4534
      __sys_bpf+0x338/0x810
      __do_sys_bpf kernel/bpf/syscall.c:5096 [inline]
      __se_sys_bpf kernel/bpf/syscall.c:5094 [inline]
      __x64_sys_bpf+0x43/0x50 kernel/bpf/syscall.c:5094
      do_syscall_x64 arch/x86/entry/common.c:50 [inline]
      do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
      entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      value changed: 0x01 -> 0x00
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 0 PID: 11241 Comm: syz-executor.3 Not tainted 6.3.0-rc7-syzkaller-00136-g6a66fdd29ea1 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/2023
      ==================================================================
      
      Reported-by: default avatar <syzbot+ebe648a84e8784763f82@syzkaller.appspotmail.com>
      Signed-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
      Acked-by: default avatarYonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/r/20230511043748.1384166-1-martin.lau@linux.dev
      
      
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c006fe36
    • Kui-Feng Lee's avatar
      bpf: Print a warning only if writing to unprivileged_bpf_disabled. · 10fa03a9
      Kui-Feng Lee authored
      [ Upstream commit fedf9920
      
       ]
      
      Only print the warning message if you are writing to
      "/proc/sys/kernel/unprivileged_bpf_disabled".
      
      The kernel may print an annoying warning when you read
      "/proc/sys/kernel/unprivileged_bpf_disabled" saying
      
        WARNING: Unprivileged eBPF is enabled with eIBRS on, data leaks possible
        via Spectre v2 BHB attacks!
      
      However, this message is only meaningful when the feature is
      disabled or enabled.
      
      Signed-off-by: default avatarKui-Feng Lee <kuifeng@meta.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Acked-by: default avatarYonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/bpf/20230502181418.308479-1-kuifeng@meta.com
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      10fa03a9
    • Maxime Bizon's avatar
      wifi: ath11k: fix registration of 6Ghz-only phy without the full channel range · 8d134210
      Maxime Bizon authored
      [ Upstream commit e2ceb1de
      
       ]
      
      Because of what seems to be a typo, a 6Ghz-only phy for which the BDF
      does not allow the 7115Mhz channel will fail to register:
      
        WARNING: CPU: 2 PID: 106 at net/wireless/core.c:907 wiphy_register+0x914/0x954
        Modules linked in: ath11k_pci sbsa_gwdt
        CPU: 2 PID: 106 Comm: kworker/u8:5 Not tainted 6.3.0-rc7-next-20230418-00549-g1e096a17625a-dirty #9
        Hardware name: Freebox V7R Board (DT)
        Workqueue: ath11k_qmi_driver_event ath11k_qmi_driver_event_work
        pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
        pc : wiphy_register+0x914/0x954
        lr : ieee80211_register_hw+0x67c/0xc10
        sp : ffffff800b123aa0
        x29: ffffff800b123aa0 x28: 0000000000000000 x27: 0000000000000000
        x26: 0000000000000000 x25: 0000000000000006 x24: ffffffc008d51418
        x23: ffffffc008cb0838 x22: ffffff80176c2460 x21: 0000000000000168
        x20: ffffff80176c0000 x19: ffffff80176c03e0 x18: 0000000000000014
        x17: 00000000cbef338c x16: 00000000d2a26f21 x15: 00000000ad6bb85f
        x14: 0000000000000020 x13: 0000000000000020 x12: 00000000ffffffbd
        x11: 0000000000000208 x10: 00000000fffffdf7 x9 : ffffffc009394718
        x8 : ffffff80176c0528 x7 : 000000007fffffff x6 : 0000000000000006
        x5 : 0000000000000005 x4 : ffffff800b304284 x3 : ffffff800b304284
        x2 : ffffff800b304d98 x1 : 0000000000000000 x0 : 0000000000000000
        Call trace:
         wiphy_register+0x914/0x954
         ieee80211_register_hw+0x67c/0xc10
         ath11k_mac_register+0x7c4/0xe10
         ath11k_core_qmi_firmware_ready+0x1f4/0x570
         ath11k_qmi_driver_event_work+0x198/0x590
         process_one_work+0x1b8/0x328
         worker_thread+0x6c/0x414
         kthread+0x100/0x104
         ret_from_fork+0x10/0x20
        ---[ end trace 0000000000000000 ]---
        ath11k_pci 0002:01:00.0: ieee80211 registration failed: -22
        ath11k_pci 0002:01:00.0: failed register the radio with mac80211: -22
        ath11k_pci 0002:01:00.0: failed to create pdev core: -22
      
      Signed-off-by: default avatarMaxime Bizon <mbizon@freebox.fr>
      Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
      Link: https://lore.kernel.org/r/20230421145445.2612280-1-mbizon@freebox.fr
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8d134210
    • Yicong Yang's avatar
      sched/fair: Don't balance task to its current running CPU · 78a5f711
      Yicong Yang authored
      [ Upstream commit 0dd37d6d
      
       ]
      
      We've run into the case that the balancer tries to balance a migration
      disabled task and trigger the warning in set_task_cpu() like below:
      
       ------------[ cut here ]------------
       WARNING: CPU: 7 PID: 0 at kernel/sched/core.c:3115 set_task_cpu+0x188/0x240
       Modules linked in: hclgevf xt_CHECKSUM ipt_REJECT nf_reject_ipv4 <...snip>
       CPU: 7 PID: 0 Comm: swapper/7 Kdump: loaded Tainted: G           O       6.1.0-rc4+ #1
       Hardware name: Huawei TaiShan 2280 V2/BC82AMDC, BIOS 2280-V2 CS V5.B221.01 12/09/2021
       pstate: 604000c9 (nZCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
       pc : set_task_cpu+0x188/0x240
       lr : load_balance+0x5d0/0xc60
       sp : ffff80000803bc70
       x29: ffff80000803bc70 x28: ffff004089e190e8 x27: ffff004089e19040
       x26: ffff007effcabc38 x25: 0000000000000000 x24: 0000000000000001
       x23: ffff80000803be84 x22: 000000000000000c x21: ffffb093e79e2a78
       x20: 000000000000000c x19: ffff004089e19040 x18: 0000000000000000
       x17: 0000000000001fad x16: 0000000000000030 x15: 0000000000000000
       x14: 0000000000000003 x13: 0000000000000000 x12: 0000000000000000
       x11: 0000000000000001 x10: 0000000000000400 x9 : ffffb093e4cee530
       x8 : 00000000fffffffe x7 : 0000000000ce168a x6 : 000000000000013e
       x5 : 00000000ffffffe1 x4 : 0000000000000001 x3 : 0000000000000b2a
       x2 : 0000000000000b2a x1 : ffffb093e6d6c510 x0 : 0000000000000001
       Call trace:
        set_task_cpu+0x188/0x240
        load_balance+0x5d0/0xc60
        rebalance_domains+0x26c/0x380
        _nohz_idle_balance.isra.0+0x1e0/0x370
        run_rebalance_domains+0x6c/0x80
        __do_softirq+0x128/0x3d8
        ____do_softirq+0x18/0x24
        call_on_irq_stack+0x2c/0x38
        do_softirq_own_stack+0x24/0x3c
        __irq_exit_rcu+0xcc/0xf4
        irq_exit_rcu+0x18/0x24
        el1_interrupt+0x4c/0xe4
        el1h_64_irq_handler+0x18/0x2c
        el1h_64_irq+0x74/0x78
        arch_cpu_idle+0x18/0x4c
        default_idle_call+0x58/0x194
        do_idle+0x244/0x2b0
        cpu_startup_entry+0x30/0x3c
        secondary_start_kernel+0x14c/0x190
        __secondary_switched+0xb0/0xb4
       ---[ end trace 0000000000000000 ]---
      
      Further investigation shows that the warning is superfluous, the migration
      disabled task is just going to be migrated to its current running CPU.
      This is because that on load balance if the dst_cpu is not allowed by the
      task, we'll re-select a new_dst_cpu as a candidate. If no task can be
      balanced to dst_cpu we'll try to balance the task to the new_dst_cpu
      instead. In this case when the migration disabled task is not on CPU it
      only allows to run on its current CPU, load balance will select its
      current CPU as new_dst_cpu and later triggers the warning above.
      
      The new_dst_cpu is chosen from the env->dst_grpmask. Currently it
      contains CPUs in sched_group_span() and if we have overlapped groups it's
      possible to run into this case. This patch makes env->dst_grpmask of
      group_balance_mask() which exclude any CPUs from the busiest group and
      solve the issue. For balancing in a domain with no overlapped groups
      the behaviour keeps same as before.
      
      Suggested-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
      Signed-off-by: default avatarYicong Yang <yangyicong@hisilicon.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
      Link: https://lore.kernel.org/r/20230530082507.10444-1-yangyicong@huawei.com
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      78a5f711
    • Paul E. McKenney's avatar
      rcu: Mark additional concurrent load from ->cpu_no_qs.b.exp · 896f4d60
      Paul E. McKenney authored
      [ Upstream commit 9146eb25
      
       ]
      
      The per-CPU rcu_data structure's ->cpu_no_qs.b.exp field is updated
      only on the instance corresponding to the current CPU, but can be read
      more widely.  Unmarked accesses are OK from the corresponding CPU, but
      only if interrupts are disabled, given that interrupt handlers can and
      do modify this field.
      
      Unfortunately, although the load from rcu_preempt_deferred_qs() is always
      carried out from the corresponding CPU, interrupts are not necessarily
      disabled.  This commit therefore upgrades this load to READ_ONCE.
      
      Similarly, the diagnostic access from synchronize_rcu_expedited_wait()
      might run with interrupts disabled and from some other CPU.  This commit
      therefore marks this load with data_race().
      
      Finally, the C-language access in rcu_preempt_ctxt_queue() is OK as
      is because interrupts are disabled and this load is always from the
      corresponding CPU.  This commit adds a comment giving the rationale for
      this access being safe.
      
      This data race was reported by KCSAN.  Not appropriate for backporting
      due to failure being unlikely.
      
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      896f4d60
    • Shigeru Yoshida's avatar
      rcu-tasks: Avoid pr_info() with spin lock in cblist_init_generic() · 9027d692
      Shigeru Yoshida authored
      [ Upstream commit 5fc8cbe4
      
       ]
      
      pr_info() is called with rtp->cbs_gbl_lock spin lock locked.  Because
      pr_info() calls printk() that might sleep, this will result in BUG
      like below:
      
      [    0.206455] cblist_init_generic: Setting adjustable number of callback queues.
      [    0.206463]
      [    0.206464] =============================
      [    0.206464] [ BUG: Invalid wait context ]
      [    0.206465] 5.19.0-00428-g9de1f9c8ca51 #5 Not tainted
      [    0.206466] -----------------------------
      [    0.206466] swapper/0/1 is trying to lock:
      [    0.206467] ffffffffa0167a58 (&port_lock_key){....}-{3:3}, at: serial8250_console_write+0x327/0x4a0
      [    0.206473] other info that might help us debug this:
      [    0.206473] context-{5:5}
      [    0.206474] 3 locks held by swapper/0/1:
      [    0.206474]  #0: ffffffff9eb597e0 (rcu_tasks.cbs_gbl_lock){....}-{2:2}, at: cblist_init_generic.constprop.0+0x14/0x1f0
      [    0.206478]  #1: ffffffff9eb579c0 (console_lock){+.+.}-{0:0}, at: _printk+0x63/0x7e
      [    0.206482]  #2: ffffffff9ea77780 (console_owner){....}-{0:0}, at: console_emit_next_record.constprop.0+0x111/0x330
      [    0.206485] stack backtrace:
      [    0.206486] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.19.0-00428-g9de1f9c8ca51 #5
      [    0.206488] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.0-1.fc36 04/01/2014
      [    0.206489] Call Trace:
      [    0.206490]  <TASK>
      [    0.206491]  dump_stack_lvl+0x6a/0x9f
      [    0.206493]  __lock_acquire.cold+0x2d7/0x2fe
      [    0.206496]  ? stack_trace_save+0x46/0x70
      [    0.206497]  lock_acquire+0xd1/0x2f0
      [    0.206499]  ? serial8250_console_write+0x327/0x4a0
      [    0.206500]  ? __lock_acquire+0x5c7/0x2720
      [    0.206502]  _raw_spin_lock_irqsave+0x3d/0x90
      [    0.206504]  ? serial8250_console_write+0x327/0x4a0
      [    0.206506]  serial8250_console_write+0x327/0x4a0
      [    0.206508]  console_emit_next_record.constprop.0+0x180/0x330
      [    0.206511]  console_unlock+0xf7/0x1f0
      [    0.206512]  vprintk_emit+0xf7/0x330
      [    0.206514]  _printk+0x63/0x7e
      [    0.206516]  cblist_init_generic.constprop.0.cold+0x24/0x32
      [    0.206518]  rcu_init_tasks_generic+0x5/0xd9
      [    0.206522]  kernel_init_freeable+0x15b/0x2a2
      [    0.206523]  ? rest_init+0x160/0x160
      [    0.206526]  kernel_init+0x11/0x120
      [    0.206527]  ret_from_fork+0x1f/0x30
      [    0.206530]  </TASK>
      [    0.207018] cblist_init_generic: Setting shift to 1 and lim to 1.
      
      This patch moves pr_info() so that it is called without
      rtp->cbs_gbl_lock locked.
      
      Signed-off-by: default avatarShigeru Yoshida <syoshida@redhat.com>
      Tested-by: default avatar"Zhang, Qiang1" <qiang1.zhang@intel.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9027d692
    • Hans de Goede's avatar
      ACPI: video: Add backlight=native DMI quirk for Dell Studio 1569 · e055d0ec
      Hans de Goede authored
      [ Upstream commit 23d28cc0
      
       ]
      
      The Dell Studio 1569 predates Windows 8, so it defaults to using
      acpi_video# for backlight control, but this is non functional on
      this model.
      
      Add a DMI quirk to use the native intel_backlight interface which
      does work properly.
      
      Reported-by: default avatarraycekarneal <raycekarneal@gmail.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e055d0ec
    • Immad Mir's avatar
      FS: JFS: Check for read-only mounted filesystem in txBegin · aa7cdf48
      Immad Mir authored
      [ Upstream commit 95e2b352
      
       ]
      
       This patch adds a check for read-only mounted filesystem
       in txBegin before starting a transaction potentially saving
       from NULL pointer deref.
      
      Signed-off-by: default avatarImmad Mir <mirimmad17@gmail.com>
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      aa7cdf48
    • Immad Mir's avatar
      FS: JFS: Fix null-ptr-deref Read in txBegin · 3e5eb6c5
      Immad Mir authored
      [ Upstream commit 47cfdc33
      
       ]
      
       Syzkaller reported an issue where txBegin may be called
       on a superblock in a read-only mounted filesystem which leads
       to NULL pointer deref. This could be solved by checking if
       the filesystem is read-only before calling txBegin, and returning
       with appropiate error code.
      
      Reported-By: default avatar <syzbot+f1faa20eec55e0c8644c@syzkaller.appspotmail.com>
      Link: https://syzkaller.appspot.com/bug?id=be7e52c50c5182cc09a09ea6fc456446b2039de3
      
      
      
      Signed-off-by: default avatarImmad Mir <mirimmad17@gmail.com>
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3e5eb6c5
    • Gustavo A. R. Silva's avatar
      MIPS: dec: prom: Address -Warray-bounds warning · da0a7c69
      Gustavo A. R. Silva authored
      [ Upstream commit 7b191b9b ]
      
      Zero-length arrays are deprecated, and we are replacing them with flexible
      array members instead. So, replace zero-length array with flexible-array
      member in struct memmap.
      
      Address the following warning found after building (with GCC-13) mips64
      with decstation_64_defconfig:
      In function 'rex_setup_memory_region',
          inlined from 'prom_meminit' at arch/mips/dec/prom/memory.c:91:3:
      arch/mips/dec/prom/memory.c:72:31: error: array subscript i is outside array bounds of 'unsigned char[0]' [-Werror=array-bounds=]
         72 |                 if (bm->bitmap[i] == 0xff)
            |                     ~~~~~~~~~~^~~
      In file included from arch/mips/dec/prom/memory.c:16:
      ./arch/mips/include/asm/dec/prom.h: In function 'prom_meminit':
      ./arch/mips/include/asm/dec/prom.h:73:23: note: while referencing 'bitmap'
         73 |         unsigned char bitmap[0];
      
      This helps with the ongoing efforts to globally enable -Warray-bounds.
      
      This results in no differences in binary output.
      
      Link: https://github.com/KSPP/linux/issues/79
      Link: https://github.com/KSPP/linux/issues/323
      
      
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      da0a7c69
    • Yogesh's avatar
      fs: jfs: Fix UBSAN: array-index-out-of-bounds in dbAllocDmapLev · bdf07ab1
      Yogesh authored
      [ Upstream commit 4e302336
      
       ]
      
      Syzkaller reported the following issue:
      
      UBSAN: array-index-out-of-bounds in fs/jfs/jfs_dmap.c:1965:6
      index -84 is out of range for type 's8[341]' (aka 'signed char[341]')
      CPU: 1 PID: 4995 Comm: syz-executor146 Not tainted 6.4.0-rc6-syzkaller-00037-gb6dad5178cea #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
       ubsan_epilogue lib/ubsan.c:217 [inline]
       __ubsan_handle_out_of_bounds+0x11c/0x150 lib/ubsan.c:348
       dbAllocDmapLev+0x3e5/0x430 fs/jfs/jfs_dmap.c:1965
       dbAllocCtl+0x113/0x920 fs/jfs/jfs_dmap.c:1809
       dbAllocAG+0x28f/0x10b0 fs/jfs/jfs_dmap.c:1350
       dbAlloc+0x658/0xca0 fs/jfs/jfs_dmap.c:874
       dtSplitUp fs/jfs/jfs_dtree.c:974 [inline]
       dtInsert+0xda7/0x6b00 fs/jfs/jfs_dtree.c:863
       jfs_create+0x7b6/0xbb0 fs/jfs/namei.c:137
       lookup_open fs/namei.c:3492 [inline]
       open_last_lookups fs/namei.c:3560 [inline]
       path_openat+0x13df/0x3170 fs/namei.c:3788
       do_filp_open+0x234/0x490 fs/namei.c:3818
       do_sys_openat2+0x13f/0x500 fs/open.c:1356
       do_sys_open fs/open.c:1372 [inline]
       __do_sys_openat fs/open.c:1388 [inline]
       __se_sys_openat fs/open.c:1383 [inline]
       __x64_sys_openat+0x247/0x290 fs/open.c:1383
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      RIP: 0033:0x7f1f4e33f7e9
      Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 14 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007ffc21129578 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
      RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f1f4e33f7e9
      RDX: 000000000000275a RSI: 0000000020000040 RDI: 00000000ffffff9c
      RBP: 00007f1f4e2ff080 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 00007f1f4e2ff110
      R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
       </TASK>
      
      The bug occurs when the dbAllocDmapLev()function attempts to access
      dp->tree.stree[leafidx + LEAFIND] while the leafidx value is negative.
      
      To rectify this, the patch introduces a safeguard within the
      dbAllocDmapLev() function. A check has been added to verify if leafidx is
      negative. If it is, the function immediately returns an I/O error, preventing
      any further execution that could potentially cause harm.
      
      Tested via syzbot.
      
      Reported-by: default avatar <syzbot+853a6f4dfa3cf37d3aea@syzkaller.appspotmail.com>
      Link: https://syzkaller.appspot.com/bug?extid=ae2f5a27a07ae44b0f17
      
      
      Signed-off-by: default avatarYogesh <yogi.kernel@gmail.com>
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bdf07ab1
    • Jan Kara's avatar
      udf: Fix uninitialized array access for some pathnames · a6824149
      Jan Kara authored
      [ Upstream commit 028f6055
      
       ]
      
      For filenames that begin with . and are between 2 and 5 characters long,
      UDF charset conversion code would read uninitialized memory in the
      output buffer. The only practical impact is that the name may be prepended a
      "unification hash" when it is not actually needed but still it is good
      to fix this.
      
      Reported-by: default avatar <syzbot+cd311b1e43cc25f90d18@syzkaller.appspotmail.com>
      Link: https://lore.kernel.org/all/000000000000e2638a05fe9dc8f9@google.com
      
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a6824149
    • Christian Brauner's avatar
      ovl: check type and offset of struct vfsmount in ovl_entry · cce9107c
      Christian Brauner authored
      [ Upstream commit f723edb8
      
       ]
      
      Porting overlayfs to the new amount api I started experiencing random
      crashes that couldn't be explained easily. So after much debugging and
      reasoning it became clear that struct ovl_entry requires the point to
      struct vfsmount to be the first member and of type struct vfsmount.
      
      During the port I added a new member at the beginning of struct
      ovl_entry which broke all over the place in the form of random crashes
      and cache corruptions. While there's a comment in ovl_free_fs() to the
      effect of "Hack! Reuse ofs->layers as a vfsmount array before freeing
      it" there's no such comment on struct ovl_entry which makes this easy to
      trip over.
      
      Add a comment and two static asserts for both the offset and the type of
      pointer in struct ovl_entry.
      
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cce9107c
    • Marco Morandini's avatar
      HID: add quirk for 03f0:464a HP Elite Presenter Mouse · 5228d4d5
      Marco Morandini authored
      [ Upstream commit 0db11735
      
       ]
      
      HP Elite Presenter Mouse HID Record Descriptor shows
      two mouses (Repord ID 0x1 and 0x2), one keypad (Report ID 0x5),
      two Consumer Controls (Report IDs 0x6 and 0x3).
      Previous to this commit it registers one mouse, one keypad
      and one Consumer Control, and it was usable only as a
      digitl laser pointer (one of the two mouses). This patch defines
      the 464a USB device ID and enables the HID_QUIRK_MULTI_INPUT
      quirk for it, allowing to use the device both as a mouse
      and a digital laser pointer.
      
      Signed-off-by: default avatarMarco Morandini <marco.morandini@polimi.it>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5228d4d5
    • Ye Bin's avatar
      quota: fix warning in dqgrab() · 6432843d
      Ye Bin authored
      [ Upstream commit d6a95db3
      
       ]
      
      There's issue as follows when do fault injection:
      WARNING: CPU: 1 PID: 14870 at include/linux/quotaops.h:51 dquot_disable+0x13b7/0x18c0
      Modules linked in:
      CPU: 1 PID: 14870 Comm: fsconfig Not tainted 6.3.0-next-20230505-00006-g5107a9c821af-dirty #541
      RIP: 0010:dquot_disable+0x13b7/0x18c0
      RSP: 0018:ffffc9000acc79e0 EFLAGS: 00010246
      RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff88825e41b980
      RDX: 0000000000000000 RSI: ffff88825e41b980 RDI: 0000000000000002
      RBP: ffff888179f68000 R08: ffffffff82087ca7 R09: 0000000000000000
      R10: 0000000000000001 R11: ffffed102f3ed026 R12: ffff888179f68130
      R13: ffff888179f68110 R14: dffffc0000000000 R15: ffff888179f68118
      FS:  00007f450a073740(0000) GS:ffff88882fc00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007ffe96f2efd8 CR3: 000000025c8ad000 CR4: 00000000000006e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       <TASK>
       dquot_load_quota_sb+0xd53/0x1060
       dquot_resume+0x172/0x230
       ext4_reconfigure+0x1dc6/0x27b0
       reconfigure_super+0x515/0xa90
       __x64_sys_fsconfig+0xb19/0xd20
       do_syscall_64+0x39/0xb0
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Above issue may happens as follows:
      ProcessA              ProcessB                    ProcessC
      sys_fsconfig
        vfs_fsconfig_locked
         reconfigure_super
           ext4_remount
            dquot_suspend -> suspend all type quota
      
                       sys_fsconfig
                        vfs_fsconfig_locked
                          reconfigure_super
                           ext4_remount
                            dquot_resume
                             ret = dquot_load_quota_sb
                              add_dquot_ref
                                                 do_open  -> open file O_RDWR
                                                  vfs_open
                                                   do_dentry_open
                                                    get_write_access
                                                     atomic_inc_unless_negative(&inode->i_writecount)
                                                    ext4_file_open
                                                     dquot_file_open
                                                      dquot_initialize
                                                        __dquot_initialize
                                                         dqget
      						    atomic_inc(&dquot->dq_count);
      
                                __dquot_initialize
                                 __dquot_initialize
                                  dqget
                                   if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
                                     ext4_acquire_dquot
      			        -> Return error DQ_ACTIVE_B flag isn't set
                               dquot_disable
      			  invalidate_dquots
      			   if (atomic_read(&dquot->dq_count))
      	                    dqgrab
      			     WARN_ON_ONCE(!test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
      	                      -> Trigger warning
      
      In the above scenario, 'dquot->dq_flags' has no DQ_ACTIVE_B is normal when
      dqgrab().
      To solve above issue just replace the dqgrab() use in invalidate_dquots() with
      atomic_inc(&dquot->dq_count).
      
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Message-Id: <20230605140731.2427629-3-yebin10@huawei.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6432843d
    • Jan Kara's avatar
      quota: Properly disable quotas when add_dquot_ref() fails · 1f2ec87f
      Jan Kara authored
      [ Upstream commit 6a4e3363
      
       ]
      
      When add_dquot_ref() fails (usually due to IO error or ENOMEM), we want
      to disable quotas we are trying to enable. However dquot_disable() call
      was passed just the flags we are enabling so in case flags ==
      DQUOT_USAGE_ENABLED dquot_disable() call will just fail with EINVAL
      instead of properly disabling quotas. Fix the problem by always passing
      DQUOT_LIMITS_ENABLED | DQUOT_USAGE_ENABLED to dquot_disable() in this
      case.
      
      Reported-and-tested-by: default avatarYe Bin <yebin10@huawei.com>
      Reported-by: default avatar <syzbot+e633c79ceaecbf479854@syzkaller.appspotmail.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Message-Id: <20230605140731.2427629-2-yebin10@huawei.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1f2ec87f