Skip to content
  1. Oct 29, 2021
  2. Oct 27, 2021
    • Greg Kroah-Hartman's avatar
      Linux 5.10.76 · 378e85d1
      Greg Kroah-Hartman authored
      
      
      Link: https://lore.kernel.org/r/20211025190956.374447057@linuxfoundation.org
      Tested-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Tested-by: default avatarPavel Machek (CIP) <pavel@denx.de>
      Tested-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Tested-by: default avatarFox Chen <foxhlchen@gmail.com>
      Tested-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Tested-by: default avatarSalvatore Bonaccorso <carnil@debian.org>
      Tested-by: default avatarSudip Mukherjee <sudip.mukherjee@codethink.co.uk>
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      v5.10.76
      378e85d1
    • Fabien Dessenne's avatar
      pinctrl: stm32: use valid pin identifier in stm32_pinctrl_resume() · cfa79faf
      Fabien Dessenne authored
      commit c370bb47 upstream.
      
      When resuming from low power, the driver attempts to restore the
      configuration of some pins. This is done by a call to:
        stm32_pinctrl_restore_gpio_regs(struct stm32_pinctrl *pctl, u32 pin)
      where 'pin' must be a valid pin value (i.e. matching some 'groups->pin').
      Fix the current implementation which uses some wrong 'pin' value.
      
      Fixes: e2f3cf18
      
       ("pinctrl: stm32: add suspend/resume management")
      Signed-off-by: default avatarFabien Dessenne <fabien.dessenne@foss.st.com>
      Link: https://lore.kernel.org/r/20211008122517.617633-1-fabien.dessenne@foss.st.com
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cfa79faf
    • Nick Desaulniers's avatar
      ARM: 9122/1: select HAVE_FUTEX_CMPXCHG · c56c8013
      Nick Desaulniers authored
      commit 9d417cbe upstream.
      
      tglx notes:
        This function [futex_detect_cmpxchg] is only needed when an
        architecture has to runtime discover whether the CPU supports it or
        not.  ARM has unconditional support for this, so the obvious thing to
        do is the below.
      
      Fixes linkage failure from Clang randconfigs:
      kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
      and boot failures for CONFIG_THUMB2_KERNEL.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/325
      
      Comments from Nick Desaulniers:
      
       See-also: 03b8c7b6
      
       ("futex: Allow architectures to skip
       futex_atomic_cmpxchg_inatomic() test")
      
      Reported-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reported-by: default avatarNathan Chancellor <nathan@kernel.org>
      Suggested-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarNathan Chancellor <nathan@kernel.org>
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Cc: stable@vger.kernel.org # v3.14+
      Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c56c8013
    • Lorenz Bauer's avatar
      selftests: bpf: fix backported ASSERT_FALSE · d088db86
      Lorenz Bauer authored
      Commit 183d9ebd ("selftests/bpf: Fix core_reloc test runner") causes
      builds of selftests/bpf to fail on 5.10.y since the branch doesn't have the
      ASSERT_FALSE macro yet. Replace ASSERT_FALSE with ASSERT_EQ.
      
      Fixes: 183d9ebd
      
       ("selftests/bpf: Fix core_reloc test runner")
      Signed-off-by: default avatarLorenz Bauer <lmb@cloudflare.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d088db86
    • Sasha Neftin's avatar
      e1000e: Separate TGP board type from SPT · 3a845fa0
      Sasha Neftin authored
      [ Upstream commit 280db5d4
      
       ]
      
      We have the same LAN controller on different PCHs. Separate TGP board
      type from SPT which will allow for specific fixes to be applied for
      TGP platforms.
      
      Suggested-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Signed-off-by: default avatarSasha Neftin <sasha.neftin@intel.com>
      Reviewed-by: default avatarPaul Menzel <pmenzel@molgen.mpg.de>
      Tested-by: default avatarMark Pearson <markpearson@lenovo.com>
      Tested-by: default avatarNechama Kraus <nechamax.kraus@linux.intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3a845fa0
    • Steven Rostedt (VMware)'s avatar
      tracing: Have all levels of checks prevent recursion · 021b6d11
      Steven Rostedt (VMware) authored
      commit ed65df63 upstream.
      
      While writing an email explaining the "bit = 0" logic for a discussion on
      making ftrace_test_recursion_trylock() disable preemption, I discovered a
      path that makes the "not do the logic if bit is zero" unsafe.
      
      The recursion logic is done in hot paths like the function tracer. Thus,
      any code executed causes noticeable overhead. Thus, tricks are done to try
      to limit the amount of code executed. This included the recursion testing
      logic.
      
      Having recursion testing is important, as there are many paths that can
      end up in an infinite recursion cycle when tracing every function in the
      kernel. Thus protection is needed to prevent that from happening.
      
      Because it is OK to recurse due to different running context levels (e.g.
      an interrupt preempts a trace, and then a trace occurs in the interrupt
      handler), a set of bits are used to know which context one is in (normal,
      softirq, irq and NMI). If a recursion occurs in the same level, it is
      prevented*.
      
      Then there are infrastructure levels of recursion as well. When more than
      one callback is attached to the same function to trace, it calls a loop
      function to iterate over all the callbacks. Both the callbacks and the
      loop function have recursion protection. The callbacks use the
      "ftrace_test_recursion_trylock()" which has a "function" set of context
      bits to test, and the loop function calls the internal
      trace_test_and_set_recursion() directly, with an "internal" set of bits.
      
      If an architecture does not implement all the features supported by ftrace
      then the callbacks are never called directly, and the loop function is
      called instead, which will implement the features of ftrace.
      
      Since both the loop function and the callbacks do recursion protection, it
      was seemed unnecessary to do it in both locations. Thus, a trick was made
      to have the internal set of recursion bits at a more significant bit
      location than the function bits. Then, if any of the higher bits were set,
      the logic of the function bits could be skipped, as any new recursion
      would first have to go through the loop function.
      
      This is true for architectures that do not support all the ftrace
      features, because all functions being traced must first go through the
      loop function before going to the callbacks. But this is not true for
      architectures that support all the ftrace features. That's because the
      loop function could be called due to two callbacks attached to the same
      function, but then a recursion function inside the callback could be
      called that does not share any other callback, and it will be called
      directly.
      
      i.e.
      
       traced_function_1: [ more than one callback tracing it ]
         call loop_func
      
       loop_func:
         trace_recursion set internal bit
         call callback
      
       callback:
         trace_recursion [ skipped because internal bit is set, return 0 ]
         call traced_function_2
      
       traced_function_2: [ only traced by above callback ]
         call callback
      
       callback:
         trace_recursion [ skipped because internal bit is set, return 0 ]
         call traced_function_2
      
       [ wash, rinse, repeat, BOOM! out of shampoo! ]
      
      Thus, the "bit == 0 skip" trick is not safe, unless the loop function is
      call for all functions.
      
      Since we want to encourage architectures to implement all ftrace features,
      having them slow down due to this extra logic may encourage the
      maintainers to update to the latest ftrace features. And because this
      logic is only safe for them, remove it completely.
      
       [*] There is on layer of recursion that is allowed, and that is to allow
           for the transition between interrupt context (normal -> softirq ->
           irq -> NMI), because a trace may occur before the context update is
           visible to the trace recursion logic.
      
      Link: https://lore.kernel.org/all/609b565a-ed6e-a1da-f025-166691b5d994@linux.alibaba.com/
      Link: https://lkml.kernel.org/r/20211018154412.09fcad3c@gandalf.local.home
      
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: "James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: Miroslav Benes <mbenes@suse.cz>
      Cc: Joe Lawrence <joe.lawrence@redhat.com>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Jisheng Zhang <jszhang@kernel.org>
      Cc: =?utf-8?b?546L6LSH?= <yun.wang@linux.alibaba.com>
      Cc: Guo Ren <guoren@kernel.org>
      Cc: stable@vger.kernel.org
      Fixes: edc15caf
      
       ("tracing: Avoid unnecessary multiple recursion checks")
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      021b6d11
    • Yanfei Xu's avatar
      net: mdiobus: Fix memory leak in __mdiobus_register · 3a0dc2e3
      Yanfei Xu authored
      commit ab609f25
      
       upstream.
      
      Once device_register() failed, we should call put_device() to
      decrement reference count for cleanup. Or it will cause memory
      leak.
      
      BUG: memory leak
      unreferenced object 0xffff888114032e00 (size 256):
        comm "kworker/1:3", pid 2960, jiffies 4294943572 (age 15.920s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 08 2e 03 14 81 88 ff ff  ................
          08 2e 03 14 81 88 ff ff 90 76 65 82 ff ff ff ff  .........ve.....
        backtrace:
          [<ffffffff8265cfab>] kmalloc include/linux/slab.h:591 [inline]
          [<ffffffff8265cfab>] kzalloc include/linux/slab.h:721 [inline]
          [<ffffffff8265cfab>] device_private_init drivers/base/core.c:3203 [inline]
          [<ffffffff8265cfab>] device_add+0x89b/0xdf0 drivers/base/core.c:3253
          [<ffffffff828dd643>] __mdiobus_register+0xc3/0x450 drivers/net/phy/mdio_bus.c:537
          [<ffffffff828cb835>] __devm_mdiobus_register+0x75/0xf0 drivers/net/phy/mdio_devres.c:87
          [<ffffffff82b92a00>] ax88772_init_mdio drivers/net/usb/asix_devices.c:676 [inline]
          [<ffffffff82b92a00>] ax88772_bind+0x330/0x480 drivers/net/usb/asix_devices.c:786
          [<ffffffff82baa33f>] usbnet_probe+0x3ff/0xdf0 drivers/net/usb/usbnet.c:1745
          [<ffffffff82c36e17>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
          [<ffffffff82661d17>] call_driver_probe drivers/base/dd.c:517 [inline]
          [<ffffffff82661d17>] really_probe.part.0+0xe7/0x380 drivers/base/dd.c:596
          [<ffffffff826620bc>] really_probe drivers/base/dd.c:558 [inline]
          [<ffffffff826620bc>] __driver_probe_device+0x10c/0x1e0 drivers/base/dd.c:751
          [<ffffffff826621ba>] driver_probe_device+0x2a/0x120 drivers/base/dd.c:781
          [<ffffffff82662a26>] __device_attach_driver+0xf6/0x140 drivers/base/dd.c:898
          [<ffffffff8265eca7>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:427
          [<ffffffff826625a2>] __device_attach+0x122/0x260 drivers/base/dd.c:969
          [<ffffffff82660916>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:487
          [<ffffffff8265cd0b>] device_add+0x5fb/0xdf0 drivers/base/core.c:3359
          [<ffffffff82c343b9>] usb_set_configuration+0x9d9/0xb90 drivers/usb/core/message.c:2170
          [<ffffffff82c4473c>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
      
      BUG: memory leak
      unreferenced object 0xffff888116f06900 (size 32):
        comm "kworker/0:2", pid 2670, jiffies 4294944448 (age 7.160s)
        hex dump (first 32 bytes):
          75 73 62 2d 30 30 31 3a 30 30 33 00 00 00 00 00  usb-001:003.....
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<ffffffff81484516>] kstrdup+0x36/0x70 mm/util.c:60
          [<ffffffff814845a3>] kstrdup_const+0x53/0x80 mm/util.c:83
          [<ffffffff82296ba2>] kvasprintf_const+0xc2/0x110 lib/kasprintf.c:48
          [<ffffffff82358d4b>] kobject_set_name_vargs+0x3b/0xe0 lib/kobject.c:289
          [<ffffffff826575f3>] dev_set_name+0x63/0x90 drivers/base/core.c:3147
          [<ffffffff828dd63b>] __mdiobus_register+0xbb/0x450 drivers/net/phy/mdio_bus.c:535
          [<ffffffff828cb835>] __devm_mdiobus_register+0x75/0xf0 drivers/net/phy/mdio_devres.c:87
          [<ffffffff82b92a00>] ax88772_init_mdio drivers/net/usb/asix_devices.c:676 [inline]
          [<ffffffff82b92a00>] ax88772_bind+0x330/0x480 drivers/net/usb/asix_devices.c:786
          [<ffffffff82baa33f>] usbnet_probe+0x3ff/0xdf0 drivers/net/usb/usbnet.c:1745
          [<ffffffff82c36e17>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
          [<ffffffff82661d17>] call_driver_probe drivers/base/dd.c:517 [inline]
          [<ffffffff82661d17>] really_probe.part.0+0xe7/0x380 drivers/base/dd.c:596
          [<ffffffff826620bc>] really_probe drivers/base/dd.c:558 [inline]
          [<ffffffff826620bc>] __driver_probe_device+0x10c/0x1e0 drivers/base/dd.c:751
          [<ffffffff826621ba>] driver_probe_device+0x2a/0x120 drivers/base/dd.c:781
          [<ffffffff82662a26>] __device_attach_driver+0xf6/0x140 drivers/base/dd.c:898
          [<ffffffff8265eca7>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:427
          [<ffffffff826625a2>] __device_attach+0x122/0x260 drivers/base/dd.c:969
      
      Reported-by: default avatar <syzbot+398e7dc692ddbbb4cfec@syzkaller.appspotmail.com>
      Signed-off-by: default avatarYanfei Xu <yanfei.xu@windriver.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3a0dc2e3
    • Daniel Borkmann's avatar
      bpf, test, cgroup: Use sk_{alloc,free} for test cases · cfe92662
      Daniel Borkmann authored
      commit 435b08ec upstream.
      
      BPF test infra has some hacks in place which kzalloc() a socket and perform
      minimum init via sock_net_set() and sock_init_data(). As a result, the sk's
      skcd->cgroup is NULL since it didn't go through proper initialization as it
      would have been the case from sk_alloc(). Rather than re-adding a NULL test
      in sock_cgroup_ptr() just for this, use sk_{alloc,free}() pair for the test
      socket. The latter also allows to get rid of the bpf_sk_storage_free() special
      case.
      
      Fixes: 8520e224 ("bpf, cgroups: Fix cgroup v2 fallback on v1/v2 mixed mode")
      Fixes: b7a1848e ("bpf: add BPF_PROG_TEST_RUN support for flow dissector")
      Fixes: 2cb494a3
      
       ("bpf: add tests for direct packet access from CGROUP_SKB")
      Reported-by: default avatar <syzbot+664b58e9a40fbb2cec71@syzkaller.appspotmail.com>
      Reported-by: default avatar <syzbot+33f36d0754d4c5c0e102@syzkaller.appspotmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Tested-by: default avatar <syzbot+664b58e9a40fbb2cec71@syzkaller.appspotmail.com>
      Tested-by: default avatar <syzbot+33f36d0754d4c5c0e102@syzkaller.appspotmail.com>
      Link: https://lore.kernel.org/bpf/20210927123921.21535-2-daniel@iogearbox.net
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cfe92662
    • Niklas Schnelle's avatar
      s390/pci: fix zpci_zdev_put() on reserve · 188907c2
      Niklas Schnelle authored
      commit a46044a9 upstream.
      
      Since commit 2a671f77 ("s390/pci: fix use after free of zpci_dev")
      the reference count of a zpci_dev is incremented between
      pcibios_add_device() and pcibios_release_device() which was supposed to
      prevent the zpci_dev from being freed while the common PCI code has
      access to it. It was missed however that the handling of zPCI
      availability events assumed that once zpci_zdev_put() was called no
      later availability event would still see the device. With the previously
      mentioned commit however this assumption no longer holds and we must
      make sure that we only drop the initial long-lived reference the zPCI
      subsystem holds exactly once.
      
      Do so by introducing a zpci_device_reserved() function that handles when
      a device is reserved. Here we make sure the zpci_dev will not be
      considered for further events by removing it from the zpci_list.
      
      This also means that the device actually stays in the
      ZPCI_FN_STATE_RESERVED state between the time we know it has been
      reserved and the final reference going away. We thus need to consider it
      a real state instead of just a conceptual state after the removal. The
      final cleanup of PCI resources, removal from zbus, and destruction of
      the IOMMU stays in zpci_release_device() to make sure holders of the
      reference do see valid data until the release.
      
      Fixes: 2a671f77
      
       ("s390/pci: fix use after free of zpci_dev")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      188907c2
    • Ziyang Xuan's avatar
      can: isotp: isotp_sendmsg(): fix TX buffer concurrent access in isotp_sendmsg() · f18b90e9
      Ziyang Xuan authored
      commit 43a08c3b upstream.
      
      When isotp_sendmsg() concurrent, tx.state of all TX processes can be
      ISOTP_IDLE. The conditions so->tx.state != ISOTP_IDLE and
      wq_has_sleeper(&so->wait) can not protect TX buffer from being
      accessed by multiple TX processes.
      
      We can use cmpxchg() to try to modify tx.state to ISOTP_SENDING firstly.
      If the modification of the previous process succeed, the later process
      must wait tx.state to ISOTP_IDLE firstly. Thus, we can ensure TX buffer
      is accessed by only one process at the same time. And we should also
      restore the original tx.state at the subsequent error processes.
      
      Fixes: e057dd3f
      
       ("can: add ISO 15765-2:2016 transport protocol")
      Link: https://lore.kernel.org/all/c2517874fbdf4188585cf9ddf67a8fa74d5dbde5.1633764159.git.william.xuanziyang@huawei.com
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarZiyang Xuan <william.xuanziyang@huawei.com>
      Acked-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>
      f18b90e9
    • Dexuan Cui's avatar
      scsi: core: Fix shost->cmd_per_lun calculation in scsi_add_host_with_dma() · 2304dfb5
      Dexuan Cui authored
      commit 50b6cb35 upstream.
      
      After commit ea2f0f77 ("scsi: core: Cap scsi_host cmd_per_lun at
      can_queue"), a 416-CPU VM running on Hyper-V hangs during boot because the
      hv_storvsc driver sets scsi_driver.can_queue to an integer value that
      exceeds SHRT_MAX, and hence scsi_add_host_with_dma() sets
      shost->cmd_per_lun to a negative "short" value.
      
      Use min_t(int, ...) to work around the issue.
      
      Link: https://lore.kernel.org/r/20211008043546.6006-1-decui@microsoft.com
      Fixes: ea2f0f77
      
       ("scsi: core: Cap scsi_host cmd_per_lun at can_queue")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
      Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
      Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarDexuan Cui <decui@microsoft.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2304dfb5
    • Yunsheng Lin's avatar
      net: hns3: fix for miscalculation of rx unused desc · c58654f3
      Yunsheng Lin authored
      [ Upstream commit 9f9f0f19 ]
      
      rx unused desc is the desc that need attatching new buffer
      before refilling to hw to receive new packet, the number of
      desc need attatching new buffer is calculated using next_to_use
      and next_to_clean. when next_to_use == next_to_clean, currently
      hns3 driver assumes that all the desc has the buffer attatched,
      but 'next_to_use == next_to_clean' also means all the desc need
      attatching new buffer if hw has comsumed all the desc and the
      driver has not attatched any buffer to the desc yet.
      
      This patch adds 'refill' in desc_cb to indicate whether a new
      buffer has been refilled to a desc.
      
      Fixes: 76ad4f0e
      
       ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC")
      Signed-off-by: default avatarYunsheng Lin <linyunsheng@huawei.com>
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c58654f3
    • Woody Lin's avatar
      sched/scs: Reset the shadow stack when idle_task_exit · 96fe5061
      Woody Lin authored
      [ Upstream commit 63acd42c ]
      
      Commit f1a0a376 ("sched/core: Initialize the idle task with
      preemption disabled") removed the init_idle() call from
      idle_thread_get(). This was the sole call-path on hotplug that resets
      the Shadow Call Stack (scs) Stack Pointer (sp).
      
      Not resetting the scs-sp leads to scs overflow after enough hotplug
      cycles. Therefore add an explicit scs_task_reset() to the hotplug code
      to make sure the scs-sp does get reset on hotplug.
      
      Fixes: f1a0a376
      
       ("sched/core: Initialize the idle task with preemption disabled")
      Signed-off-by: default avatarWoody Lin <woodylin@google.com>
      [peterz: Changelog]
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarValentin Schneider <valentin.schneider@arm.com>
      Link: https://lore.kernel.org/r/20211012083521.973587-1-woodylin@google.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      96fe5061
    • Joy Gu's avatar
      scsi: qla2xxx: Fix a memory leak in an error path of qla2x00_process_els() · 96f0aebf
      Joy Gu authored
      [ Upstream commit 7fb223d0 ]
      
      Commit 8c0eb596 ("[SCSI] qla2xxx: Fix a memory leak in an error path of
      qla2x00_process_els()"), intended to change:
      
              bsg_job->request->msgcode == FC_BSG_HST_ELS_NOLOGIN
      
      to:
      
              bsg_job->request->msgcode != FC_BSG_RPT_ELS
      
      but changed it to:
      
              bsg_job->request->msgcode == FC_BSG_RPT_ELS
      
      instead.
      
      Change the == to a != to avoid leaking the fcport structure or freeing
      unallocated memory.
      
      Link: https://lore.kernel.org/r/20211012191834.90306-2-jgu@purestorage.com
      Fixes: 8c0eb596
      
       ("[SCSI] qla2xxx: Fix a memory leak in an error path of qla2x00_process_els()")
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarJoy Gu <jgu@purestorage.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      96f0aebf
    • Mike Christie's avatar
      scsi: iscsi: Fix set_param() handling · 90c8e8c0
      Mike Christie authored
      [ Upstream commit 187a580c ]
      
      In commit 9e67600e ("scsi: iscsi: Fix race condition between login and
      sync thread") we meant to add a check where before we call ->set_param() we
      make sure the iscsi_cls_connection is bound. The problem is that between
      versions 4 and 5 of the patch the deletion of the unchecked set_param()
      call was dropped so we ended up with 2 calls. As a result we can still hit
      a crash where we access the unbound connection on the first call.
      
      This patch removes that first call.
      
      Fixes: 9e67600e
      
       ("scsi: iscsi: Fix race condition between login and sync thread")
      Link: https://lore.kernel.org/r/20211010161904.60471-1-michael.christie@oracle.com
      Reviewed-by: default avatarLee Duncan <lduncan@suse.com>
      Reviewed-by: default avatarLi Feng <fengli@smartx.com>
      Signed-off-by: default avatarMike Christie <michael.christie@oracle.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      90c8e8c0
    • Uwe Kleine-König's avatar
      Input: snvs_pwrkey - add clk handling · 0eb25447
      Uwe Kleine-König authored
      [ Upstream commit d997cc17 ]
      
      On i.MX7S and i.MX8M* (but not i.MX6*) the pwrkey device has an
      associated clock. Accessing the registers requires that this clock is
      enabled. Binding the driver on at least i.MX7S and i.MX8MP while not
      having the clock enabled results in a complete hang of the machine.
      (This usually only happens if snvs_pwrkey is built as a module and the
      rtc-snvs driver isn't already bound because at bootup the required clk
      is on and only gets disabled when the clk framework disables unused clks
      late during boot.)
      
      This completes the fix in commit 135be16d
      
       ("ARM: dts: imx7s: add
      snvs clock to pwrkey").
      
      Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Link: https://lore.kernel.org/r/20211013062848.2667192-1-u.kleine-koenig@pengutronix.de
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0eb25447
    • Kan Liang's avatar
      perf/x86/msr: Add Sapphire Rapids CPU support · ea9c1f5d
      Kan Liang authored
      [ Upstream commit 71920ea9
      
       ]
      
      SMI_COUNT MSR is supported on Sapphire Rapids CPU.
      
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/1633551137-192083-1-git-send-email-kan.liang@linux.intel.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ea9c1f5d
    • Shunsuke Nakamura's avatar
      libperf tests: Fix test_stat_cpu · 7a5a1f09
      Shunsuke Nakamura authored
      [ Upstream commit 3ff6d64e
      
       ]
      
      The `cpu` argument of perf_evsel__read() must specify the cpu index.
      
      perf_cpu_map__for_each_cpu() is for iterating the cpu number (not index)
      and is thus not appropriate for use with perf_evsel__read().
      
      So, if there is an offline CPU, the cpu number specified in the argument
      may point out of range because the cpu number and the cpu index are
      different.
      
      Fix test_stat_cpu().
      
      Testing it:
      
        # make tests -C tools/lib/perf/
        make: Entering directory '/home/nakamura/kernel_src/linux-5.15-rc4_fix/tools/lib/perf'
        running static:
        - running tests/test-cpumap.c...OK
        - running tests/test-threadmap.c...OK
        - running tests/test-evlist.c...OK
        - running tests/test-evsel.c...OK
        running dynamic:
        - running tests/test-cpumap.c...OK
        - running tests/test-threadmap.c...OK
        - running tests/test-evlist.c...OK
        - running tests/test-evsel.c...OK
        make: Leaving directory '/home/nakamura/kernel_src/linux-5.15-rc4_fix/tools/lib/perf'
      
      Signed-off-by: default avatarShunsuke Nakamura <nakamura.shun@fujitsu.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20211011083704.4108720-1-nakamura.shun@fujitsu.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7a5a1f09
    • Kai Vehmanen's avatar
      ALSA: hda: avoid write to STATESTS if controller is in reset · e56a3e7a
      Kai Vehmanen authored
      [ Upstream commit b37a1518 ]
      
      The snd_hdac_bus_reset_link() contains logic to clear STATESTS register
      before performing controller reset. This code dates back to an old
      bugfix in commit e8a7f136 ("[ALSA] hda-intel - Improve HD-audio
      codec probing robustness"). Originally the code was added to
      azx_reset().
      
      The code was moved around in commit a41d1224
      
       ("ALSA: hda - Embed bus
      into controller object") and ended up to snd_hdac_bus_reset_link() and
      called primarily via snd_hdac_bus_init_chip().
      
      The logic to clear STATESTS is correct when snd_hdac_bus_init_chip() is
      called when controller is not in reset. In this case, STATESTS can be
      cleared. This can be useful e.g. when forcing a controller reset to retry
      codec probe. A normal non-power-on reset will not clear the bits.
      
      However, this old logic is problematic when controller is already in
      reset. The HDA specification states that controller must be taken out of
      reset before writing to registers other than GCTL.CRST (1.0a spec,
      3.3.7). The write to STATESTS in snd_hdac_bus_reset_link() will be lost
      if the controller is already in reset per the HDA specification mentioned.
      
      This has been harmless on older hardware. On newer generation of Intel
      PCIe based HDA controllers, if configured to report issues, this write
      will emit an unsupported request error. If ACPI Platform Error Interface
      (APEI) is enabled in kernel, this will end up to kernel log.
      
      Fix the code in snd_hdac_bus_reset_link() to only clear the STATESTS if
      the function is called when controller is not in reset. Otherwise
      clearing the bits is not possible and should be skipped.
      
      Signed-off-by: default avatarKai Vehmanen <kai.vehmanen@linux.intel.com>
      Link: https://lore.kernel.org/r/20211012142935.3731820-1-kai.vehmanen@linux.intel.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e56a3e7a
    • Prashant Malani's avatar
      platform/x86: intel_scu_ipc: Update timeout value in comment · 85c8d8c1
      Prashant Malani authored
      [ Upstream commit a0c5814b ]
      
      The comment decribing the IPC timeout hadn't been updated when the
      actual timeout was changed from 3 to 5 seconds in
      commit a7d53dbb
      
       ("platform/x86: intel_scu_ipc: Increase virtual
      timeout from 3 to 5 seconds") .
      
      Since the value is anyway updated to 10s now, take this opportunity to
      update the value in the comment too.
      
      Signed-off-by: default avatarPrashant Malani <pmalani@chromium.org>
      Cc: Benson Leung <bleung@chromium.org>
      Reviewed-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Link: https://lore.kernel.org/r/20210928101932.2543937-4-pmalani@chromium.org
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      85c8d8c1
    • Zheyu Ma's avatar
      isdn: mISDN: Fix sleeping function called from invalid context · 9f591cbd
      Zheyu Ma authored
      [ Upstream commit 6510e80a
      
       ]
      
      The driver can call card->isac.release() function from an atomic
      context.
      
      Fix this by calling this function after releasing the lock.
      
      The following log reveals it:
      
      [   44.168226 ] BUG: sleeping function called from invalid context at kernel/workqueue.c:3018
      [   44.168941 ] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 5475, name: modprobe
      [   44.169574 ] INFO: lockdep is turned off.
      [   44.169899 ] irq event stamp: 0
      [   44.170160 ] hardirqs last  enabled at (0): [<0000000000000000>] 0x0
      [   44.170627 ] hardirqs last disabled at (0): [<ffffffff814209ed>] copy_process+0x132d/0x3e00
      [   44.171240 ] softirqs last  enabled at (0): [<ffffffff81420a1a>] copy_process+0x135a/0x3e00
      [   44.171852 ] softirqs last disabled at (0): [<0000000000000000>] 0x0
      [   44.172318 ] Preemption disabled at:
      [   44.172320 ] [<ffffffffa009b0a9>] nj_release+0x69/0x500 [netjet]
      [   44.174441 ] Call Trace:
      [   44.174630 ]  dump_stack_lvl+0xa8/0xd1
      [   44.174912 ]  dump_stack+0x15/0x17
      [   44.175166 ]  ___might_sleep+0x3a2/0x510
      [   44.175459 ]  ? nj_release+0x69/0x500 [netjet]
      [   44.175791 ]  __might_sleep+0x82/0xe0
      [   44.176063 ]  ? start_flush_work+0x20/0x7b0
      [   44.176375 ]  start_flush_work+0x33/0x7b0
      [   44.176672 ]  ? trace_irq_enable_rcuidle+0x85/0x170
      [   44.177034 ]  ? kasan_quarantine_put+0xaa/0x1f0
      [   44.177372 ]  ? kasan_quarantine_put+0xaa/0x1f0
      [   44.177711 ]  __flush_work+0x11a/0x1a0
      [   44.177991 ]  ? flush_work+0x20/0x20
      [   44.178257 ]  ? lock_release+0x13c/0x8f0
      [   44.178550 ]  ? __kasan_check_write+0x14/0x20
      [   44.178872 ]  ? do_raw_spin_lock+0x148/0x360
      [   44.179187 ]  ? read_lock_is_recursive+0x20/0x20
      [   44.179530 ]  ? __kasan_check_read+0x11/0x20
      [   44.179846 ]  ? do_raw_spin_unlock+0x55/0x900
      [   44.180168 ]  ? ____kasan_slab_free+0x116/0x140
      [   44.180505 ]  ? _raw_spin_unlock_irqrestore+0x41/0x60
      [   44.180878 ]  ? skb_queue_purge+0x1a3/0x1c0
      [   44.181189 ]  ? kfree+0x13e/0x290
      [   44.181438 ]  flush_work+0x17/0x20
      [   44.181695 ]  mISDN_freedchannel+0xe8/0x100
      [   44.182006 ]  isac_release+0x210/0x260 [mISDNipac]
      [   44.182366 ]  nj_release+0xf6/0x500 [netjet]
      [   44.182685 ]  nj_remove+0x48/0x70 [netjet]
      [   44.182989 ]  pci_device_remove+0xa9/0x250
      
      Signed-off-by: default avatarZheyu Ma <zheyuma97@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9f591cbd
    • Herve Codina's avatar
      ARM: dts: spear3xx: Fix gmac node · ab4f542b
      Herve Codina authored
      [ Upstream commit 6636fec2
      
       ]
      
      On SPEAr3xx, ethernet driver is not compatible with the SPEAr600
      one.
      Indeed, SPEAr3xx uses an earlier version of this IP (v3.40) and
      needs some driver tuning compare to SPEAr600.
      
      The v3.40 IP support was added to stmmac driver and this patch
      fixes this issue and use the correct compatible string for
      SPEAr3xx
      
      Signed-off-by: default avatarHerve Codina <herve.codina@bootlin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ab4f542b
    • Herve Codina's avatar
      net: stmmac: add support for dwmac 3.40a · 15d3ad79
      Herve Codina authored
      [ Upstream commit 9cb1d19f
      
       ]
      
      dwmac 3.40a is an old ip version that can be found on SPEAr3xx soc.
      
      Signed-off-by: default avatarHerve Codina <herve.codina@bootlin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      15d3ad79
    • Filipe Manana's avatar
      btrfs: deal with errors when checking if a dir entry exists during log replay · f9d16a42
      Filipe Manana authored
      [ Upstream commit 77a5b9e3
      
       ]
      
      Currently inode_in_dir() ignores errors returned from
      btrfs_lookup_dir_index_item() and from btrfs_lookup_dir_item(), treating
      any errors as if the directory entry does not exists in the fs/subvolume
      tree, which is obviously not correct, as we can get errors such as -EIO
      when reading extent buffers while searching the fs/subvolume's tree.
      
      Fix that by making inode_in_dir() return the errors and making its only
      caller, add_inode_ref(), deal with returned errors as well.
      
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f9d16a42
    • Takashi Iwai's avatar
      ALSA: hda: intel: Allow repeatedly probing on codec configuration errors · 369db2a9
      Takashi Iwai authored
      [ Upstream commit c0f1886d
      
       ]
      
      It seems that a few recent AMD systems show the codec configuration
      errors at the early boot, while loading the driver at a later stage
      works magically.  Although the root cause of the error isn't clear,
      it's certainly not bad to allow retrying the codec probe in such a
      case if that helps.
      
      This patch adds the capability for retrying the probe upon codec probe
      errors on the certain AMD platforms.  The probe_work is changed to a
      delayed work, and at the secondary call, it'll jump to the codec
      probing.
      
      Note that, not only adding the re-probing, this includes the behavior
      changes in the codec configuration function.  Namely,
      snd_hda_codec_configure() won't unregister the codec at errors any
      longer.  Instead, its caller, azx_codec_configure() unregisters the
      codecs with the probe failures *if* any codec has been successfully
      configured.  If all codec probe failed, it doesn't unregister but let
      it re-probed -- which is the most case we're seeing and this patch
      tries to improve.
      
      Even if the driver doesn't re-probe or give up, it will go to the
      "free-all" error path, hence the leftover codecs shall be disabled /
      deleted in anyway.
      
      BugLink: https://bugzilla.suse.com/show_bug.cgi?id=1190801
      Link: https://lore.kernel.org/r/20211006141940.2897-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      369db2a9
    • Brendan Higgins's avatar
      gcc-plugins/structleak: add makefile var for disabling structleak · 81d8e70c
      Brendan Higgins authored
      [ Upstream commit 554afc3b
      
       ]
      
      KUnit and structleak don't play nice, so add a makefile variable for
      enabling structleak when it complains.
      
      Co-developed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      81d8e70c
    • Yunsheng Lin's avatar
      net: hns3: fix the max tx size according to user manual · 69078a94
      Yunsheng Lin authored
      commit adfb7b49 upstream.
      
      Currently the max tx size supported by the hw is calculated by
      using the max BD num supported by the hw. According to the hw
      user manual, the max tx size is fixed value for both non-TSO and
      TSO skb.
      
      This patch updates the max tx size according to the manual.
      
      Fixes: 8ae10cfb
      
      ("net: hns3: support tx-scatter-gather-fraglist feature")
      Signed-off-by: default avatarYunsheng Lin <linyunsheng@huawei.com>
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      69078a94
    • Marek Vasut's avatar
      drm: mxsfb: Fix NULL pointer dereference crash on unload · f40c2281
      Marek Vasut authored
      commit 3cfc1830 upstream.
      
      The mxsfb->crtc.funcs may already be NULL when unloading the driver,
      in which case calling mxsfb_irq_disable() via drm_irq_uninstall() from
      mxsfb_unload() leads to NULL pointer dereference.
      
      Since all we care about is masking the IRQ and mxsfb->base is still
      valid, just use that to clear and mask the IRQ.
      
      Fixes: ae1ed009
      
       ("drm: mxsfb: Stop using DRM simple display pipeline helper")
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Cc: Daniel Abrecht <public@danielabrecht.ch>
      Cc: Emil Velikov <emil.l.velikov@gmail.com>
      Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Stefan Agner <stefan@agner.ch>
      Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20211016210446.171616-1-marex@denx.de
      Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f40c2281
    • Nikolay Aleksandrov's avatar
      net: bridge: mcast: use multicast_membership_interval for IGMPv3 · 96835b68
      Nikolay Aleksandrov authored
      commit fac3cb82
      
       upstream.
      
      When I added IGMPv3 support I decided to follow the RFC for computing
      the GMI dynamically:
      " 8.4. Group Membership Interval
      
         The Group Membership Interval is the amount of time that must pass
         before a multicast router decides there are no more members of a
         group or a particular source on a network.
      
         This value MUST be ((the Robustness Variable) times (the Query
         Interval)) plus (one Query Response Interval)."
      
      But that actually is inconsistent with how the bridge used to compute it
      for IGMPv2, where it was user-configurable that has a correct default value
      but it is up to user-space to maintain it. This would make it consistent
      with the other timer values which are also maintained correct by the user
      instead of being dynamically computed. It also changes back to the previous
      user-expected GMI behaviour for IGMPv3 queries which were supported before
      IGMPv3 was added. Note that to properly compute it dynamically we would
      need to add support for "Robustness Variable" which is currently missing.
      
      Reported-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Fixes: 0436862e
      
       ("net: bridge: mcast: support for IGMPv3/MLDv2 ALLOW_NEW_SOURCES report")
      Signed-off-by: default avatarNikolay Aleksandrov <nikolay@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      96835b68
    • Florian Westphal's avatar
      selftests: netfilter: remove stray bash debug line · 0e033cb4
      Florian Westphal authored
      commit 3e6ed770 upstream.
      
      This should not be there.
      
      Fixes: 2de03b45
      
       ("selftests: netfilter: add flowtable test script")
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0e033cb4
    • Vegard Nossum's avatar
      netfilter: Kconfig: use 'default y' instead of 'm' for bool config option · f8a65413
      Vegard Nossum authored
      commit 77076934 upstream.
      
      This option, NF_CONNTRACK_SECMARK, is a bool, so it can never be 'm'.
      
      Fixes: 33b8e776
      
       ("[NETFILTER]: Add CONFIG_NETFILTER_ADVANCED option")
      Signed-off-by: default avatarVegard Nossum <vegard.nossum@oracle.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f8a65413
    • Xiaolong Huang's avatar
      isdn: cpai: check ctr->cnr to avoid array index out of bound · 7f221ccb
      Xiaolong Huang authored
      commit 1f3e2e97
      
       upstream.
      
      The cmtp_add_connection() would add a cmtp session to a controller
      and run a kernel thread to process cmtp.
      
      	__module_get(THIS_MODULE);
      	session->task = kthread_run(cmtp_session, session, "kcmtpd_ctr_%d",
      								session->num);
      
      During this process, the kernel thread would call detach_capi_ctr()
      to detach a register controller. if the controller
      was not attached yet, detach_capi_ctr() would
      trigger an array-index-out-bounds bug.
      
      [   46.866069][ T6479] UBSAN: array-index-out-of-bounds in
      drivers/isdn/capi/kcapi.c:483:21
      [   46.867196][ T6479] index -1 is out of range for type 'capi_ctr *[32]'
      [   46.867982][ T6479] CPU: 1 PID: 6479 Comm: kcmtpd_ctr_0 Not tainted
      5.15.0-rc2+ #8
      [   46.869002][ T6479] Hardware name: QEMU Standard PC (i440FX + PIIX,
      1996), BIOS 1.14.0-2 04/01/2014
      [   46.870107][ T6479] Call Trace:
      [   46.870473][ T6479]  dump_stack_lvl+0x57/0x7d
      [   46.870974][ T6479]  ubsan_epilogue+0x5/0x40
      [   46.871458][ T6479]  __ubsan_handle_out_of_bounds.cold+0x43/0x48
      [   46.872135][ T6479]  detach_capi_ctr+0x64/0xc0
      [   46.872639][ T6479]  cmtp_session+0x5c8/0x5d0
      [   46.873131][ T6479]  ? __init_waitqueue_head+0x60/0x60
      [   46.873712][ T6479]  ? cmtp_add_msgpart+0x120/0x120
      [   46.874256][ T6479]  kthread+0x147/0x170
      [   46.874709][ T6479]  ? set_kthread_struct+0x40/0x40
      [   46.875248][ T6479]  ret_from_fork+0x1f/0x30
      [   46.875773][ T6479]
      
      Signed-off-by: default avatarXiaolong Huang <butterflyhuangxx@gmail.com>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Link: https://lore.kernel.org/r/20211008065830.305057-1-butterflyhuangxx@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7f221ccb
    • Lin Ma's avatar
      nfc: nci: fix the UAF of rf_conn_info object · 77c0ef97
      Lin Ma authored
      commit 1b1499a8
      
       upstream.
      
      The nci_core_conn_close_rsp_packet() function will release the conn_info
      with given conn_id. However, it needs to set the rf_conn_info to NULL to
      prevent other routines like nci_rf_intf_activated_ntf_packet() to trigger
      the UAF.
      
      Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
      Signed-off-by: default avatarLin Ma <linma@zju.edu.cn>
      Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      77c0ef97
    • Paolo Bonzini's avatar
      KVM: nVMX: promptly process interrupts delivered while in guest mode · 8f042315
      Paolo Bonzini authored
      commit 3a25dfa6 upstream.
      
      Since commit c300ab9f ("KVM: x86: Replace late check_nested_events() hack with
      more precise fix") there is no longer the certainty that check_nested_events()
      tries to inject an external interrupt vmexit to L1 on every call to vcpu_enter_guest.
      Therefore, even in that case we need to set KVM_REQ_EVENT.  This ensures
      that inject_pending_event() is called, and from there kvm_check_nested_events().
      
      Fixes: c300ab9f
      
       ("KVM: x86: Replace late check_nested_events() hack with more precise fix")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8f042315
    • Miaohe Lin's avatar
      mm, slub: fix incorrect memcg slab count for bulk free · b41fd8f5
      Miaohe Lin authored
      commit 3ddd6026 upstream.
      
      kmem_cache_free_bulk() will call memcg_slab_free_hook() for all objects
      when doing bulk free.  So we shouldn't call memcg_slab_free_hook() again
      for bulk free to avoid incorrect memcg slab count.
      
      Link: https://lkml.kernel.org/r/20210916123920.48704-6-linmiaohe@huawei.com
      Fixes: d1b2cf6c
      
       ("mm: memcg/slab: uncharge during kmem_cache_free_bulk()")
      Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Reviewed-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Cc: Andrey Konovalov <andreyknvl@gmail.com>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Bharata B Rao <bharata@linux.ibm.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Faiyaz Mohammed <faiyazm@codeaurora.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Roman Gushchin <guro@fb.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b41fd8f5