Skip to content
  1. Nov 03, 2021
  2. Oct 27, 2021
    • Greg Kroah-Hartman's avatar
      Linux 4.14.253 · cd529693
      Greg Kroah-Hartman authored
      
      
      Link: https://lore.kernel.org/r/20211025190922.089277904@linuxfoundation.org
      Tested-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      v4.14.253
      cd529693
    • Nick Desaulniers's avatar
      ARM: 9122/1: select HAVE_FUTEX_CMPXCHG · 8b9d000e
      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>
      8b9d000e
    • Steven Rostedt (VMware)'s avatar
      tracing: Have all levels of checks prevent recursion · 83f0c62f
      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>
      83f0c62f
    • Yanfei Xu's avatar
      net: mdiobus: Fix memory leak in __mdiobus_register · 4ec0f9ab
      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>
      4ec0f9ab
    • Dexuan Cui's avatar
      scsi: core: Fix shost->cmd_per_lun calculation in scsi_add_host_with_dma() · 249955c1
      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>
      249955c1
    • Kai Vehmanen's avatar
      ALSA: hda: avoid write to STATESTS if controller is in reset · 840c7109
      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>
      840c7109
    • Prashant Malani's avatar
      platform/x86: intel_scu_ipc: Update timeout value in comment · 394ca06e
      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>
      394ca06e
    • Zheyu Ma's avatar
      isdn: mISDN: Fix sleeping function called from invalid context · 37e4f57b
      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>
      37e4f57b
    • Herve Codina's avatar
      ARM: dts: spear3xx: Fix gmac node · cc6a8f43
      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>
      cc6a8f43
    • Herve Codina's avatar
      net: stmmac: add support for dwmac 3.40a · 4d1c25f7
      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>
      4d1c25f7
    • Filipe Manana's avatar
      btrfs: deal with errors when checking if a dir entry exists during log replay · 1899538b
      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>
      1899538b
    • Vegard Nossum's avatar
      netfilter: Kconfig: use 'default y' instead of 'm' for bool config option · e9e7a80b
      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>
      e9e7a80b
    • Xiaolong Huang's avatar
      isdn: cpai: check ctr->cnr to avoid array index out of bound · 9b6b2db7
      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>
      9b6b2db7
    • Lin Ma's avatar
      nfc: nci: fix the UAF of rf_conn_info object · a2efe3df
      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>
      a2efe3df
    • Takashi Iwai's avatar
      ASoC: DAPM: Fix missing kctl change notifications · 2e1606a0
      Takashi Iwai authored
      commit 5af82c81
      
       upstream.
      
      The put callback of a kcontrol is supposed to return 1 when the value
      is changed, and this will be notified to user-space.  However, some
      DAPM kcontrols always return 0 (except for errors), hence the
      user-space misses the update of a control value.
      
      This patch corrects the behavior by properly returning 1 when the
      value gets updated.
      
      Reported-and-tested-by: default avatarHans de Goede <hdegoede@redhat.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Link: https://lore.kernel.org/r/20211006141712.2439-1-tiwai@suse.de
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2e1606a0
    • Brendan Grieve's avatar
      ALSA: usb-audio: Provide quirk for Sennheiser GSP670 Headset · 86ee5f97
      Brendan Grieve authored
      commit 3c414eb6
      
       upstream.
      
      As per discussion at: https://github.com/szszoke/sennheiser-gsp670-pulseaudio-profile/issues/13
      
      The GSP670 has 2 playback and 1 recording device that by default are
      detected in an incompatible order for alsa. This may have been done to make
      it compatible for the console by the manufacturer and only affects the
      latest firmware which uses its own ID.
      
      This quirk will resolve this by reordering the channels.
      
      Signed-off-by: default avatarBrendan Grieve <brendan@grieve.com.au>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20211015025335.196592-1-brendan@grieve.com.au
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      86ee5f97
    • Matthew Wilcox (Oracle)'s avatar
      vfs: check fd has read access in kernel_read_file_from_fd() · aaa5e838
      Matthew Wilcox (Oracle) authored
      commit 032146cd upstream.
      
      If we open a file without read access and then pass the fd to a syscall
      whose implementation calls kernel_read_file_from_fd(), we get a warning
      from __kernel_read():
      
              if (WARN_ON_ONCE(!(file->f_mode & FMODE_READ)))
      
      This currently affects both finit_module() and kexec_file_load(), but it
      could affect other syscalls in the future.
      
      Link: https://lkml.kernel.org/r/20211007220110.600005-1-willy@infradead.org
      Fixes: b844f0ec
      
       ("vfs: define kernel_copy_file_from_fd()")
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Reported-by: default avatarHao Sun <sunhao.th@gmail.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Mimi Zohar <zohar@linux.ibm.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>
      aaa5e838
    • Lukas Bulwahn's avatar
      elfcore: correct reference to CONFIG_UML · 25302765
      Lukas Bulwahn authored
      commit b0e90128 upstream.
      
      Commit 6e7b64b9 ("elfcore: fix building with clang") introduces
      special handling for two architectures, ia64 and User Mode Linux.
      However, the wrong name, i.e., CONFIG_UM, for the intended Kconfig
      symbol for User-Mode Linux was used.
      
      Although the directory for User Mode Linux is ./arch/um; the Kconfig
      symbol for this architecture is called CONFIG_UML.
      
      Luckily, ./scripts/checkkconfigsymbols.py warns on non-existing configs:
      
        UM
        Referencing files: include/linux/elfcore.h
        Similar symbols: UML, NUMA
      
      Correct the name of the config to the intended one.
      
      [akpm@linux-foundation.org: fix um/x86_64, per Catalin]
        Link: https://lkml.kernel.org/r/20211006181119.2851441-1-catalin.marinas@arm.com
        Link: https://lkml.kernel.org/r/YV6pejGzLy5ppEpt@arm.com
      
      Link: https://lkml.kernel.org/r/20211006082209.417-1-lukas.bulwahn@gmail.com
      Fixes: 6e7b64b9
      
       ("elfcore: fix building with clang")
      Signed-off-by: default avatarLukas Bulwahn <lukas.bulwahn@gmail.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Barret Rhoden <brho@google.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>
      25302765
    • Valentin Vidic's avatar
      ocfs2: mount fails with buffer overflow in strlen · 232ed975
      Valentin Vidic authored
      commit b15fa922
      
       upstream.
      
      Starting with kernel 5.11 built with CONFIG_FORTIFY_SOURCE mouting an
      ocfs2 filesystem with either o2cb or pcmk cluster stack fails with the
      trace below.  Problem seems to be that strings for cluster stack and
      cluster name are not guaranteed to be null terminated in the disk
      representation, while strlcpy assumes that the source string is always
      null terminated.  This causes a read outside of the source string
      triggering the buffer overflow detection.
      
        detected buffer overflow in strlen
        ------------[ cut here ]------------
        kernel BUG at lib/string.c:1149!
        invalid opcode: 0000 [#1] SMP PTI
        CPU: 1 PID: 910 Comm: mount.ocfs2 Not tainted 5.14.0-1-amd64 #1
          Debian 5.14.6-2
        RIP: 0010:fortify_panic+0xf/0x11
        ...
        Call Trace:
         ocfs2_initialize_super.isra.0.cold+0xc/0x18 [ocfs2]
         ocfs2_fill_super+0x359/0x19b0 [ocfs2]
         mount_bdev+0x185/0x1b0
         legacy_get_tree+0x27/0x40
         vfs_get_tree+0x25/0xb0
         path_mount+0x454/0xa20
         __x64_sys_mount+0x103/0x140
         do_syscall_64+0x3b/0xc0
         entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Link: https://lkml.kernel.org/r/20210929180654.32460-1-vvidic@valentin-vidic.from.hr
      Signed-off-by: default avatarValentin Vidic <vvidic@valentin-vidic.from.hr>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Jun Piao <piaojun@huawei.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>
      232ed975
    • Jan Kara's avatar
      ocfs2: fix data corruption after conversion from inline format · 8e6bfb4f
      Jan Kara authored
      commit 5314454e upstream.
      
      Commit 6dbf7bb5 ("fs: Don't invalidate page buffers in
      block_write_full_page()") uncovered a latent bug in ocfs2 conversion
      from inline inode format to a normal inode format.
      
      The code in ocfs2_convert_inline_data_to_extents() attempts to zero out
      the whole cluster allocated for file data by grabbing, zeroing, and
      dirtying all pages covering this cluster.  However these pages are
      beyond i_size, thus writeback code generally ignores these dirty pages
      and no blocks were ever actually zeroed on the disk.
      
      This oversight was fixed by commit 693c241a ("ocfs2: No need to zero
      pages past i_size.") for standard ocfs2 write path, inline conversion
      path was apparently forgotten; the commit log also has a reasoning why
      the zeroing actually is not needed.
      
      After commit 6dbf7bb5, things became worse as writeback code stopped
      invalidating buffers on pages beyond i_size and thus these pages end up
      with clean PageDirty bit but with buffers attached to these pages being
      still dirty.  So when a file is converted from inline format, then
      writeback triggers, and then the file is grown so that these pages
      become valid, the invalid dirtiness state is preserved,
      mark_buffer_dirty() does nothing on these pages (buffers are already
      dirty) but page is never written back because it is clean.  So data
      written to these pages is lost once pages are reclaimed.
      
      Simple reproducer for the problem is:
      
        xfs_io -f -c "pwrite 0 2000" -c "pwrite 2000 2000" -c "fsync" \
          -c "pwrite 4000 2000" ocfs2_file
      
      After unmounting and mounting the fs again, you can observe that end of
      'ocfs2_file' has lost its contents.
      
      Fix the problem by not doing the pointless zeroing during conversion
      from inline format similarly as in the standard write path.
      
      [akpm@linux-foundation.org: fix whitespace, per Joseph]
      
      Link: https://lkml.kernel.org/r/20210930095405.21433-1-jack@suse.cz
      Fixes: 6dbf7bb5
      
       ("fs: Don't invalidate page buffers in block_write_full_page()")
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Tested-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Acked-by: default avatarGang He <ghe@suse.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Jun Piao <piaojun@huawei.com>
      Cc: "Markov, Andrey" <Markov.Andrey@Dell.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>
      8e6bfb4f
    • Zheyu Ma's avatar
      can: peak_pci: peak_pci_remove(): fix UAF · 34914971
      Zheyu Ma authored
      commit 949fe9b3 upstream.
      
      When remove the module peek_pci, referencing 'chan' again after
      releasing 'dev' will cause UAF.
      
      Fix this by releasing 'dev' later.
      
      The following log reveals it:
      
      [   35.961814 ] BUG: KASAN: use-after-free in peak_pci_remove+0x16f/0x270 [peak_pci]
      [   35.963414 ] Read of size 8 at addr ffff888136998ee8 by task modprobe/5537
      [   35.965513 ] Call Trace:
      [   35.965718 ]  dump_stack_lvl+0xa8/0xd1
      [   35.966028 ]  print_address_description+0x87/0x3b0
      [   35.966420 ]  kasan_report+0x172/0x1c0
      [   35.966725 ]  ? peak_pci_remove+0x16f/0x270 [peak_pci]
      [   35.967137 ]  ? trace_irq_enable_rcuidle+0x10/0x170
      [   35.967529 ]  ? peak_pci_remove+0x16f/0x270 [peak_pci]
      [   35.967945 ]  __asan_report_load8_noabort+0x14/0x20
      [   35.968346 ]  peak_pci_remove+0x16f/0x270 [peak_pci]
      [   35.968752 ]  pci_device_remove+0xa9/0x250
      
      Fixes: e6d9c80b
      
       ("can: peak_pci: add support of some new PEAK-System PCI cards")
      Link: https://lore.kernel.org/all/1634192913-15639-1-git-send-email-zheyuma97@gmail.com
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarZheyu Ma <zheyuma97@gmail.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      34914971
    • Stephane Grosjean's avatar
      can: peak_usb: pcan_usb_fd_decode_status(): fix back to ERROR_ACTIVE state notification · 80d75c5f
      Stephane Grosjean authored
      commit 3d031abc upstream.
      
      This corrects the lack of notification of a return to ERROR_ACTIVE
      state for USB - CANFD devices from PEAK-System.
      
      Fixes: 0a25e1f4
      
       ("can: peak_usb: add support for PEAK new CANFD USB adapters")
      Link: https://lore.kernel.org/all/20210929142111.55757-1-s.grosjean@peak-system.com
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarStephane Grosjean <s.grosjean@peak-system.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      80d75c5f
    • Yoshihiro Shimoda's avatar
      can: rcar_can: fix suspend/resume · c827f3a2
      Yoshihiro Shimoda authored
      commit f7c05c39 upstream.
      
      If the driver was not opened, rcar_can_suspend() should not call
      clk_disable() because the clock was not enabled.
      
      Fixes: fd115931
      
       ("can: add Renesas R-Car CAN driver")
      Link: https://lore.kernel.org/all/20210924075556.223685-1-yoshihiro.shimoda.uh@renesas.com
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Tested-by: default avatarAyumi Nakamichi <ayumi.nakamichi.kf@renesas.com>
      Reviewed-by: default avatarUlrich Hecht <uli+renesas@fpond.eu>
      Tested-by: default avatarBiju Das <biju.das.jz@bp.renesas.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c827f3a2
    • Randy Dunlap's avatar
      NIOS2: irqflags: rename a redefined register name · aa175e4b
      Randy Dunlap authored
      [ Upstream commit 4cce60f1 ]
      
      Both arch/nios2/ and drivers/mmc/host/tmio_mmc.c define a macro
      with the name "CTL_STATUS". Change the one in arch/nios2/ to be
      "CTL_FSTATUS" (flags status) to eliminate the build warning.
      
      In file included from ../drivers/mmc/host/tmio_mmc.c:22:
      drivers/mmc/host/tmio_mmc.h:31: warning: "CTL_STATUS" redefined
         31 | #define CTL_STATUS 0x1c
      arch/nios2/include/asm/registers.h:14: note: this is the location of the previous definition
         14 | #define CTL_STATUS      0
      
      Fixes: b31ebd80
      
       ("nios2: Nios2 registers")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Dinh Nguyen <dinguyen@kernel.org>
      Signed-off-by: default avatarDinh Nguyen <dinguyen@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      aa175e4b
    • Antoine Tenart's avatar
      netfilter: ipvs: make global sysctl readonly in non-init netns · 736192b2
      Antoine Tenart authored
      [ Upstream commit 174c3762 ]
      
      Because the data pointer of net/ipv4/vs/debug_level is not updated per
      netns, it must be marked as read-only in non-init netns.
      
      Fixes: c6d2d445
      
       ("IPVS: netns, final patch enabling network name space.")
      Signed-off-by: default avatarAntoine Tenart <atenart@kernel.org>
      Acked-by: default avatarJulian Anastasov <ja@ssi.bg>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      736192b2
    • Benjamin Coddington's avatar
      NFSD: Keep existing listeners on portlist error · 652da40a
      Benjamin Coddington authored
      [ Upstream commit c2010694
      
       ]
      
      If nfsd has existing listening sockets without any processes, then an error
      returned from svc_create_xprt() for an additional transport will remove
      those existing listeners.  We're seeing this in practice when userspace
      attempts to create rpcrdma transports without having the rpcrdma modules
      present before creating nfsd kernel processes.  Fix this by checking for
      existing sockets before calling nfsd_destroy().
      
      Signed-off-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      652da40a
    • Guenter Roeck's avatar
      xtensa: xtfpga: Try software restart before simulating CPU reset · f0f25ea8
      Guenter Roeck authored
      [ Upstream commit 012e9745
      
       ]
      
      Rebooting xtensa images loaded with the '-kernel' option in qemu does
      not work. When executing a reboot command, the qemu session either hangs
      or experiences an endless sequence of error messages.
      
        Kernel panic - not syncing: Unrecoverable error in exception handler
      
      Reset code jumps to the CPU restart address, but Linux can not recover
      from there because code and data in the kernel init sections have been
      discarded and overwritten at this point.
      
      XTFPGA platforms have a means to reset the CPU by writing 0xdead into a
      specific FPGA IO address. When used in QEMU the kernel image loaded with
      the '-kernel' option gets restored to its original state allowing the
      machine to boot successfully.
      
      Use that mechanism to attempt a platform reset. If it does not work,
      fall back to the existing mechanism.
      
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f0f25ea8
    • Max Filippov's avatar
      xtensa: xtfpga: use CONFIG_USE_OF instead of CONFIG_OF · fe700bd1
      Max Filippov authored
      [ Upstream commit f3d7c2cd
      
       ]
      
      Use platform data to initialize xtfpga device drivers when CONFIG_USE_OF
      is not selected. This fixes xtfpga networking when CONFIG_USE_OF is not
      selected but CONFIG_OF is.
      
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fe700bd1
    • Eugen Hristev's avatar
      ARM: dts: at91: sama5d2_som1_ek: disable ISC node by default · 0828fff9
      Eugen Hristev authored
      [ Upstream commit 4348cc10
      
       ]
      
      Without a sensor node, the ISC will simply fail to probe, as the
      corresponding port node is missing.
      It is then logical to disable the node in the devicetree.
      If we add a port with a connection to a sensor endpoint, ISC can be enabled.
      
      Signed-off-by: default avatarEugen Hristev <eugen.hristev@microchip.com>
      Signed-off-by: default avatarNicolas Ferre <nicolas.ferre@microchip.com>
      Link: https://lore.kernel.org/r/20210902121358.503589-1-eugen.hristev@microchip.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0828fff9