Skip to content
  1. Jul 12, 2022
    • Miaoqian Lin's avatar
      ARM: meson: Fix refcount leak in meson_smp_prepare_cpus · 2e1bcd33
      Miaoqian Lin authored
      [ Upstream commit 34d2cd3f ]
      
      of_find_compatible_node() returns a node pointer with refcount
      incremented, we should use of_node_put() on it when done.
      Add missing of_node_put() to avoid refcount leak.
      
      Fixes: d850f3e5
      
       ("ARM: meson: Add SMP bringup code for Meson8 and Meson8b")
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Reviewed-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Signed-off-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
      Link: https://lore.kernel.org/r/20220512021611.47921-1-linmq006@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2e1bcd33
    • Eric Sandeen's avatar
      xfs: remove incorrect ASSERT in xfs_rename · 18aef352
      Eric Sandeen authored
      commit e4459765
      
       upstream.
      
      This ASSERT in xfs_rename is a) incorrect, because
      (RENAME_WHITEOUT|RENAME_NOREPLACE) is a valid combination, and
      b) unnecessary, because actual invalid flag combinations are already
      handled at the vfs level in do_renameat2() before we get called.
      So, remove it.
      
      Reported-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
      Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Fixes: 7dcf5c3e
      
       ("xfs: add RENAME_WHITEOUT support")
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Acked-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      18aef352
    • Jimmy Assarsson's avatar
      can: kvaser_usb: kvaser_usb_leaf: fix bittiming limits · b62a5e19
      Jimmy Assarsson authored
      commit b3b6df2c upstream.
      
      Use correct bittiming limits depending on device. For devices based on
      USBcanII, Leaf M32C or Leaf i.MX28.
      
      Fixes: 080f40a6 ("can: kvaser_usb: Add support for Kvaser CAN/USB devices")
      Fixes: b4f20130 ("can: kvaser_usb: add support for Kvaser Leaf v2 and usb mini PCIe")
      Fixes: f5d4abea
      
       ("can: kvaser_usb: Add support for the USBcan-II family")
      Link: https://lore.kernel.org/all/20220603083820.800246-4-extja@kvaser.com
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJimmy Assarsson <extja@kvaser.com>
      [mkl: remove stray netlink.h include]
      [mkl: keep struct can_bittiming_const kvaser_usb_flexc_bittiming_const in kvaser_usb_hydra.c]
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b62a5e19
    • Jimmy Assarsson's avatar
      can: kvaser_usb: kvaser_usb_leaf: fix CAN clock frequency regression · 6f819737
      Jimmy Assarsson authored
      commit e6c80e60 upstream.
      
      The firmware of M32C based Leaf devices expects bittiming parameters
      calculated for 16MHz clock. Since we use the actual clock frequency of
      the device, the device may end up with wrong bittiming parameters,
      depending on user requested parameters.
      
      This regression affects M32C based Leaf devices with non-16MHz clock.
      
      Fixes: 7a09ebf0
      
       ("can: kvaser_usb: get CAN clock frequency from device")
      Link: https://lore.kernel.org/all/20220603083820.800246-3-extja@kvaser.com
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJimmy Assarsson <extja@kvaser.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6f819737
    • Jimmy Assarsson's avatar
      can: kvaser_usb: replace run-time checks with struct kvaser_usb_driver_info · 5e312134
      Jimmy Assarsson authored
      commit 49f274c7
      
       upstream.
      
      Unify and move compile-time known information into new struct
      kvaser_usb_driver_info, in favor of run-time checks.
      
      All Kvaser USBcanII supports listen-only mode and error counter
      reporting.
      
      Link: https://lore.kernel.org/all/20220603083820.800246-2-extja@kvaser.com
      Suggested-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJimmy Assarsson <extja@kvaser.com>
      [mkl: move struct kvaser_usb_driver_info into kvaser_usb_core.c]
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5e312134
    • Jason A. Donenfeld's avatar
      powerpc/powernv: delay rng platform device creation until later in boot · 8d7fb023
      Jason A. Donenfeld authored
      commit 88750282 upstream.
      
      The platform device for the rng must be created much later in boot.
      Otherwise it tries to connect to a parent that doesn't yet exist,
      resulting in this splat:
      
        [    0.000478] kobject: '(null)' ((____ptrval____)): is not initialized, yet kobject_get() is being called.
        [    0.002925] [c000000002a0fb30] [c00000000073b0bc] kobject_get+0x8c/0x100 (unreliable)
        [    0.003071] [c000000002a0fba0] [c00000000087e464] device_add+0xf4/0xb00
        [    0.003194] [c000000002a0fc80] [c000000000a7f6e4] of_device_add+0x64/0x80
        [    0.003321] [c000000002a0fcb0] [c000000000a800d0] of_platform_device_create_pdata+0xd0/0x1b0
        [    0.003476] [c000000002a0fd00] [c00000000201fa44] pnv_get_random_long_early+0x240/0x2e4
        [    0.003623] [c000000002a0fe20] [c000000002060c38] random_init+0xc0/0x214
      
      This patch fixes the issue by doing the platform device creation inside
      of machine_subsys_initcall.
      
      Fixes: f3eac426
      
       ("powerpc/powernv: wire up rng during setup_arch")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarSachin Sant <sachinp@linux.ibm.com>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Tested-by: default avatarSachin Sant <sachinp@linux.ibm.com>
      [mpe: Change "of node" to "platform device" in change log]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20220630121654.1939181-1-Jason@zx2c4.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8d7fb023
    • Hsin-Yi Wang's avatar
      video: of_display_timing.h: include errno.h · 377ca648
      Hsin-Yi Wang authored
      commit 3663a2fb upstream.
      
      If CONFIG_OF is not enabled, default of_get_display_timing() returns an
      errno, so include the header.
      
      Fixes: 422b67e0
      
       ("videomode: provide dummy inline functions for !CONFIG_OF")
      Suggested-by: default avatarStephen Boyd <swboyd@chromium.org>
      Signed-off-by: default avatarHsin-Yi Wang <hsinyi@chromium.org>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      377ca648
    • Helge Deller's avatar
      fbcon: Disallow setting font bigger than screen size · eae522ed
      Helge Deller authored
      commit 65a01e60
      
       upstream.
      
      Prevent that users set a font size which is bigger than the physical screen.
      It's unlikely this may happen (because screens are usually much larger than the
      fonts and each font char is limited to 32x32 pixels), but it may happen on
      smaller screens/LCD displays.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Reviewed-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Cc: stable@vger.kernel.org # v4.14+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eae522ed
    • Yian Chen's avatar
      iommu/vt-d: Fix PCI bus rescan device hot add · d14cb7ad
      Yian Chen authored
      commit 316f92a7 upstream.
      
      Notifier calling chain uses priority to determine the execution
      order of the notifiers or listeners registered to the chain.
      PCI bus device hot add utilizes the notification mechanism.
      
      The current code sets low priority (INT_MIN) to Intel
      dmar_pci_bus_notifier and postpones DMAR decoding after adding
      new device into IOMMU. The result is that struct device pointer
      cannot be found in DRHD search for the new device's DMAR/IOMMU.
      Subsequently, the device is put under the "catch-all" IOMMU
      instead of the correct one. This could cause system hang when
      device TLB invalidation is sent to the wrong IOMMU. Invalidation
      timeout error and hard lockup have been observed and data
      inconsistency/crush may occur as well.
      
      This patch fixes the issue by setting a positive priority(1) for
      dmar_pci_bus_notifier while the priority of IOMMU bus notifier
      uses the default value(0), therefore DMAR decoding will be in
      advance of DRHD search for a new device to find the correct IOMMU.
      
      Following is a 2-step example that triggers the bug by simulating
      PCI device hot add behavior in Intel Sapphire Rapids server.
      
      echo 1 > /sys/bus/pci/devices/0000:6a:01.0/remove
      echo 1 > /sys/bus/pci/rescan
      
      Fixes: 59ce0515
      
       ("iommu/vt-d: Update DRHD/RMRR/ATSR device scope")
      Cc: stable@vger.kernel.org # v3.15+
      Reported-by: default avatarZhang, Bernice <bernice.zhang@intel.com>
      Signed-off-by: default avatarJacob Pan <jacob.jun.pan@linux.intel.com>
      Signed-off-by: default avatarYian Chen <yian.chen@intel.com>
      Link: https://lore.kernel.org/r/20220521002115.1624069-1-yian.chen@intel.com
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d14cb7ad
    • Duoming Zhou's avatar
      net: rose: fix UAF bug caused by rose_t0timer_expiry · e426d153
      Duoming Zhou authored
      commit 148ca045 upstream.
      
      There are UAF bugs caused by rose_t0timer_expiry(). The
      root cause is that del_timer() could not stop the timer
      handler that is running and there is no synchronization.
      One of the race conditions is shown below:
      
          (thread 1)             |        (thread 2)
                                 | rose_device_event
                                 |   rose_rt_device_down
                                 |     rose_remove_neigh
      rose_t0timer_expiry        |       rose_stop_t0timer(rose_neigh)
        ...                      |         del_timer(&neigh->t0timer)
                                 |         kfree(rose_neigh) //[1]FREE
        neigh->dce_mode //[2]USE |
      
      The rose_neigh is deallocated in position [1] and use in
      position [2].
      
      The crash trace triggered by POC is like below:
      
      BUG: KASAN: use-after-free in expire_timers+0x144/0x320
      Write of size 8 at addr ffff888009b19658 by task swapper/0/0
      ...
      Call Trace:
       <IRQ>
       dump_stack_lvl+0xbf/0xee
       print_address_description+0x7b/0x440
       print_report+0x101/0x230
       ? expire_timers+0x144/0x320
       kasan_report+0xed/0x120
       ? expire_timers+0x144/0x320
       expire_timers+0x144/0x320
       __run_timers+0x3ff/0x4d0
       run_timer_softirq+0x41/0x80
       __do_softirq+0x233/0x544
       ...
      
      This patch changes rose_stop_ftimer() and rose_stop_t0timer()
      in rose_remove_neigh() to del_timer_sync() in order that the
      timer handler could be finished before the resources such as
      rose_neigh and so on are deallocated. As a result, the UAF
      bugs could be mitigated.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarDuoming Zhou <duoming@zju.edu.cn>
      Link: https://lore.kernel.org/r/20220705125610.77971-1-duoming@zju.edu.cn
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e426d153
    • Oliver Neukum's avatar
      usbnet: fix memory leak in error case · d5165e65
      Oliver Neukum authored
      commit b55a21b7 upstream.
      
      usbnet_write_cmd_async() mixed up which buffers
      need to be freed in which error case.
      
      v2: add Fixes tag
      v3: fix uninitialized buf pointer
      
      Fixes: 877bd862
      
       ("usbnet: introduce usbnet 3 command helpers")
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
      Link: https://lore.kernel.org/r/20220705125351.17309-1-oneukum@suse.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d5165e65
    • Rhett Aultman's avatar
      can: gs_usb: gs_usb_open/close(): fix memory leak · d9149263
      Rhett Aultman authored
      commit 2bda24ef upstream.
      
      The gs_usb driver appears to suffer from a malady common to many USB
      CAN adapter drivers in that it performs usb_alloc_coherent() to
      allocate a number of USB request blocks (URBs) for RX, and then later
      relies on usb_kill_anchored_urbs() to free them, but this doesn't
      actually free them. As a result, this may be leaking DMA memory that's
      been used by the driver.
      
      This commit is an adaptation of the techniques found in the esd_usb2
      driver where a similar design pattern led to a memory leak. It
      explicitly frees the RX URBs and their DMA memory via a call to
      usb_free_coherent(). Since the RX URBs were allocated in the
      gs_can_open(), we remove them in gs_can_close() rather than in the
      disconnect function as was done in esd_usb2.
      
      For more information, see the 928150fa ("can: esd_usb2: fix memory
      leak").
      
      Link: https://lore.kernel.org/all/alpine.DEB.2.22.394.2206031547001.1630869@thelappy
      Fixes: d08e973a
      
       ("can: gs_usb: Added support for the GS_USB CAN devices")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarRhett Aultman <rhett.aultman@samsara.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d9149263
    • Liang He's avatar
      can: grcan: grcan_probe(): remove extra of_node_get() · effa1894
      Liang He authored
      commit 562fed94 upstream.
      
      In grcan_probe(), of_find_node_by_path() has already increased the
      refcount. There is no need to call of_node_get() again, so remove it.
      
      Link: https://lore.kernel.org/all/20220619070257.4067022-1-windhl@126.com
      Fixes: 1e93ed26
      
       ("can: grcan: grcan_probe(): fix broken system id check for errata workaround needs")
      Cc: stable@vger.kernel.org # v5.18
      Cc: Andreas Larsson <andreas@gaisler.com>
      Signed-off-by: default avatarLiang He <windhl@126.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      effa1894
    • Oliver Hartkopp's avatar
      can: bcm: use call_rcu() instead of costly synchronize_rcu() · fbac09a3
      Oliver Hartkopp authored
      commit f1b4e32a upstream.
      
      In commit d5f9023f ("can: bcm: delay release of struct bcm_op
      after synchronize_rcu()") Thadeu Lima de Souza Cascardo introduced two
      synchronize_rcu() calls in bcm_release() (only once at socket close)
      and in bcm_delete_rx_op() (called on removal of each single bcm_op).
      
      Unfortunately this slow removal of the bcm_op's affects user space
      applications like cansniffer where the modification of a filter
      removes 2048 bcm_op's which blocks the cansniffer application for
      40(!) seconds.
      
      In commit 181d4447 ("can: gw: use call_rcu() instead of costly
      synchronize_rcu()") Eric Dumazet replaced the synchronize_rcu() calls
      with several call_rcu()'s to safely remove the data structures after
      the removal of CAN ID subscriptions with can_rx_unregister() calls.
      
      This patch adopts Erics approach for the can-bcm which should be
      applicable since the removal of tasklet_kill() in bcm_remove_op() and
      the introduction of the HRTIMER_MODE_SOFT timer handling in Linux 5.4.
      
      Fixes: d5f9023f
      
       ("can: bcm: delay release of struct bcm_op after synchronize_rcu()") # >= 5.4
      Link: https://lore.kernel.org/all/20220520183239.19111-1-socketcan@hartkopp.net
      Cc: stable@vger.kernel.org
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: Norbert Slusarek <nslusarek@gmx.net>
      Cc: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
      Signed-off-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fbac09a3
    • Jann Horn's avatar
      mm/slub: add missing TID updates on slab deactivation · e2b2f0e2
      Jann Horn authored
      commit eeaa345e upstream.
      
      The fastpath in slab_alloc_node() assumes that c->slab is stable as long as
      the TID stays the same. However, two places in __slab_alloc() currently
      don't update the TID when deactivating the CPU slab.
      
      If multiple operations race the right way, this could lead to an object
      getting lost; or, in an even more unlikely situation, it could even lead to
      an object being freed onto the wrong slab's freelist, messing up the
      `inuse` counter and eventually causing a page to be freed to the page
      allocator while it still contains slab objects.
      
      (I haven't actually tested these cases though, this is just based on
      looking at the code. Writing testcases for this stuff seems like it'd be
      a pain...)
      
      The race leading to state inconsistency is (all operations on the same CPU
      and kmem_cache):
      
       - task A: begin do_slab_free():
          - read TID
          - read pcpu freelist (==NULL)
          - check `slab == c->slab` (true)
       - [PREEMPT A->B]
       - task B: begin slab_alloc_node():
          - fastpath fails (`c->freelist` is NULL)
          - enter __slab_alloc()
          - slub_get_cpu_ptr() (disables preemption)
          - enter ___slab_alloc()
          - take local_lock_irqsave()
          - read c->freelist as NULL
          - get_freelist() returns NULL
          - write `c->slab = NULL`
          - drop local_unlock_irqrestore()
          - goto new_slab
          - slub_percpu_partial() is NULL
          - get_partial() returns NULL
          - slub_put_cpu_ptr() (enables preemption)
       - [PREEMPT B->A]
       - task A: finish do_slab_free():
          - this_cpu_cmpxchg_double() succeeds()
          - [CORRUPT STATE: c->slab==NULL, c->freelist!=NULL]
      
      From there, the object on c->freelist will get lost if task B is allowed to
      continue from here: It will proceed to the retry_load_slab label,
      set c->slab, then jump to load_freelist, which clobbers c->freelist.
      
      But if we instead continue as follows, we get worse corruption:
      
       - task A: run __slab_free() on object from other struct slab:
          - CPU_PARTIAL_FREE case (slab was on no list, is now on pcpu partial)
       - task A: run slab_alloc_node() with NUMA node constraint:
          - fastpath fails (c->slab is NULL)
          - call __slab_alloc()
          - slub_get_cpu_ptr() (disables preemption)
          - enter ___slab_alloc()
          - c->slab is NULL: goto new_slab
          - slub_percpu_partial() is non-NULL
          - set c->slab to slub_percpu_partial(c)
          - [CORRUPT STATE: c->slab points to slab-1, c->freelist has objects
            from slab-2]
          - goto redo
          - node_match() fails
          - goto deactivate_slab
          - existing c->freelist is passed into deactivate_slab()
          - inuse count of slab-1 is decremented to account for object from
            slab-2
      
      At this point, the inuse count of slab-1 is 1 lower than it should be.
      This means that if we free all allocated objects in slab-1 except for one,
      SLUB will think that slab-1 is completely unused, and may free its page,
      leading to use-after-free.
      
      Fixes: c17dda40 ("slub: Separate out kmem_cache_cpu processing from deactivate_slab")
      Fixes: 03e404af
      
       ("slub: fast release on full slab")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Acked-by: default avatarChristoph Lameter <cl@linux.com>
      Acked-by: default avatarDavid Rientjes <rientjes@google.com>
      Reviewed-by: default avatarMuchun Song <songmuchun@bytedance.com>
      Tested-by: default avatarHyeonggon Yoo <42.hyeyoo@gmail.com>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Link: https://lore.kernel.org/r/20220608182205.2945720-1-jannh@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e2b2f0e2
    • Sabrina Dubroca's avatar
      esp: limit skb_page_frag_refill use to a single page · ef6f83df
      Sabrina Dubroca authored
      commit 5bd8baab upstream.
      
      Commit ebe48d36 ("esp: Fix possible buffer overflow in ESP
      transformation") tried to fix skb_page_frag_refill usage in ESP by
      capping allocsize to 32k, but that doesn't completely solve the issue,
      as skb_page_frag_refill may return a single page. If that happens, we
      will write out of bounds, despite the check introduced in the previous
      patch.
      
      This patch forces COW in cases where we would end up calling
      skb_page_frag_refill with a size larger than a page (first in
      esp_output_head with tailen, then in esp_output_tail with
      skb->data_len).
      
      Fixes: cac2661c ("esp4: Avoid skb_cow_data whenever possible")
      Fixes: 03e2a30f
      
       ("esp6: Avoid skb_cow_data whenever possible")
      Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ef6f83df
  2. Jul 07, 2022