Skip to content
  1. Sep 13, 2023
    • Matthew Wilcox (Oracle)'s avatar
      XArray: Do not return sibling entries from xa_load() · 4a3e0d51
      Matthew Wilcox (Oracle) authored
      commit cbc02854
      
       upstream.
      
      It is possible for xa_load() to observe a sibling entry pointing to
      another sibling entry.  An example:
      
      Thread A:		Thread B:
      			xa_store_range(xa, entry, 188, 191, gfp);
      xa_load(xa, 191);
      entry = xa_entry(xa, node, 63);
      [entry is a sibling of 188]
      			xa_store_range(xa, entry, 184, 191, gfp);
      if (xa_is_sibling(entry))
      offset = xa_to_sibling(entry);
      entry = xa_entry(xas->xa, node, offset);
      [entry is now a sibling of 184]
      
      It is sufficient to go around this loop until we hit a non-sibling entry.
      Sibling entries always point earlier in the node, so we are guaranteed
      to terminate this search.
      
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Fixes: 6b24ca4a
      
       ("mm: Use multi-index entries in the page cache")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4a3e0d51
    • Gustavo A. R. Silva's avatar
      ARM: OMAP2+: Fix -Warray-bounds warning in _pwrdm_state_switch() · 7a7f1128
      Gustavo A. R. Silva authored
      commit 847fb80c upstream.
      
      If function pwrdm_read_prev_pwrst() returns -EINVAL, we will end
      up accessing array pwrdm->state_counter through negative index
      -22. This is wrong and the compiler is legitimately warning us
      about this potential problem.
      
      Fix this by sanity checking the value stored in variable _prev_
      before accessing array pwrdm->state_counter.
      
      Address the following -Warray-bounds warning:
      arch/arm/mach-omap2/powerdomain.c:178:45: warning: array subscript -22 is below array bounds of 'unsigned int[4]' [-Warray-bounds]
      
      Link: https://github.com/KSPP/linux/issues/307
      Fixes: ba20bb12
      
       ("OMAP: PM counter infrastructure.")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Link: https://lore.kernel.org/lkml/20230607050639.LzbPn%25lkp@intel.com/
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Message-ID: <ZIFVGwImU3kpaGeH@work>
      Acked-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7a7f1128
    • Yi Yang's avatar
      ipmi_si: fix a memleak in try_smi_init() · 09cb2a71
      Yi Yang authored
      commit 6cf1a126 upstream.
      
      Kmemleak reported the following leak info in try_smi_init():
      
      unreferenced object 0xffff00018ecf9400 (size 1024):
        comm "modprobe", pid 2707763, jiffies 4300851415 (age 773.308s)
        backtrace:
          [<000000004ca5b312>] __kmalloc+0x4b8/0x7b0
          [<00000000953b1072>] try_smi_init+0x148/0x5dc [ipmi_si]
          [<000000006460d325>] 0xffff800081b10148
          [<0000000039206ea5>] do_one_initcall+0x64/0x2a4
          [<00000000601399ce>] do_init_module+0x50/0x300
          [<000000003c12ba3c>] load_module+0x7a8/0x9e0
          [<00000000c246fffe>] __se_sys_init_module+0x104/0x180
          [<00000000eea99093>] __arm64_sys_init_module+0x24/0x30
          [<0000000021b1ef87>] el0_svc_common.constprop.0+0x94/0x250
          [<0000000070f4f8b7>] do_el0_svc+0x48/0xe0
          [<000000005a05337f>] el0_svc+0x24/0x3c
          [<000000005eb248d6>] el0_sync_handler+0x160/0x164
          [<0000000030a59039>] el0_sync+0x160/0x180
      
      The problem was that when an error occurred before handlers registration
      and after allocating `new_smi->si_sm`, the variable wouldn't be freed in
      the error handling afterwards since `shutdown_smi()` hadn't been
      registered yet. Fix it by adding a `kfree()` in the error handling path
      in `try_smi_init()`.
      
      Cc: stable@vger.kernel.org # 4.19+
      Fixes: 7960f18a
      
       ("ipmi_si: Convert over to a shutdown handler")
      Signed-off-by: default avatarYi Yang <yiyang13@huawei.com>
      Co-developed-by: default avatarGONG, Ruiqi <gongruiqi@huaweicloud.com>
      Signed-off-by: default avatarGONG, Ruiqi <gongruiqi@huaweicloud.com>
      Message-Id: <20230629123328.2402075-1-gongruiqi@huaweicloud.com>
      Signed-off-by: default avatarCorey Minyard <minyard@acm.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      09cb2a71
    • Rick Wertenbroek's avatar
      PCI: rockchip: Use 64-bit mask on MSI 64-bit PCI address · dafe7acf
      Rick Wertenbroek authored
      commit cdb50033 upstream.
      
      A 32-bit mask was used on the 64-bit PCI address used for mapping MSIs.
      This would result in the upper 32 bits being unintentionally zeroed and
      MSIs getting mapped to incorrect PCI addresses if the address had any
      of the upper bits set.
      
      Replace 32-bit mask by appropriate 64-bit mask.
      
      [kwilczynski: use GENMASK_ULL() over GENMASK() for 32-bit compatibility]
      Fixes: dc73ed0f
      
       ("PCI: rockchip: Fix window mapping and address translation for endpoint")
      Closes: https://lore.kernel.org/linux-pci/8d19e5b7-8fa0-44a4-90e2-9bb06f5eb694@moroto.mountain
      Link: https://lore.kernel.org/linux-pci/20230703085845.2052008-1-rick.wertenbroek@gmail.com
      Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
      Signed-off-by: default avatarRick Wertenbroek <rick.wertenbroek@gmail.com>
      Signed-off-by: default avatarKrzysztof Wilczyński <kwilczynski@kernel.org>
      Reviewed-by: default avatarDamien Le Moal <dlemoal@kernel.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dafe7acf
    • Sakari Ailus's avatar
      media: i2c: Add a camera sensor top level menu · 823f52da
      Sakari Ailus authored
      commit 7d3c7d2a
      
       upstream.
      
      Select V4L2_FWNODE and VIDEO_V4L2_SUBDEV_API for all sensor drivers. This
      also adds the options to drivers that don't specifically need them, these
      are still seldom used drivers using old APIs. The upside is that these
      should now all compile --- many drivers have had missing dependencies.
      
      The "menu" is replaced by selectable "menuconfig" to select the needed
      V4L2_FWNODE and VIDEO_V4L2_SUBDEV_API options.
      
      Also select MEDIA_CONTROLLER which VIDEO_V4L2_SUBDEV_API effectively
      depends on, and add the I2C dependency to the menu.
      
      Reported-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Cc: stable@vger.kernel.org # for >= 6.1
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      823f52da
    • Sakari Ailus's avatar
      media: i2c: ccs: Check rules is non-NULL · ceedc62a
      Sakari Ailus authored
      commit 607bcc42
      
       upstream.
      
      Fix the following smatch warning:
      
      drivers/media/i2c/ccs/ccs-data.c:524 ccs_data_parse_rules() warn: address
      of NULL pointer 'rules'
      
      The CCS static data rule parser does not check an if rule has been
      obtained before checking for other rule types (which depend on the if
      rule). In practice this means parsing invalid CCS static data could lead
      to dereferencing a NULL pointer.
      
      Reported-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
      Fixes: a6b396f4
      
       ("media: ccs: Add CCS static data parser library")
      Cc: stable@vger.kernel.org # for 5.11 and up
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ceedc62a
    • Thomas Gleixner's avatar
      cpu/hotplug: Prevent self deadlock on CPU hot-unplug · fea9dd86
      Thomas Gleixner authored
      commit 2b8272ff
      
       upstream.
      
      Xiongfeng reported and debugged a self deadlock of the task which initiates
      and controls a CPU hot-unplug operation vs. the CFS bandwidth timer.
      
          CPU1      			                 	 CPU2
      
      T1 sets cfs_quota
         starts hrtimer cfs_bandwidth 'period_timer'
      T1 is migrated to CPU2
      						T1 initiates offlining of CPU1
      Hotplug operation starts
        ...
      'period_timer' expires and is re-enqueued on CPU1
        ...
      take_cpu_down()
        CPU1 shuts down and does not handle timers
        anymore. They have to be migrated in the
        post dead hotplug steps by the control task.
      
      						T1 runs the post dead offline operation
      					      	T1 is scheduled out
      						T1 waits for 'period_timer' to expire
      
      T1 waits there forever if it is scheduled out before it can execute the hrtimer
      offline callback hrtimers_dead_cpu().
      
      Cure this by delegating the hotplug control operation to a worker thread on
      an online CPU. This takes the initiating user space task, which might be
      affected by the bandwidth timer, completely out of the picture.
      
      Reported-by: default avatarXiongfeng Wang <wangxiongfeng2@huawei.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarYu Liao <liaoyu15@huawei.com>
      Acked-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/lkml/8e785777-03aa-99e1-d20e-e956f5685be6@huawei.com
      Link: https://lore.kernel.org/r/87h6oqdq0i.ffs@tglx
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fea9dd86
    • Joel Fernandes (Google)'s avatar
      mm/vmalloc: add a safer version of find_vm_area() for debug · 4245ca8f
      Joel Fernandes (Google) authored
      commit 0818e739 upstream.
      
      It is unsafe to dump vmalloc area information when trying to do so from
      some contexts.  Add a safer trylock version of the same function to do a
      best-effort VMA finding and use it from vmalloc_dump_obj().
      
      [applied test robot feedback on unused function fix.]
      [applied Uladzislau feedback on locking.]
      Link: https://lkml.kernel.org/r/20230904180806.1002832-1-joel@joelfernandes.org
      Fixes: 98f18083
      
       ("mm: Make mem_dump_obj() handle vmalloc() memory")
      Signed-off-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>
      Reviewed-by: default avatarUladzislau Rezki (Sony) <urezki@gmail.com>
      Reported-by: default avatarZhen Lei <thunder.leizhen@huaweicloud.com>
      Cc: Paul E. McKenney <paulmck@kernel.org>
      Cc: Zqiang <qiang.zhang1211@gmail.com>
      Cc: <stable@vger.kernel.org>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4245ca8f
    • Bart Van Assche's avatar
      scsi: core: Fix the scsi_set_resid() documentation · 157c4636
      Bart Van Assche authored
      commit f669b8a6 upstream.
      
      Because scsi_finish_command() subtracts the residual from the buffer
      length, residual overflows must not be reported. Reflect this in the SCSI
      documentation. See also commit 9237f04e
      
       ("scsi: core: Fix
      scsi_get/set_resid() interface")
      
      Cc: Damien Le Moal <dlemoal@kernel.org>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Link: https://lore.kernel.org/r/20230721160154.874010-2-bvanassche@acm.org
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      157c4636
    • Kees Cook's avatar
      printk: ringbuffer: Fix truncating buffer size min_t cast · 2344b139
      Kees Cook authored
      commit 53e9e33e
      
       upstream.
      
      If an output buffer size exceeded U16_MAX, the min_t(u16, ...) cast in
      copy_data() was causing writes to truncate. This manifested as output
      bytes being skipped, seen as %NUL bytes in pstore dumps when the available
      record size was larger than 65536. Fix the cast to no longer truncate
      the calculation.
      
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Reported-by: default avatarVijay Balakrishna <vijayb@linux.microsoft.com>
      Link: https://lore.kernel.org/lkml/d8bb1ec7-a4c5-43a2-9de0-9643a70b899f@linux.microsoft.com/
      Fixes: b6cf8b3f
      
       ("printk: add lockless ringbuffer")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Tested-by: default avatarVijay Balakrishna <vijayb@linux.microsoft.com>
      Tested-by: Guilherme G. Piccoli <gpiccoli@igalia.com> # Steam Deck
      Reviewed-by: default avatarTyler Hicks (Microsoft) <code@tyhicks.com>
      Tested-by: default avatarTyler Hicks (Microsoft) <code@tyhicks.com>
      Reviewed-by: default avatarJohn Ogness <john.ogness@linutronix.de>
      Reviewed-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
      Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
      Link: https://lore.kernel.org/r/20230811054528.never.165-kees@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2344b139
    • Zqiang's avatar
      rcu: dump vmalloc memory info safely · 3f7a4e88
      Zqiang authored
      commit c83ad36a upstream.
      
      Currently, for double invoke call_rcu(), will dump rcu_head objects memory
      info, if the objects is not allocated from the slab allocator, the
      vmalloc_dump_obj() will be invoke and the vmap_area_lock spinlock need to
      be held, since the call_rcu() can be invoked in interrupt context,
      therefore, there is a possibility of spinlock deadlock scenarios.
      
      And in Preempt-RT kernel, the rcutorture test also trigger the following
      lockdep warning:
      
      BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
      in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 1, name: swapper/0
      preempt_count: 1, expected: 0
      RCU nest depth: 1, expected: 1
      3 locks held by swapper/0/1:
       #0: ffffffffb534ee80 (fullstop_mutex){+.+.}-{4:4}, at: torture_init_begin+0x24/0xa0
       #1: ffffffffb5307940 (rcu_read_lock){....}-{1:3}, at: rcu_torture_init+0x1ec7/0x2370
       #2: ffffffffb536af40 (vmap_area_lock){+.+.}-{3:3}, at: find_vmap_area+0x1f/0x70
      irq event stamp: 565512
      hardirqs last  enabled at (565511): [<ffffffffb379b138>] __call_rcu_common+0x218/0x940
      hardirqs last disabled at (565512): [<ffffffffb5804262>] rcu_torture_init+0x20b2/0x2370
      softirqs last  enabled at (399112): [<ffffffffb36b2586>] __local_bh_enable_ip+0x126/0x170
      softirqs last disabled at (399106): [<ffffffffb43fef59>] inet_register_protosw+0x9/0x1d0
      Preemption disabled at:
      [<ffffffffb58040c3>] rcu_torture_init+0x1f13/0x2370
      CPU: 0 PID: 1 Comm: swapper/0 Tainted: G        W          6.5.0-rc4-rt2-yocto-preempt-rt+ #15
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org 04/01/2014
      Call Trace:
       <TASK>
       dump_stack_lvl+0x68/0xb0
       dump_stack+0x14/0x20
       __might_resched+0x1aa/0x280
       ? __pfx_rcu_torture_err_cb+0x10/0x10
       rt_spin_lock+0x53/0x130
       ? find_vmap_area+0x1f/0x70
       find_vmap_area+0x1f/0x70
       vmalloc_dump_obj+0x20/0x60
       mem_dump_obj+0x22/0x90
       __call_rcu_common+0x5bf/0x940
       ? debug_smp_processor_id+0x1b/0x30
       call_rcu_hurry+0x14/0x20
       rcu_torture_init+0x1f82/0x2370
       ? __pfx_rcu_torture_leak_cb+0x10/0x10
       ? __pfx_rcu_torture_leak_cb+0x10/0x10
       ? __pfx_rcu_torture_init+0x10/0x10
       do_one_initcall+0x6c/0x300
       ? debug_smp_processor_id+0x1b/0x30
       kernel_init_freeable+0x2b9/0x540
       ? __pfx_kernel_init+0x10/0x10
       kernel_init+0x1f/0x150
       ret_from_fork+0x40/0x50
       ? __pfx_kernel_init+0x10/0x10
       ret_from_fork_asm+0x1b/0x30
       </TASK>
      
      The previous patch fixes this by using the deadlock-safe best-effort
      version of find_vm_area.  However, in case of failure print the fact that
      the pointer was a vmalloc pointer so that we print at least something.
      
      Link: https://lkml.kernel.org/r/20230904180806.1002832-2-joel@joelfernandes.org
      Fixes: 98f18083
      
       ("mm: Make mem_dump_obj() handle vmalloc() memory")
      Signed-off-by: default avatarZqiang <qiang.zhang1211@gmail.com>
      Signed-off-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>
      Reported-by: default avatarZhen Lei <thunder.leizhen@huaweicloud.com>
      Reviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Cc: Paul E. McKenney <paulmck@kernel.org>
      Cc: Uladzislau Rezki (Sony) <urezki@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f7a4e88
    • Takashi Iwai's avatar
      ALSA: pcm: Fix missing fixup call in compat hw_refine ioctl · 8ad2e7ef
      Takashi Iwai authored
      commit 358040e3
      
       upstream.
      
      The update of rate_num/den and msbits were factored out to
      fixup_unreferenced_params() function to be called explicitly after the
      hw_refine or hw_params procedure.  It's called from
      snd_pcm_hw_refine_user(), but it's forgotten in the PCM compat ioctl.
      This ended up with the incomplete rate_num/den and msbits parameters
      when 32bit compat ioctl is used.
      
      This patch adds the missing call in snd_pcm_ioctl_hw_params_compat().
      
      Reported-by: default avatar <Meng_Cai@novatek.com.cn>
      Fixes: f9a076bf
      
       ("ALSA: pcm: calculate non-mask/non-interval parameters always when possible")
      Reviewed-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Reviewed-by: default avatarJaroslav Kysela <perex@perex.cz>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20230829134344.31588-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8ad2e7ef
    • Boris Brezillon's avatar
      PM / devfreq: Fix leak in devfreq_dev_release() · 8918025f
      Boris Brezillon authored
      commit 5693d077 upstream.
      
      srcu_init_notifier_head() allocates resources that need to be released
      with a srcu_cleanup_notifier_head() call.
      
      Reported by kmemleak.
      
      Fixes: 0fe3a664
      
       ("PM / devfreq: Add new DEVFREQ_TRANSITION_NOTIFIER notifier")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
      Reviewed-by: default avatarDhruva Gole <d-gole@ti.com>
      Signed-off-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8918025f
    • Radoslaw Tyl's avatar
      igb: set max size RX buffer when store bad packet is enabled · d2e906c7
      Radoslaw Tyl authored
      commit bb5ed01c upstream.
      
      Increase the RX buffer size to 3K when the SBP bit is on. The size of
      the RX buffer determines the number of pages allocated which may not
      be sufficient for receive frames larger than the set MTU size.
      
      Cc: stable@vger.kernel.org
      Fixes: 89eaefb6
      
       ("igb: Support RX-ALL feature flag.")
      Reported-by: default avatarManfred Rudigier <manfred.rudigier@omicronenergy.com>
      Signed-off-by: default avatarRadoslaw Tyl <radoslawx.tyl@intel.com>
      Tested-by: Arpana Arland <arpanax.arland@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d2e906c7
    • Mohamed Khalfella's avatar
      skbuff: skb_segment, Call zero copy functions before using skbuff frags · 04c3eee4
      Mohamed Khalfella authored
      commit 2ea35288 upstream.
      
      Commit bf5c25d6 ("skbuff: in skb_segment, call zerocopy functions
      once per nskb") added the call to zero copy functions in skb_segment().
      The change introduced a bug in skb_segment() because skb_orphan_frags()
      may possibly change the number of fragments or allocate new fragments
      altogether leaving nrfrags and frag to point to the old values. This can
      cause a panic with stacktrace like the one below.
      
      [  193.894380] BUG: kernel NULL pointer dereference, address: 00000000000000bc
      [  193.895273] CPU: 13 PID: 18164 Comm: vh-net-17428 Kdump: loaded Tainted: G           O      5.15.123+ #26
      [  193.903919] RIP: 0010:skb_segment+0xb0e/0x12f0
      [  194.021892] Call Trace:
      [  194.027422]  <TASK>
      [  194.072861]  tcp_gso_segment+0x107/0x540
      [  194.082031]  inet_gso_segment+0x15c/0x3d0
      [  194.090783]  skb_mac_gso_segment+0x9f/0x110
      [  194.095016]  __skb_gso_segment+0xc1/0x190
      [  194.103131]  netem_enqueue+0x290/0xb10 [sch_netem]
      [  194.107071]  dev_qdisc_enqueue+0x16/0x70
      [  194.110884]  __dev_queue_xmit+0x63b/0xb30
      [  194.121670]  bond_start_xmit+0x159/0x380 [bonding]
      [  194.128506]  dev_hard_start_xmit+0xc3/0x1e0
      [  194.131787]  __dev_queue_xmit+0x8a0/0xb30
      [  194.138225]  macvlan_start_xmit+0x4f/0x100 [macvlan]
      [  194.141477]  dev_hard_start_xmit+0xc3/0x1e0
      [  194.144622]  sch_direct_xmit+0xe3/0x280
      [  194.147748]  __dev_queue_xmit+0x54a/0xb30
      [  194.154131]  tap_get_user+0x2a8/0x9c0 [tap]
      [  194.157358]  tap_sendmsg+0x52/0x8e0 [tap]
      [  194.167049]  handle_tx_zerocopy+0x14e/0x4c0 [vhost_net]
      [  194.173631]  handle_tx+0xcd/0xe0 [vhost_net]
      [  194.176959]  vhost_worker+0x76/0xb0 [vhost]
      [  194.183667]  kthread+0x118/0x140
      [  194.190358]  ret_from_fork+0x1f/0x30
      [  194.193670]  </TASK>
      
      In this case calling skb_orphan_frags() updated nr_frags leaving nrfrags
      local variable in skb_segment() stale. This resulted in the code hitting
      i >= nrfrags prematurely and trying to move to next frag_skb using
      list_skb pointer, which was NULL, and caused kernel panic. Move the call
      to zero copy functions before using frags and nr_frags.
      
      Fixes: bf5c25d6
      
       ("skbuff: in skb_segment, call zerocopy functions once per nskb")
      Signed-off-by: default avatarMohamed Khalfella <mkhalfella@purestorage.com>
      Reported-by: default avatarAmit Goyal <agoyal@purestorage.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      04c3eee4
    • Wander Lairson Costa's avatar
      netfilter: xt_sctp: validate the flag_info count · 4921f934
      Wander Lairson Costa authored
      commit e9947649 upstream.
      
      sctp_mt_check doesn't validate the flag_count field. An attacker can
      take advantage of that to trigger a OOB read and leak memory
      information.
      
      Add the field validation in the checkentry function.
      
      Fixes: 2e4e6a17
      
       ("[NETFILTER] x_tables: Abstraction layer for {ip,ip6,arp}_tables")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarLucas Leong <wmliang@infosec.exchange>
      Signed-off-by: default avatarWander Lairson Costa <wander@redhat.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4921f934
    • Wander Lairson Costa's avatar
      netfilter: xt_u32: validate user space input · 1c164c1e
      Wander Lairson Costa authored
      commit 69c5d284 upstream.
      
      The xt_u32 module doesn't validate the fields in the xt_u32 structure.
      An attacker may take advantage of this to trigger an OOB read by setting
      the size fields with a value beyond the arrays boundaries.
      
      Add a checkentry function to validate the structure.
      
      This was originally reported by the ZDI project (ZDI-CAN-18408).
      
      Fixes: 1b50b8a3
      
       ("[NETFILTER]: Add u32 match")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarWander Lairson Costa <wander@redhat.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1c164c1e
    • Xiao Liang's avatar
      netfilter: nft_exthdr: Fix non-linear header modification · bcdb4a5c
      Xiao Liang authored
      commit 28427f36 upstream.
      
      Fix skb_ensure_writable() size. Don't use nft_tcp_header_pointer() to
      make it explicit that pointers point to the packet (not local buffer).
      
      Fixes: 99d1712b ("netfilter: exthdr: tcp option set support")
      Fixes: 7890cbea
      
       ("netfilter: exthdr: add support for tcp option removal")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarXiao Liang <shaw.leon@gmail.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bcdb4a5c
    • Kyle Zeng's avatar
      netfilter: ipset: add the missing IP_SET_HASH_WITH_NET0 macro for ip_set_hash_netportnet.c · 7ca0706c
      Kyle Zeng authored
      commit 050d91c0 upstream.
      
      The missing IP_SET_HASH_WITH_NET0 macro in ip_set_hash_netportnet can
      lead to the use of wrong `CIDR_POS(c)` for calculating array offsets,
      which can lead to integer underflow. As a result, it leads to slab
      out-of-bound access.
      This patch adds back the IP_SET_HASH_WITH_NET0 macro to
      ip_set_hash_netportnet to address the issue.
      
      Fixes: 886503f3
      
       ("netfilter: ipset: actually allow allowable CIDR 0 in hash:net,port,net")
      Suggested-by: default avatarJozsef Kadlecsik <kadlec@netfilter.org>
      Signed-off-by: default avatarKyle Zeng <zengyhkyle@gmail.com>
      Acked-by: default avatarJozsef Kadlecsik <kadlec@netfilter.org>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7ca0706c
    • Eric Dumazet's avatar
      igmp: limit igmpv3_newpack() packet size to IP_MAX_MTU · 6678912b
      Eric Dumazet authored
      commit c3b704d4 upstream.
      
      This is a follow up of commit 915d975b ("net: deal with integer
      overflows in kmalloc_reserve()") based on David Laight feedback.
      
      Back in 2010, I failed to realize malicious users could set dev->mtu
      to arbitrary values. This mtu has been since limited to 0x7fffffff but
      regardless of how big dev->mtu is, it makes no sense for igmpv3_newpack()
      to allocate more than IP_MAX_MTU and risk various skb fields overflows.
      
      Fixes: 57e1ab6e
      
       ("igmp: refine skb allocations")
      Link: https://lore.kernel.org/netdev/d273628df80f45428e739274ab9ecb72@AcuMS.aculab.com/
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarDavid Laight <David.Laight@ACULAB.COM>
      Cc: Kyle Zeng <zengyhkyle@gmail.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6678912b
    • Yuan Yao's avatar
      virtio_ring: fix avail_wrap_counter in virtqueue_add_packed · ad8900dd
      Yuan Yao authored
      [ Upstream commit 1acfe2c1 ]
      
      In current packed virtqueue implementation, the avail_wrap_counter won't
      flip, in the case when the driver supplies a descriptor chain with a
      length equals to the queue size; total_sg == vq->packed.vring.num.
      
      Let’s assume the following situation:
      vq->packed.vring.num=4
      vq->packed.next_avail_idx: 1
      vq->packed.avail_wrap_counter: 0
      
      Then the driver adds a descriptor chain containing 4 descriptors.
      
      We expect the following result with avail_wrap_counter flipped:
      vq->packed.next_avail_idx: 1
      vq->packed.avail_wrap_counter: 1
      
      But, the current implementation gives the following result:
      vq->packed.next_avail_idx: 1
      vq->packed.avail_wrap_counter: 0
      
      To reproduce the bug, you can set a packed queue size as small as
      possible, so that the driver is more likely to provide a descriptor
      chain with a length equal to the packed queue size. For example, in
      qemu run following commands:
      sudo qemu-system-x86_64 \
      -enable-kvm \
      -nographic \
      -kernel "path/to/kernel_image" \
      -m 1G \
      -drive file="path/to/rootfs",if=none,id=disk \
      -device virtio-blk,drive=disk \
      -drive file="path/to/disk_image",if=none,id=rwdisk \
      -device virtio-blk,drive=rwdisk,packed=on,queue-size=4,\
      indirect_desc=off \
      -append "console=ttyS0 root=/dev/vda rw init=/bin/bash"
      
      Inside the VM, create a directory and mount the rwdisk device on it. The
      rwdisk will hang and mount operation will not complete.
      
      This commit fixes the wrap counter error by flipping the
      packed.avail_wrap_counter, when start of descriptor chain equals to the
      end of descriptor chain (head == i).
      
      Fixes: 1ce9e605
      
       ("virtio_ring: introduce packed ring support")
      Signed-off-by: default avatarYuan Yao <yuanyaogoog@chromium.org>
      Message-Id: <20230808051110.3492693-1-yuanyaogoog@chromium.org>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ad8900dd
    • Liao Chang's avatar
      cpufreq: Fix the race condition while updating the transition_task of policy · 4927edc2
      Liao Chang authored
      [ Upstream commit 61bfbf79 ]
      
      The field 'transition_task' of policy structure is used to track the
      task which is performing the frequency transition. Using this field to
      print a warning once detect a case where the same task is calling
      _begin() again before completing the preivous frequency transition via
      the _end().
      
      However, there is a potential race condition in _end() and _begin() APIs
      while updating the field 'transition_task' of policy, the scenario is
      depicted below:
      
                   Task A                            Task B
      
              /* 1st freq transition */
              Invoke _begin() {
                      ...
                      ...
              }
                                              /* 2nd freq transition */
                                              Invoke _begin() {
                                                      ... //waiting for A to
                                                      ... //clear
                                                      ... //transition_ongoing
                                                      ... //in _end() for
                                                      ... //the 1st transition
                                                              |
              Change the frequency                            |
                                                              |
              Invoke _end() {                                 |
                      ...                                     |
                      ...                                     |
                      transition_ongoing = false;             V
                                                      transition_ongoing = true;
                                                      transition_task = current;
                      transition_task = NULL;
                      ... //A overwrites the task
                      ... //performing the transition
                      ... //result in error warning.
              }
      
      To fix this race condition, the transition_lock of policy structure is
      now acquired before updating policy structure in _end() API. Which ensure
      that only one task can update the 'transition_task' field at a time.
      
      Link: https://lore.kernel.org/all/b3c61d8a-d52d-3136-fbf0-d1de9f1ba411@huawei.com/
      Fixes: ca654dc3
      
       ("cpufreq: Catch double invocations of cpufreq_freq_transition_begin/end")
      Signed-off-by: default avatarLiao Chang <liaochang1@huawei.com>
      Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4927edc2
    • Maciej S. Szmigiero's avatar
      Drivers: hv: vmbus: Don't dereference ACPI root object handle · 96db43ac
      Maciej S. Szmigiero authored
      [ Upstream commit 78e04bbf ]
      
      Since the commit referenced in the Fixes: tag below the VMBus client driver
      is walking the ACPI namespace up from the VMBus ACPI device to the ACPI
      namespace root object trying to find Hyper-V MMIO ranges.
      
      However, if it is not able to find them it ends trying to walk resources of
      the ACPI namespace root object itself.
      This object has all-ones handle, which causes a NULL pointer dereference
      in the ACPI code (from dereferencing this pointer with an offset).
      
      This in turn causes an oops on boot with VMBus host implementations that do
      not provide Hyper-V MMIO ranges in their VMBus ACPI device or its
      ancestors.
      The QEMU VMBus implementation is an example of such implementation.
      
      I guess providing these ranges is optional, since all tested Windows
      versions seem to be able to use VMBus devices without them.
      
      Fix this by explicitly terminating the lookup at the ACPI namespace root
      object.
      
      Note that Linux guests under KVM/QEMU do not use the Hyper-V PV interface
      by default - they only do so if the KVM PV interface is missing or
      disabled.
      
      Example stack trace of such oops:
      [ 3.710827] ? __die+0x1f/0x60
      [ 3.715030] ? page_fault_oops+0x159/0x460
      [ 3.716008] ? exc_page_fault+0x73/0x170
      [ 3.716959] ? asm_exc_page_fault+0x22/0x30
      [ 3.717957] ? acpi_ns_lookup+0x7a/0x4b0
      [ 3.718898] ? acpi_ns_internalize_name+0x79/0xc0
      [ 3.720018] acpi_ns_get_node_unlocked+0xb5/0xe0
      [ 3.721120] ? acpi_ns_check_object_type+0xfe/0x200
      [ 3.722285] ? acpi_rs_convert_aml_to_resource+0x37/0x6e0
      [ 3.723559] ? down_timeout+0x3a/0x60
      [ 3.724455] ? acpi_ns_get_node+0x3a/0x60
      [ 3.725412] acpi_ns_get_node+0x3a/0x60
      [ 3.726335] acpi_ns_evaluate+0x1c3/0x2c0
      [ 3.727295] acpi_ut_evaluate_object+0x64/0x1b0
      [ 3.728400] acpi_rs_get_method_data+0x2b/0x70
      [ 3.729476] ? vmbus_platform_driver_probe+0x1d0/0x1d0 [hv_vmbus]
      [ 3.730940] ? vmbus_platform_driver_probe+0x1d0/0x1d0 [hv_vmbus]
      [ 3.732411] acpi_walk_resources+0x78/0xd0
      [ 3.733398] vmbus_platform_driver_probe+0x9f/0x1d0 [hv_vmbus]
      [ 3.734802] platform_probe+0x3d/0x90
      [ 3.735684] really_probe+0x19b/0x400
      [ 3.736570] ? __device_attach_driver+0x100/0x100
      [ 3.737697] __driver_probe_device+0x78/0x160
      [ 3.738746] driver_probe_device+0x1f/0x90
      [ 3.739743] __driver_attach+0xc2/0x1b0
      [ 3.740671] bus_for_each_dev+0x70/0xc0
      [ 3.741601] bus_add_driver+0x10e/0x210
      [ 3.742527] driver_register+0x55/0xf0
      [ 3.744412] ? 0xffffffffc039a000
      [ 3.745207] hv_acpi_init+0x3c/0x1000 [hv_vmbus]
      
      Fixes: 7f163a6f
      
       ("drivers:hv: Modify hv_vmbus to search for all MMIO ranges available.")
      Signed-off-by: default avatarMaciej S. Szmigiero <maciej.szmigiero@oracle.com>
      Reviewed-by: default avatarMichael Kelley <mikelley@microsoft.com>
      Signed-off-by: default avatarWei Liu <wei.liu@kernel.org>
      Link: https://lore.kernel.org/r/fd8e64ceeecfd1d95ff49021080cf699e88dbbde.1691606267.git.maciej.szmigiero@oracle.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      96db43ac
    • ruanjinjie's avatar
      dmaengine: ste_dma40: Add missing IRQ check in d40_probe · e351933e
      ruanjinjie authored
      [ Upstream commit c05ce690 ]
      
      Check for the return value of platform_get_irq(): if no interrupt
      is specified, it wouldn't make sense to call request_irq().
      
      Fixes: 8d318a50
      
       ("DMAENGINE: Support for ST-Ericssons DMA40 block v3")
      Signed-off-by: default avatarRuan Jinjie <ruanjinjie@huawei.com>
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Link: https://lore.kernel.org/r/20230724144108.2582917-1-ruanjinjie@huawei.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e351933e
    • Randy Dunlap's avatar
      um: Fix hostaudio build errors · 43a57ca7
      Randy Dunlap authored
      [ Upstream commit db4bfcba ]
      
      Use "select" to ensure that the required kconfig symbols are set
      as expected.
      Drop HOSTAUDIO since it is now equivalent to UML_SOUND.
      
      Set CONFIG_SOUND=m in ARCH=um defconfig files to maintain the
      status quo of the default configs.
      
      Allow SOUND with UML regardless of HAS_IOMEM. Otherwise there is a
      kconfig warning for unmet dependencies. (This was not an issue when
      SOUND was defined in arch/um/drivers/Kconfig. I have done 50 randconfig
      builds and didn't find any issues.)
      
      This fixes build errors when CONFIG_SOUND is not set:
      
      ld: arch/um/drivers/hostaudio_kern.o: in function `hostaudio_cleanup_module':
      hostaudio_kern.c:(.exit.text+0xa): undefined reference to `unregister_sound_mixer'
      ld: hostaudio_kern.c:(.exit.text+0x15): undefined reference to `unregister_sound_dsp'
      ld: arch/um/drivers/hostaudio_kern.o: in function `hostaudio_init_module':
      hostaudio_kern.c:(.init.text+0x19): undefined reference to `register_sound_dsp'
      ld: hostaudio_kern.c:(.init.text+0x31): undefined reference to `register_sound_mixer'
      ld: hostaudio_kern.c:(.init.text+0x49): undefined reference to `unregister_sound_dsp'
      
      and this kconfig warning:
      WARNING: unmet direct dependencies detected for SOUND
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Fixes: d886e87c
      
       ("sound: make OSS sound core optional")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Closes: lore.kernel.org/r/202307141416.vxuRVpFv-lkp@intel.com
      Cc: Richard Weinberger <richard@nod.at>
      Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
      Cc: Johannes Berg <johannes@sipsolutions.net>
      Cc: linux-um@lists.infradead.org
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Takashi Iwai <tiwai@suse.de>
      Cc: Jaroslav Kysela <perex@perex.cz>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Nicolas Schier <nicolas@fjasle.eu>
      Cc: linux-kbuild@vger.kernel.org
      Cc: alsa-devel@alsa-project.org
      Reviewed-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      43a57ca7
    • Yi Yang's avatar
      mtd: rawnand: fsmc: handle clk prepare error in fsmc_nand_resume() · 222b85e7
      Yi Yang authored
      [ Upstream commit a5a88125 ]
      
      In fsmc_nand_resume(), the return value of clk_prepare_enable() should be
      checked since it might fail.
      
      Fixes: e25da1c0
      
       ("mtd: fsmc_nand: Add clk_{un}prepare() support")
      Signed-off-by: default avatarYi Yang <yiyang13@huawei.com>
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Link: https://lore.kernel.org/linux-mtd/20230817115839.10192-1-yiyang13@huawei.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      222b85e7
    • Hsin-Yi Wang's avatar
      mtd: spi-nor: Check bus width while setting QE bit · eaf4c789
      Hsin-Yi Wang authored
      [ Upstream commit f01d8155 ]
      
      spi_nor_write_16bit_sr_and_check() should also check if bus width is
      4 before setting QE bit.
      
      Fixes: 39d1e334
      
       ("mtd: spi-nor: Fix clearing of QE bit on lock()/unlock()")
      Suggested-by: default avatarMichael Walle <michael@walle.cc>
      Suggested-by: default avatarTudor Ambarus <tudor.ambarus@linaro.org>
      Signed-off-by: default avatarHsin-Yi Wang <hsinyi@chromium.org>
      Reviewed-by: default avatarMichael Walle <michael@walle.cc>
      Link: https://lore.kernel.org/r/20230818064524.1229100-2-hsinyi@chromium.org
      Signed-off-by: default avatarTudor Ambarus <tudor.ambarus@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      eaf4c789
    • Marek Behún's avatar
      leds: trigger: tty: Do not use LED_ON/OFF constants, use led_blink_set_oneshot instead · 3e313b6c
      Marek Behún authored
      [ Upstream commit 73009457 ]
      
      The tty LED trigger uses the obsolete LED_ON & LED_OFF constants when
      setting LED brightness. This is bad because the LED_ON constant is equal
      to 1, and so when activating the tty LED trigger on a LED class device
      with max_brightness greater than 1, the LED is dimmer than it can be
      (when max_brightness is 255, the LED is very dimm indeed; some devices
      translate 1/255 to 0, so the LED is OFF all the time).
      
      Instead of directly setting brightness to a specific value, use the
      led_blink_set_oneshot() function from LED core to configure the blink.
      This function takes the current configured brightness as blink
      brightness if not zero, and max brightness otherwise.
      
      This also changes the behavior of the TTY LED trigger. Previously if
      rx/tx stats kept changing, the LED was ON all the time they kept
      changing. With this patch the LED will blink on TTY activity.
      
      Fixes: fd4a641a
      
       ("leds: trigger: implement a tty trigger")
      Signed-off-by: default avatarMarek Behún <kabel@kernel.org>
      Link: https://lore.kernel.org/r/20230802090753.13611-1-kabel@kernel.org
      Signed-off-by: default avatarLee Jones <lee@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3e313b6c
    • Marek Behún's avatar
      leds: Fix BUG_ON check for LED_COLOR_ID_MULTI that is always false · f741121a
      Marek Behún authored
      [ Upstream commit c3f85318 ]
      
      At the time we call
          BUG_ON(props.color == LED_COLOR_ID_MULTI);
      the props variable is still initialized to zero.
      
      Call the BUG_ON only after we parse fwnode into props.
      
      Fixes: 77dce3a2
      
       ("leds: disallow /sys/class/leds/*:multi:* for now")
      Signed-off-by: default avatarMarek Behún <kabel@kernel.org>
      Link: https://lore.kernel.org/r/20230801151623.30387-1-kabel@kernel.org
      Signed-off-by: default avatarLee Jones <lee@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f741121a
    • Marek Behún's avatar
      leds: multicolor: Use rounded division when calculating color components · a253c416
      Marek Behún authored
      [ Upstream commit 065d099f ]
      
      Given channel intensity, LED brightness and max LED brightness, the
      multicolor LED framework helper led_mc_calc_color_components() computes
      the color channel brightness as
      
          chan_brightness = brightness * chan_intensity / max_brightness
      
      Consider the situation when (brightness, intensity, max_brightness) is
      for example (16, 15, 255), then chan_brightness is computed to 0
      although the fractional divison would give 0.94, which should be rounded
      to 1.
      
      Use DIV_ROUND_CLOSEST here for the division to give more realistic
      component computation:
      
          chan_brightness = DIV_ROUND_CLOSEST(brightness * chan_intensity,
                                              max_brightness)
      
      Fixes: 55d5d3b4
      
       ("leds: multicolor: Introduce a multicolor class definition")
      Signed-off-by: default avatarMarek Behún <kabel@kernel.org>
      Link: https://lore.kernel.org/r/20230801124931.8661-1-kabel@kernel.org
      Signed-off-by: default avatarLee Jones <lee@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a253c416
    • Dan Carpenter's avatar
      leds: pwm: Fix error code in led_pwm_create_fwnode() · 2804cc35
      Dan Carpenter authored
      [ Upstream commit cadb2de2 ]
      
      Negative -EINVAL was intended, not positive EINVAL.  Fix it.
      
      Fixes: 95138e01
      
       ("leds: pwm: Make error handling more robust")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
      Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
      Link: https://lore.kernel.org/r/a33b981a-b2c4-4dc2-b00a-626a090d2f11@moroto.mountain
      Signed-off-by: default avatarLee Jones <lee@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2804cc35
    • 蒋家盛's avatar
      rpmsg: glink: Add check for kstrdup · cae0787e
      蒋家盛 authored
      [ Upstream commit b5c9ee82 ]
      
      Add check for the return value of kstrdup() and return the error
      if it fails in order to avoid NULL pointer dereference.
      
      Fixes: b4f8e52b
      
       ("rpmsg: Introduce Qualcomm RPM glink driver")
      Signed-off-by: default avatarJiasheng Jiang <jiasheng@iscas.ac.cn>
      Link: https://lore.kernel.org/r/20230619030631.12361-1-jiasheng@iscas.ac.cn
      Signed-off-by: default avatarBjorn Andersson <andersson@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cae0787e
    • Jonas Karlman's avatar
      phy/rockchip: inno-hdmi: do not power on rk3328 post pll on reg write · f309ac8a
      Jonas Karlman authored
      [ Upstream commit 19a1d46b ]
      
      inno_write is used to configure 0xaa reg, that also hold the
      POST_PLL_POWER_DOWN bit.
      When POST_PLL_REFCLK_SEL_TMDS is configured the power down bit is not
      taken into consideration.
      
      Fix this by keeping the power down bit until configuration is complete.
      Also reorder the reg write order for consistency.
      
      Fixes: 53706a11
      
       ("phy: add Rockchip Innosilicon hdmi phy")
      Signed-off-by: default avatarJonas Karlman <jonas@kwiboo.se>
      Link: https://lore.kernel.org/r/20230615171005.2251032-5-jonas@kwiboo.se
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f309ac8a
    • Zheng Yang's avatar
      phy/rockchip: inno-hdmi: round fractal pixclock in rk3328 recalc_rate · 8f0f5452
      Zheng Yang authored
      [ Upstream commit d5ef343c ]
      
      inno_hdmi_phy_rk3328_clk_recalc_rate() is returning a rate not found
      in the pre pll config table when the fractal divider is used.
      This can prevent proper power_on because a tmdsclock for the new rate
      is not found in the pre pll config table.
      
      Fix this by saving and returning a rounded pixel rate that exist
      in the pre pll config table.
      
      Fixes: 53706a11
      
       ("phy: add Rockchip Innosilicon hdmi phy")
      Signed-off-by: default avatarZheng Yang <zhengyang@rock-chips.com>
      Signed-off-by: default avatarJonas Karlman <jonas@kwiboo.se>
      Link: https://lore.kernel.org/r/20230615171005.2251032-3-jonas@kwiboo.se
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8f0f5452
    • Jonas Karlman's avatar
      phy/rockchip: inno-hdmi: use correct vco_div_5 macro on rk3328 · 0d86292e
      Jonas Karlman authored
      [ Upstream commit 644c06df ]
      
      inno_hdmi_phy_rk3328_clk_set_rate() is using the RK3228 macro
      when configuring vco_div_5 on RK3328.
      
      Fix this by using correct vco_div_5 macro for RK3328.
      
      Fixes: 53706a11
      
       ("phy: add Rockchip Innosilicon hdmi phy")
      Signed-off-by: default avatarJonas Karlman <jonas@kwiboo.se>
      Link: https://lore.kernel.org/r/20230615171005.2251032-2-jonas@kwiboo.se
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0d86292e
    • Rex Zhang's avatar
      dmaengine: idxd: Modify the dependence of attribute pasid_enabled · 50fa0124
      Rex Zhang authored
      [ Upstream commit 50c5e6f4 ]
      
      Kernel PASID and user PASID are separately enabled. User needs to know the
      user PASID enabling status to decide how to use IDXD device in user space.
      This is done via the attribute /sys/bus/dsa/devices/dsa0/pasid_enabled.
      It's unnecessary for user to know the kernel PASID enabling status because
      user won't use the kernel PASID. But instead of showing the user PASID
      enabling status, the attribute shows the kernel PASID enabling status. Fix
      the issue by showing the user PASID enabling status in the attribute.
      
      Fixes: 42a1b738
      
       ("dmaengine: idxd: Separate user and kernel pasid enabling")
      Signed-off-by: default avatarRex Zhang <rex.zhang@intel.com>
      Acked-by: default avatarFenghua Yu <fenghua.yu@intel.com>
      Acked-by: default avatarDave Jiang <dave.jiang@intel.com>
      Link: https://lore.kernel.org/r/20230614062706.1743078-1-rex.zhang@intel.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      50fa0124
    • William Zhang's avatar
      mtd: rawnand: brcmnand: Fix mtd oobsize · 6453a2fb
      William Zhang authored
      [ Upstream commit 60177390 ]
      
      brcmnand controller can only access the flash spare area up to certain
      bytes based on the ECC level. It can be less than the actual flash spare
      area size. For example, for many NAND chip supporting ECC BCH-8, it has
      226 bytes spare area. But controller can only uses 218 bytes. So brcmand
      driver overrides the mtd oobsize with the controller's accessible spare
      area size. When the nand base driver utilizes the nand_device object, it
      resets the oobsize back to the actual flash spare aprea size from
      nand_memory_organization structure and controller may not able to access
      all the oob area as mtd advises.
      
      This change fixes the issue by overriding the oobsize in the
      nand_memory_organization structure to the controller's accessible spare
      area size.
      
      Fixes: a7ab085d
      
       ("mtd: rawnand: Initialize the nand_device object")
      Signed-off-by: default avatarWilliam Zhang <william.zhang@broadcom.com>
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Link: https://lore.kernel.org/linux-mtd/20230706182909.79151-6-william.zhang@broadcom.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6453a2fb
    • Zheng Yejian's avatar
      tracing: Fix race issue between cpu buffer write and swap · 74c85396
      Zheng Yejian authored
      [ Upstream commit 3163f635 ]
      
      Warning happened in rb_end_commit() at code:
      	if (RB_WARN_ON(cpu_buffer, !local_read(&cpu_buffer->committing)))
      
        WARNING: CPU: 0 PID: 139 at kernel/trace/ring_buffer.c:3142
      	rb_commit+0x402/0x4a0
        Call Trace:
         ring_buffer_unlock_commit+0x42/0x250
         trace_buffer_unlock_commit_regs+0x3b/0x250
         trace_event_buffer_commit+0xe5/0x440
         trace_event_buffer_reserve+0x11c/0x150
         trace_event_raw_event_sched_switch+0x23c/0x2c0
         __traceiter_sched_switch+0x59/0x80
         __schedule+0x72b/0x1580
         schedule+0x92/0x120
         worker_thread+0xa0/0x6f0
      
      It is because the race between writing event into cpu buffer and swapping
      cpu buffer through file per_cpu/cpu0/snapshot:
      
        Write on CPU 0             Swap buffer by per_cpu/cpu0/snapshot on CPU 1
        --------                   --------
                                   tracing_snapshot_write()
                                     [...]
      
        ring_buffer_lock_reserve()
          cpu_buffer = buffer->buffers[cpu]; // 1. Suppose find 'cpu_buffer_a';
          [...]
          rb_reserve_next_event()
            [...]
      
                                     ring_buffer_swap_cpu()
                                       if (local_read(&cpu_buffer_a->committing))
                                           goto out_dec;
                                       if (local_read(&cpu_buffer_b->committing))
                                           goto out_dec;
                                       buffer_a->buffers[cpu] = cpu_buffer_b;
                                       buffer_b->buffers[cpu] = cpu_buffer_a;
                                       // 2. cpu_buffer has swapped here.
      
            rb_start_commit(cpu_buffer);
            if (unlikely(READ_ONCE(cpu_buffer->buffer)
                != buffer)) { // 3. This check passed due to 'cpu_buffer->buffer'
              [...]           //    has not changed here.
              return NULL;
            }
                                       cpu_buffer_b->buffer = buffer_a;
                                       cpu_buffer_a->buffer = buffer_b;
                                       [...]
      
            // 4. Reserve event from 'cpu_buffer_a'.
      
        ring_buffer_unlock_commit()
          [...]
          cpu_buffer = buffer->buffers[cpu]; // 5. Now find 'cpu_buffer_b' !!!
          rb_commit(cpu_buffer)
            rb_end_commit()  // 6. WARN for the wrong 'committing' state !!!
      
      Based on above analysis, we can easily reproduce by following testcase:
        ``` bash
        #!/bin/bash
      
        dmesg -n 7
        sysctl -w kernel.panic_on_warn=1
        TR=/sys/kernel/tracing
        echo 7 > ${TR}/buffer_size_kb
        echo "sched:sched_switch" > ${TR}/set_event
        while [ true ]; do
                echo 1 > ${TR}/per_cpu/cpu0/snapshot
        done &
        while [ true ]; do
                echo 1 > ${TR}/per_cpu/cpu0/snapshot
        done &
        while [ true ]; do
                echo 1 > ${TR}/per_cpu/cpu0/snapshot
        done &
        ```
      
      To fix it, IIUC, we can use smp_call_function_single() to do the swap on
      the target cpu where the buffer is located, so that above race would be
      avoided.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20230831132739.4070878-1-zhengyejian1@huawei.com
      
      Cc: <mhiramat@kernel.org>
      Fixes: f1affcaa
      
       ("tracing: Add snapshot in the per_cpu trace directories")
      Signed-off-by: default avatarZheng Yejian <zhengyejian1@huawei.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      74c85396
    • Mikhail Kobuk's avatar
      tracing: Remove extra space at the end of hwlat_detector/mode · fb34716c
      Mikhail Kobuk authored
      [ Upstream commit 2cf0dee9 ]
      
      Space is printed after each mode value including the last one:
      $ echo \"$(sudo cat /sys/kernel/tracing/hwlat_detector/mode)\"
      "none [round-robin] per-cpu "
      
      Found by Linux Verification Center (linuxtesting.org) with SVACE.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20230825103432.7750-1-m.kobuk@ispras.ru
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Fixes: 8fa826b7
      
       ("trace/hwlat: Implement the mode config option")
      Signed-off-by: default avatarMikhail Kobuk <m.kobuk@ispras.ru>
      Reviewed-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
      Acked-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fb34716c
    • Dave Hansen's avatar
      x86/speculation: Mark all Skylake CPUs as vulnerable to GDS · ca5e8427
      Dave Hansen authored
      [ Upstream commit c9f4c45c
      
       ]
      
      The Gather Data Sampling (GDS) vulnerability is common to all Skylake
      processors.  However, the "client" Skylakes* are now in this list:
      
      	https://www.intel.com/content/www/us/en/support/articles/000022396/processors.html
      
      which means they are no longer included for new vulnerabilities here:
      
      	https://www.intel.com/content/www/us/en/developer/topic-technology/software-security-guidance/processors-affected-consolidated-product-cpu-model.html
      
      or in other GDS documentation.  Thus, they were not included in the
      original GDS mitigation patches.
      
      Mark SKYLAKE and SKYLAKE_L as vulnerable to GDS to match all the
      other Skylake CPUs (which include Kaby Lake).  Also group the CPUs
      so that the ones that share the exact same vulnerabilities are next
      to each other.
      
      Last, move SRBDS to the end of each line.  This makes it clear at a
      glance that SKYLAKE_X is unique.  Of the five Skylakes, it is the
      only "server" CPU and has a different implementation from the
      clients of the "special register" hardware, making it immune to SRBDS.
      
      This makes the diff much harder to read, but the resulting table is
      worth it.
      
      I very much appreciate the report from Michael Zhivich about this
      issue.  Despite what level of support a hardware vendor is providing,
      the kernel very much needs an accurate and up-to-date list of
      vulnerable CPUs.  More reports like this are very welcome.
      
      * Client Skylakes are CPUID 406E3/506E3 which is family 6, models
        0x4E and 0x5E, aka INTEL_FAM6_SKYLAKE and INTEL_FAM6_SKYLAKE_L.
      
      Reported-by: default avatarMichael Zhivich <mzhivich@akamai.com>
      Fixes: 8974eb58
      
       ("x86/speculation: Add Gather Data Sampling mitigation")
      Signed-off-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Reviewed-by: default avatarDaniel Sneddon <daniel.sneddon@linux.intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ca5e8427