1. 21 Dec, 2021 7 commits
    • Heikki Krogerus's avatar
      usb: typec: ucsi: Only check the contract if there is a connection · 3f345e90
      Heikki Krogerus authored
      The driver must make sure there is an actual connection
      before checking details about the USB Power Delivery
      contract. Those details are not valid unless there is a
      connection.
      
      This fixes NULL pointer dereference that is caused by an
      attempt to register bogus partner alternate mode that the
      firmware on some platform may report before the actual
      connection.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=215117
      Fixes: 6cbe4b2d ("usb: typec: ucsi: Check the partner alt modes always if there is PD contract")
      Reported-by: default avatarChris Hixon <linux-kernel-bugs@hixontech.com>
      Signed-off-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Link: https://lore.kernel.org/r/eb34f98f-00ef-3238-2daa-80481116035d@leemhuis.info/
      Link: https://lore.kernel.org/r/20211221140352.45501-1-heikki.krogerus@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f345e90
    • Mathias Nyman's avatar
      xhci: Fresco FL1100 controller should not have BROKEN_MSI quirk set. · e4844092
      Mathias Nyman authored
      The Fresco Logic FL1100 controller needs the TRUST_TX_LENGTH quirk like
      other Fresco controllers, but should not have the BROKEN_MSI quirks set.
      
      BROKEN_MSI quirk causes issues in detecting usb drives connected to docks
      with this FL1100 controller.
      The BROKEN_MSI flag was apparently accidentally set together with the
      TRUST_TX_LENGTH quirk
      
      Original patch went to stable so this should go there as well.
      
      Fixes: ea0f69d8 ("xhci: Enable trust tx length quirk for Fresco FL11 USB controller")
      Cc: stable@vger.kernel.org
      cc: Nikolay Martynov <mar.kolya@gmail.com>
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Link: https://lore.kernel.org/r/20211221112825.54690-2-mathias.nyman@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e4844092
    • Chunfeng Yun's avatar
      usb: mtu3: set interval of FS intr and isoc endpoint · 43f3b8cb
      Chunfeng Yun authored
      Add support to set interval also for FS intr and isoc endpoint.
      
      Fixes: 4d79e042 ("usb: mtu3: add support for usb3.1 IP")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarChunfeng Yun <chunfeng.yun@mediatek.com>
      Link: https://lore.kernel.org/r/20211218095749.6250-4-chunfeng.yun@mediatek.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      43f3b8cb
    • Chunfeng Yun's avatar
      usb: mtu3: fix list_head check warning · 8c313e3b
      Chunfeng Yun authored
      This is caused by uninitialization of list_head.
      
      BUG: KASAN: use-after-free in __list_del_entry_valid+0x34/0xe4
      
      Call trace:
      dump_backtrace+0x0/0x298
      show_stack+0x24/0x34
      dump_stack+0x130/0x1a8
      print_address_description+0x88/0x56c
      __kasan_report+0x1b8/0x2a0
      kasan_report+0x14/0x20
      __asan_load8+0x9c/0xa0
      __list_del_entry_valid+0x34/0xe4
      mtu3_req_complete+0x4c/0x300 [mtu3]
      mtu3_gadget_stop+0x168/0x448 [mtu3]
      usb_gadget_unregister_driver+0x204/0x3a0
      unregister_gadget_item+0x44/0xa4
      
      Fixes: 83374e03 ("usb: mtu3: add tracepoints to help debug")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarYuwen Ng <yuwen.ng@mediatek.com>
      Signed-off-by: default avatarChunfeng Yun <chunfeng.yun@mediatek.com>
      Link: https://lore.kernel.org/r/20211218095749.6250-3-chunfeng.yun@mediatek.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c313e3b
    • Chunfeng Yun's avatar
      usb: mtu3: add memory barrier before set GPD's HWO · a7aae769
      Chunfeng Yun authored
      There is a seldom issue that the controller access invalid address
      and trigger devapc or emimpu violation. That is due to memory access
      is out of order and cause gpd data is not correct.
      Add mb() to prohibit compiler or cpu from reordering to make sure GPD
      is fully written before setting its HWO.
      
      Fixes: 48e0d373 ("usb: mtu3: supports new QMU format")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarEddie Hung <eddie.hung@mediatek.com>
      Signed-off-by: default avatarChunfeng Yun <chunfeng.yun@mediatek.com>
      Link: https://lore.kernel.org/r/20211218095749.6250-2-chunfeng.yun@mediatek.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a7aae769
    • Chunfeng Yun's avatar
      usb: mtu3: fix interval value for intr and isoc · e3d4621c
      Chunfeng Yun authored
      Use the Interval value from isoc/intr endpoint descriptor, no need
      minus one. The original code doesn't cause transfer error for
      normal cases, but it may have side effect with respond time of ERDY
      or tPingTimeout.
      Signed-off-by: default avatarChunfeng Yun <chunfeng.yun@mediatek.com>
      Link: https://lore.kernel.org/r/20211218095749.6250-1-chunfeng.yun@mediatek.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e3d4621c
    • Vincent Pelletier's avatar
      usb: gadget: f_fs: Clear ffs_eventfd in ffs_data_clear. · b1e08873
      Vincent Pelletier authored
      ffs_data_clear is indirectly called from both ffs_fs_kill_sb and
      ffs_ep0_release, so it ends up being called twice when userland closes ep0
      and then unmounts f_fs.
      If userland provided an eventfd along with function's USB descriptors, it
      ends up calling eventfd_ctx_put as many times, causing a refcount
      underflow.
      NULL-ify ffs_eventfd to prevent these extraneous eventfd_ctx_put calls.
      
      Also, set epfiles to NULL right after de-allocating it, for readability.
      
      For completeness, ffs_data_clear actually ends up being called thrice, the
      last call being before the whole ffs structure gets freed, so when this
      specific sequence happens there is a second underflow happening (but not
      being reported):
      
      /sys/kernel/debug/tracing# modprobe usb_f_fs
      /sys/kernel/debug/tracing# echo ffs_data_clear > set_ftrace_filter
      /sys/kernel/debug/tracing# echo function > current_tracer
      /sys/kernel/debug/tracing# echo 1 > tracing_on
      (setup gadget, run and kill function userland process, teardown gadget)
      /sys/kernel/debug/tracing# echo 0 > tracing_on
      /sys/kernel/debug/tracing# cat trace
       smartcard-openp-436     [000] .....  1946.208786: ffs_data_clear <-ffs_data_closed
       smartcard-openp-431     [000] .....  1946.279147: ffs_data_clear <-ffs_data_closed
       smartcard-openp-431     [000] .n...  1946.905512: ffs_data_clear <-ffs_data_put
      
      Warning output corresponding to above trace:
      [ 1946.284139] WARNING: CPU: 0 PID: 431 at lib/refcount.c:28 refcount_warn_saturate+0x110/0x15c
      [ 1946.293094] refcount_t: underflow; use-after-free.
      [ 1946.298164] Modules linked in: usb_f_ncm(E) u_ether(E) usb_f_fs(E) hci_uart(E) btqca(E) btrtl(E) btbcm(E) btintel(E) bluetooth(E) nls_ascii(E) nls_cp437(E) vfat(E) fat(E) bcm2835_v4l2(CE) bcm2835_mmal_vchiq(CE) videobuf2_vmalloc(E) videobuf2_memops(E) sha512_generic(E) videobuf2_v4l2(E) sha512_arm(E) videobuf2_common(E) videodev(E) cpufreq_dt(E) snd_bcm2835(CE) brcmfmac(E) mc(E) vc4(E) ctr(E) brcmutil(E) snd_soc_core(E) snd_pcm_dmaengine(E) drbg(E) snd_pcm(E) snd_timer(E) snd(E) soundcore(E) drm_kms_helper(E) cec(E) ansi_cprng(E) rc_core(E) syscopyarea(E) raspberrypi_cpufreq(E) sysfillrect(E) sysimgblt(E) cfg80211(E) max17040_battery(OE) raspberrypi_hwmon(E) fb_sys_fops(E) regmap_i2c(E) ecdh_generic(E) rfkill(E) ecc(E) bcm2835_rng(E) rng_core(E) vchiq(CE) leds_gpio(E) libcomposite(E) fuse(E) configfs(E) ip_tables(E) x_tables(E) autofs4(E) ext4(E) crc16(E) mbcache(E) jbd2(E) crc32c_generic(E) sdhci_iproc(E) sdhci_pltfm(E) sdhci(E)
      [ 1946.399633] CPU: 0 PID: 431 Comm: smartcard-openp Tainted: G         C OE     5.15.0-1-rpi #1  Debian 5.15.3-1
      [ 1946.417950] Hardware name: BCM2835
      [ 1946.425442] Backtrace:
      [ 1946.432048] [<c08d60a0>] (dump_backtrace) from [<c08d62ec>] (show_stack+0x20/0x24)
      [ 1946.448226]  r7:00000009 r6:0000001c r5:c04a948c r4:c0a64e2c
      [ 1946.458412] [<c08d62cc>] (show_stack) from [<c08d9ae0>] (dump_stack+0x28/0x30)
      [ 1946.470380] [<c08d9ab8>] (dump_stack) from [<c0123500>] (__warn+0xe8/0x154)
      [ 1946.482067]  r5:c04a948c r4:c0a71dc8
      [ 1946.490184] [<c0123418>] (__warn) from [<c08d6948>] (warn_slowpath_fmt+0xa0/0xe4)
      [ 1946.506758]  r7:00000009 r6:0000001c r5:c0a71dc8 r4:c0a71e04
      [ 1946.517070] [<c08d68ac>] (warn_slowpath_fmt) from [<c04a948c>] (refcount_warn_saturate+0x110/0x15c)
      [ 1946.535309]  r8:c0100224 r7:c0dfcb84 r6:ffffffff r5:c3b84c00 r4:c24a17c0
      [ 1946.546708] [<c04a937c>] (refcount_warn_saturate) from [<c0380134>] (eventfd_ctx_put+0x48/0x74)
      [ 1946.564476] [<c03800ec>] (eventfd_ctx_put) from [<bf5464e8>] (ffs_data_clear+0xd0/0x118 [usb_f_fs])
      [ 1946.582664]  r5:c3b84c00 r4:c2695b00
      [ 1946.590668] [<bf546418>] (ffs_data_clear [usb_f_fs]) from [<bf547cc0>] (ffs_data_closed+0x9c/0x150 [usb_f_fs])
      [ 1946.609608]  r5:bf54d014 r4:c2695b00
      [ 1946.617522] [<bf547c24>] (ffs_data_closed [usb_f_fs]) from [<bf547da0>] (ffs_fs_kill_sb+0x2c/0x30 [usb_f_fs])
      [ 1946.636217]  r7:c0dfcb84 r6:c3a12260 r5:bf54d014 r4:c229f000
      [ 1946.646273] [<bf547d74>] (ffs_fs_kill_sb [usb_f_fs]) from [<c0326d50>] (deactivate_locked_super+0x54/0x9c)
      [ 1946.664893]  r5:bf54d014 r4:c229f000
      [ 1946.672921] [<c0326cfc>] (deactivate_locked_super) from [<c0326df8>] (deactivate_super+0x60/0x64)
      [ 1946.690722]  r5:c2a09000 r4:c229f000
      [ 1946.698706] [<c0326d98>] (deactivate_super) from [<c0349a28>] (cleanup_mnt+0xe4/0x14c)
      [ 1946.715553]  r5:c2a09000 r4:00000000
      [ 1946.723528] [<c0349944>] (cleanup_mnt) from [<c0349b08>] (__cleanup_mnt+0x1c/0x20)
      [ 1946.739922]  r7:c0dfcb84 r6:c3a12260 r5:c3a126fc r4:00000000
      [ 1946.750088] [<c0349aec>] (__cleanup_mnt) from [<c0143d10>] (task_work_run+0x84/0xb8)
      [ 1946.766602] [<c0143c8c>] (task_work_run) from [<c010bdc8>] (do_work_pending+0x470/0x56c)
      [ 1946.783540]  r7:5ac3c35a r6:c0d0424c r5:c200bfb0 r4:c200a000
      [ 1946.793614] [<c010b958>] (do_work_pending) from [<c01000c0>] (slow_work_pending+0xc/0x20)
      [ 1946.810553] Exception stack(0xc200bfb0 to 0xc200bff8)
      [ 1946.820129] bfa0:                                     00000000 00000000 000000aa b5e21430
      [ 1946.837104] bfc0: bef867a0 00000001 bef86840 00000034 bef86838 bef86790 bef86794 bef867a0
      [ 1946.854125] bfe0: 00000000 bef86798 b67b7a1c b6d626a4 60000010 b5a23760
      [ 1946.865335]  r10:00000000 r9:c200a000 r8:c0100224 r7:00000034 r6:bef86840 r5:00000001
      [ 1946.881914]  r4:bef867a0
      [ 1946.888793] ---[ end trace 7387f2a9725b28d0 ]---
      
      Fixes: 5e33f6fd ("usb: gadget: ffs: add eventfd notification about ffs events")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarVincent Pelletier <plr.vincent@gmail.com>
      Link: https://lore.kernel.org/r/f79eeea29f3f98de6782a064ec0f7351ad2f598f.1639793920.git.plr.vincent@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b1e08873
  2. 19 Dec, 2021 14 commits
  3. 18 Dec, 2021 11 commits
    • Linus Torvalds's avatar
      Merge tag 'tty-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty · 3f667b5d
      Linus Torvalds authored
      Pull tty/serial fixes from Greg KH:
       "Here are two small tty/serial fixes for 5.16-rc6.  They include:
      
         - n_hdlc fix for syzbot reported problem that you were previously
           copied on.
      
         - 8250_fintek driver fix that resolved a console problem by removing
           a previous change.
      
        Both have been in linux-next with no reported issues"
      
      * tag 'tty-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
        serial: 8250_fintek: Fix garbled text for console
        tty: n_hdlc: make n_hdlc_tty_wakeup() asynchronous
      3f667b5d
    • Linus Torvalds's avatar
      Merge tag 'usb-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb · fb7d0829
      Linus Torvalds authored
      Pull USB fixes from Greg KH:
       "Here are a number of small USB driver fixes for reported problems.
        They include:
      
         - dwc2 driver fixes
      
         - xhci driver fixes
      
         - cdnsp driver fixes
      
         - typec driver fix
      
         - gadget u_ether driver fix
      
         - new quirk additions
      
         - usb gadget endpoint calculation fix
      
         - usb serial new device ids
      
         - revert of a xhci-dbg change that broke early debug booting
      
        All changes, except for the revert, have been in linux-next with no
        reported problems. The revert was from yesterday, and it was reported
        by the developers affected that it resolved their problem"
      
      * tag 'usb-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
        Revert "usb: early: convert to readl_poll_timeout_atomic()"
        usb: typec: tcpm: fix tcpm unregister port but leave a pending timer
        usb: cdnsp: Fix lack of spin_lock_irqsave/spin_lock_restore
        USB: NO_LPM quirk Lenovo USB-C to Ethernet Adapher(RTL8153-04)
        usb: xhci: Extend support for runtime power management for AMD's Yellow carp.
        usb: dwc2: fix STM ID/VBUS detection startup delay in dwc2_driver_probe
        USB: gadget: bRequestType is a bitfield, not a enum
        USB: serial: option: add Telit FN990 compositions
        USB: serial: cp210x: fix CP2105 GPIO registration
        usb: cdnsp: Fix incorrect status for control request
        usb: cdnsp: Fix issue in cdnsp_log_ep trace event
        usb: cdnsp: Fix incorrect calling of cdnsp_died function
        usb: xhci-mtk: fix list_del warning when enable list debug
        usb: gadget: u_ether: fix race in setting MAC address in setup phase
      fb7d0829
    • Linus Torvalds's avatar
      Merge tag 'perf-tools-fixes-for-v5.16-2021-12-18' of... · 0f03adcc
      Linus Torvalds authored
      Merge tag 'perf-tools-fixes-for-v5.16-2021-12-18' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
      Pull perf tools fixes from Arnaldo Carvalho de Melo:
      
       - Fix segfaults in 'perf inject' related to usage of unopened files
      
       - The return value of hashmap__new() should be checked using IS_ERR()
      
      * tag 'perf-tools-fixes-for-v5.16-2021-12-18' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
        perf inject: Fix segfault due to perf_data__fd() without open
        perf inject: Fix segfault due to close without open
        perf expr: Fix missing check for return value of hashmap__new()
      0f03adcc
    • Adrian Hunter's avatar
      perf inject: Fix segfault due to perf_data__fd() without open · c271a55b
      Adrian Hunter authored
      The fixed commit attempts to get the output file descriptor even if the
      file was never opened e.g.
      
        $ perf record uname
        Linux
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.002 MB perf.data (7 samples) ]
        $ perf inject -i perf.data --vm-time-correlation=dry-run
        Segmentation fault (core dumped)
        $ gdb --quiet perf
        Reading symbols from perf...
        (gdb) r inject -i perf.data --vm-time-correlation=dry-run
        Starting program: /home/ahunter/bin/perf inject -i perf.data --vm-time-correlation=dry-run
        [Thread debugging using libthread_db enabled]
        Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
      
        Program received signal SIGSEGV, Segmentation fault.
        __GI___fileno (fp=0x0) at fileno.c:35
        35      fileno.c: No such file or directory.
        (gdb) bt
        #0  __GI___fileno (fp=0x0) at fileno.c:35
        #1  0x00005621e48dd987 in perf_data__fd (data=0x7fff4c68bd08) at util/data.h:72
        #2  perf_data__fd (data=0x7fff4c68bd08) at util/data.h:69
        #3  cmd_inject (argc=<optimized out>, argv=0x7fff4c69c1f0) at builtin-inject.c:1017
        #4  0x00005621e4936783 in run_builtin (p=0x5621e4ee6878 <commands+600>, argc=4, argv=0x7fff4c69c1f0) at perf.c:313
        #5  0x00005621e4897d5c in handle_internal_command (argv=<optimized out>, argc=<optimized out>) at perf.c:365
        #6  run_argv (argcp=<optimized out>, argv=<optimized out>) at perf.c:409
        #7  main (argc=4, argv=0x7fff4c69c1f0) at perf.c:539
        (gdb)
      
      Fixes: 0ae03893 ("perf tools: Pass a fd to perf_file_header__read_pipe()")
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20211213084829.114772-3-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c271a55b
    • Adrian Hunter's avatar
      perf inject: Fix segfault due to close without open · 0c8e32fe
      Adrian Hunter authored
      The fixed commit attempts to close inject.output even if it was never
      opened e.g.
      
        $ perf record uname
        Linux
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.002 MB perf.data (7 samples) ]
        $ perf inject -i perf.data --vm-time-correlation=dry-run
        Segmentation fault (core dumped)
        $ gdb --quiet perf
        Reading symbols from perf...
        (gdb) r inject -i perf.data --vm-time-correlation=dry-run
        Starting program: /home/ahunter/bin/perf inject -i perf.data --vm-time-correlation=dry-run
        [Thread debugging using libthread_db enabled]
        Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
      
        Program received signal SIGSEGV, Segmentation fault.
        0x00007eff8afeef5b in _IO_new_fclose (fp=0x0) at iofclose.c:48
        48      iofclose.c: No such file or directory.
        (gdb) bt
        #0  0x00007eff8afeef5b in _IO_new_fclose (fp=0x0) at iofclose.c:48
        #1  0x0000557fc7b74f92 in perf_data__close (data=data@entry=0x7ffcdafa6578) at util/data.c:376
        #2  0x0000557fc7a6b807 in cmd_inject (argc=<optimized out>, argv=<optimized out>) at builtin-inject.c:1085
        #3  0x0000557fc7ac4783 in run_builtin (p=0x557fc8074878 <commands+600>, argc=4, argv=0x7ffcdafb6a60) at perf.c:313
        #4  0x0000557fc7a25d5c in handle_internal_command (argv=<optimized out>, argc=<optimized out>) at perf.c:365
        #5  run_argv (argcp=<optimized out>, argv=<optimized out>) at perf.c:409
        #6  main (argc=4, argv=0x7ffcdafb6a60) at perf.c:539
        (gdb)
      
      Fixes: 02e6246f ("perf inject: Close inject.output on exit")
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20211213084829.114772-2-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0c8e32fe
    • Miaoqian Lin's avatar
      perf expr: Fix missing check for return value of hashmap__new() · 0a515a06
      Miaoqian Lin authored
      The hashmap__new() function may return ERR_PTR(-ENOMEM) when malloc()
      fails, add IS_ERR() checking for ctx->ids.
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.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/20211212062504.25841-1-linmq006@gmail.com
      [ s/kfree()/free()/ and add missing linux/err.h include ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0a515a06
    • Zqiang's avatar
      locking/rtmutex: Fix incorrect condition in rtmutex_spin_on_owner() · 8f556a32
      Zqiang authored
      Optimistic spinning needs to be terminated when the spinning waiter is not
      longer the top waiter on the lock, but the condition is negated. It
      terminates if the waiter is the top waiter, which is defeating the whole
      purpose.
      
      Fixes: c3123c43 ("locking/rtmutex: Dont dereference waiter lockless")
      Signed-off-by: default avatarZqiang <qiang1.zhang@intel.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20211217074207.77425-1-qiang1.zhang@intel.com
      8f556a32
    • Linus Torvalds's avatar
      Merge tag 'libata-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata · 9eaa88c7
      Linus Torvalds authored
      Pull libata fix from Damien Le Moal:
       "A single fix for this cycle:
      
         - Check that ATA16 passthrough commands that do not transfer any data
           have a DMA direction set to DMA_NONE (From George)"
      
      * tag 'libata-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata:
        libata: if T_LENGTH is zero, dma direction should be DMA_NONE
      9eaa88c7
    • Linus Torvalds's avatar
      Merge tag 'zonefs-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs · 1887bf5c
      Linus Torvalds authored
      Pull zonefs fixes from Damien Le Moal:
       "One fix and one trivial update for rc6:
      
         - Add MODULE_ALIAS_FS to get automatic module loading on mount
           (Naohiro)
      
         - Update Damien's email address in the MAINTAINERS file (me)"
      
      * tag 'zonefs-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs:
        MAITAINERS: Change zonefs maintainer email address
        zonefs: add MODULE_ALIAS_FS
      1887bf5c
    • Thiago Rafael Becker's avatar
      cifs: sanitize multiple delimiters in prepath · a3108089
      Thiago Rafael Becker authored
      mount.cifs can pass a device with multiple delimiters in it. This will
      cause rename(2) to fail with ENOENT.
      
      V2:
        - Make sanitize_path more readable.
        - Fix multiple delimiters between UNC and prepath.
        - Avoid a memory leak if a bad user starts putting a lot of delimiters
          in the path on purpose.
      
      BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=2031200
      Fixes: 24e0a1ef ("cifs: switch to new mount api")
      Cc: stable@vger.kernel.org # 5.11+
      Acked-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: default avatarThiago Rafael Becker <trbecker@gmail.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      a3108089
    • Shyam Prasad N's avatar
      cifs: ignore resource_id while getting fscache super cookie · b774302e
      Shyam Prasad N authored
      We have a cyclic dependency between fscache super cookie
      and root inode cookie. The super cookie relies on
      tcon->resource_id, which gets populated from the root inode
      number. However, fetching the root inode initializes inode
      cookie as a child of super cookie, which is yet to be populated.
      
      resource_id is only used as auxdata to check the validity of
      super cookie. We can completely avoid setting resource_id to
      remove the circular dependency. Since vol creation time and
      vol serial numbers are used for auxdata, we should be fine.
      Additionally, there will be auxiliary data check for each
      inode cookie as well.
      
      Fixes: 5bf91ef0 ("cifs: wait for tcon resource_id before getting fscache super")
      CC: David Howells <dhowells@redhat.com>
      Signed-off-by: default avatarShyam Prasad N <sprasad@microsoft.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      b774302e
  4. 17 Dec, 2021 8 commits
    • Yu Liao's avatar
      timekeeping: Really make sure wall_to_monotonic isn't positive · 4e8c11b6
      Yu Liao authored
      Even after commit e1d7ba87 ("time: Always make sure wall_to_monotonic
      isn't positive") it is still possible to make wall_to_monotonic positive
      by running the following code:
      
          int main(void)
          {
              struct timespec time;
      
              clock_gettime(CLOCK_MONOTONIC, &time);
              time.tv_nsec = 0;
              clock_settime(CLOCK_REALTIME, &time);
              return 0;
          }
      
      The reason is that the second parameter of timespec64_compare(), ts_delta,
      may be unnormalized because the delta is calculated with an open coded
      substraction which causes the comparison of tv_sec to yield the wrong
      result:
      
        wall_to_monotonic = { .tv_sec = -10, .tv_nsec =  900000000 }
        ts_delta 	    = { .tv_sec =  -9, .tv_nsec = -900000000 }
      
      That makes timespec64_compare() claim that wall_to_monotonic < ts_delta,
      but actually the result should be wall_to_monotonic > ts_delta.
      
      After normalization, the result of timespec64_compare() is correct because
      the tv_sec comparison is not longer misleading:
      
        wall_to_monotonic = { .tv_sec = -10, .tv_nsec =  900000000 }
        ts_delta 	    = { .tv_sec = -10, .tv_nsec =  100000000 }
      
      Use timespec64_sub() to ensure that ts_delta is normalized, which fixes the
      issue.
      
      Fixes: e1d7ba87 ("time: Always make sure wall_to_monotonic isn't positive")
      Signed-off-by: default avatarYu Liao <liaoyu15@huawei.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20211213135727.1656662-1-liaoyu15@huawei.com
      4e8c11b6
    • Linus Torvalds's avatar
      Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · 5d65f6f3
      Linus Torvalds authored
      Pull SCSI fix from James Bottomley:
       "One driver fix: the pm8001 has never actually worked on a system with
        an IOMMU and this fixes that use case"
      
      * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
        scsi: pm8001: Fix phys_to_virt() usage on dma_addr_t
      5d65f6f3
    • Linus Torvalds's avatar
      Merge tag 'for-5.16-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux · 96091341
      Linus Torvalds authored
      Pull btrfs fixes from David Sterba:
       "A few more fixes, almost all error handling one-liners and for stable.
      
         - regression fix in directory logging items
      
         - regression fix of extent buffer status bits handling after an error
      
         - fix memory leak in error handling path in tree-log
      
         - fix freeing invalid anon device number when handling errors during
           subvolume creation
      
         - fix warning when freeing leaf after subvolume creation failure
      
         - fix missing blkdev put in device scan error handling
      
         - fix invalid delayed ref after subvolume creation failure"
      
      * tag 'for-5.16-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
        btrfs: fix missing blkdev_put() call in btrfs_scan_one_device()
        btrfs: fix warning when freeing leaf after subvolume creation failure
        btrfs: fix invalid delayed ref after subvolume creation failure
        btrfs: check WRITE_ERR when trying to read an extent buffer
        btrfs: fix missing last dir item offset update when logging directory
        btrfs: fix double free of anon_dev after failure to create subvolume
        btrfs: fix memory leak in __add_inode_ref()
      96091341
    • Linus Torvalds's avatar
      Merge tag 'selinux-pr-20211217' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux · f1f05ef3
      Linus Torvalds authored
      Pull selinux fix from Paul Moore:
       "Another small SELinux fix for v5.16 to ensure that we don't block on
        memory allocations while holding a spinlock.
      
        This passes all our tests without problem"
      
      * tag 'selinux-pr-20211217' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
        selinux: fix sleeping function called from invalid context
      f1f05ef3
    • Linus Torvalds's avatar
      Merge tag 'riscv-for-linus-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux · 0bb43aec
      Linus Torvalds authored
      Pull RISC-V fixes from Palmer Dabbelt:
      
       - A handful of DT updates for the SiFive HiFive Unmatched, that fix the
         regulator handling. These should stop some warning spew.
      
       - A pair of fixes for both the SiFive Hifive Unleashed and Unmatched,
         that correctly hook up the MMC card detect signal.
      
      * tag 'riscv-for-linus-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
        riscv: dts: sifive unmatched: Link the tmp451 with its power supply
        riscv: dts: sifive unmatched: Fix regulator for board rev3
        riscv: dts: sifive unmatched: Expose the PMIC sub-functions
        riscv: dts: sifive unmatched: Expose the board ID eeprom
        riscv: dts: sifive unmatched: Name gpio lines
        riscv: dts: unmatched: Add gpio card detect to mmc-spi-slot
        riscv: dts: unleashed: Add gpio card detect to mmc-spi-slot
      0bb43aec
    • Linus Torvalds's avatar
      Merge tag 'block-5.16-2021-12-17' of git://git.kernel.dk/linux-block · fa09ca5e
      Linus Torvalds authored
      Pull block fixes from Jens Axboe:
      
       - Fix for hammering on the delayed run queue timer (me)
      
       - bcache regression fix for this merge window (Lin)
      
       - Fix a divide-by-zero in the blk-iocost code (Tejun)
      
      * tag 'block-5.16-2021-12-17' of git://git.kernel.dk/linux-block:
        bcache: fix NULL pointer reference in cached_dev_detach_finish
        block: reduce kblockd_mod_delayed_work_on() CPU consumption
        iocost: Fix divide-by-zero on donation from low hweight cgroup
      fa09ca5e
    • Linus Torvalds's avatar
      Merge tag 'io_uring-5.16-2021-12-17' of git://git.kernel.dk/linux-block · cb29eee3
      Linus Torvalds authored
      Pull io_uring fix from Jens Axboe:
       "Just a single fix, fixing an issue with the worker creation change
        that was merged last week"
      
      * tag 'io_uring-5.16-2021-12-17' of git://git.kernel.dk/linux-block:
        io-wq: drop wqe lock before creating new worker
      cb29eee3
    • Linus Torvalds's avatar
      Merge tag 'dmaengine-fix-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine · 43d1c6a6
      Linus Torvalds authored
      Pull dmaengine fixes from Vinod Koul:
       "A bunch of driver fixes, notably:
      
         - uninit variable fix for dw-axi-dmac driver
      
         - return value check dw-edma driver
      
         - calling wq quiesce inside spinlock and missed completion for idxd
           driver
      
         - mod alias fix for st_fdma driver"
      
      * tag 'dmaengine-fix-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine:
        dmaengine: st_fdma: fix MODULE_ALIAS
        dmaengine: idxd: fix missed completion on abort path
        dmaengine: ti: k3-udma: Fix smatch warnings
        dmaengine: idxd: fix calling wq quiesce inside spinlock
        dmaengine: dw-edma: Fix return value check for dma_set_mask_and_coherent()
        dmaengine: dw-axi-dmac: Fix uninitialized variable in axi_chan_block_xfer_start()
      43d1c6a6