Skip to content
  1. Nov 26, 2022
    • Eric Dumazet's avatar
      kcm: avoid potential race in kcm_tx_work · fe3f7970
      Eric Dumazet authored
      commit ec7eede3 upstream.
      
      syzbot found that kcm_tx_work() could crash [1] in:
      
      	/* Primarily for SOCK_SEQPACKET sockets */
      	if (likely(sk->sk_socket) &&
      	    test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) {
      <<*>>	clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
      		sk->sk_write_space(sk);
      	}
      
      I think the reason is that another thread might concurrently
      run in kcm_release() and call sock_orphan(sk) while sk is not
      locked. kcm_tx_work() find sk->sk_socket being NULL.
      
      [1]
      BUG: KASAN: null-ptr-deref in instrument_atomic_write include/linux/instrumented.h:86 [inline]
      BUG: KASAN: null-ptr-deref in clear_bit include/asm-generic/bitops/instrumented-atomic.h:41 [inline]
      BUG: KASAN: null-ptr-deref in kcm_tx_work+0xff/0x160 net/kcm/kcmsock.c:742
      Write of size 8 at addr 0000000000000008 by task kworker/u4:3/53
      
      CPU: 0 PID: 53 Comm: kworker/u4:3 Not tainted 5.19.0-rc3-next-20220621-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Workqueue: kkcmd kcm_tx_work
      Call Trace:
      <TASK>
      __dump_stack lib/dump_stack.c:88 [inline]
      dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
      kasan_report+0xbe/0x1f0 mm/kasan/report.c:495
      check_region_inline mm/kasan/generic.c:183 [inline]
      kasan_check_range+0x13d/0x180 mm/kasan/generic.c:189
      instrument_atomic_write include/linux/instrumented.h:86 [inline]
      clear_bit include/asm-generic/bitops/instrumented-atomic.h:41 [inline]
      kcm_tx_work+0xff/0x160 net/kcm/kcmsock.c:742
      process_one_work+0x996/0x1610 kernel/workqueue.c:2289
      worker_thread+0x665/0x1080 kernel/workqueue.c:2436
      kthread+0x2e9/0x3a0 kernel/kthread.c:376
      ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:302
      </TASK>
      
      Fixes: ab7ac4eb
      
       ("kcm: Kernel Connection Multiplexor module")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Tom Herbert <tom@herbertland.com>
      Link: https://lore.kernel.org/r/20221012133412.519394-1-edumazet@google.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fe3f7970
    • Eric Dumazet's avatar
      tcp: cdg: allow tcp_cdg_release() to be called multiple times · 0b191714
      Eric Dumazet authored
      commit 72e560cb upstream.
      
      Apparently, mptcp is able to call tcp_disconnect() on an already
      disconnected flow. This is generally fine, unless current congestion
      control is CDG, because it might trigger a double-free [1]
      
      Instead of fixing MPTCP, and future bugs, we can make tcp_disconnect()
      more resilient.
      
      [1]
      BUG: KASAN: double-free in slab_free mm/slub.c:3539 [inline]
      BUG: KASAN: double-free in kfree+0xe2/0x580 mm/slub.c:4567
      
      CPU: 0 PID: 3645 Comm: kworker/0:7 Not tainted 6.0.0-syzkaller-02734-g0326074ff465 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022
      Workqueue: events mptcp_worker
      Call Trace:
      <TASK>
      __dump_stack lib/dump_stack.c:88 [inline]
      dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
      print_address_description mm/kasan/report.c:317 [inline]
      print_report.cold+0x2ba/0x719 mm/kasan/report.c:433
      kasan_report_invalid_free+0x81/0x190 mm/kasan/report.c:462
      ____kasan_slab_free+0x18b/0x1c0 mm/kasan/common.c:356
      kasan_slab_free include/linux/kasan.h:200 [inline]
      slab_free_hook mm/slub.c:1759 [inline]
      slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1785
      slab_free mm/slub.c:3539 [inline]
      kfree+0xe2/0x580 mm/slub.c:4567
      tcp_disconnect+0x980/0x1e20 net/ipv4/tcp.c:3145
      __mptcp_close_ssk+0x5ca/0x7e0 net/mptcp/protocol.c:2327
      mptcp_do_fastclose net/mptcp/protocol.c:2592 [inline]
      mptcp_worker+0x78c/0xff0 net/mptcp/protocol.c:2627
      process_one_work+0x991/0x1610 kernel/workqueue.c:2289
      worker_thread+0x665/0x1080 kernel/workqueue.c:2436
      kthread+0x2e4/0x3a0 kernel/kthread.c:376
      ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
      </TASK>
      
      Allocated by task 3671:
      kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
      kasan_set_track mm/kasan/common.c:45 [inline]
      set_alloc_info mm/kasan/common.c:437 [inline]
      ____kasan_kmalloc mm/kasan/common.c:516 [inline]
      ____kasan_kmalloc mm/kasan/common.c:475 [inline]
      __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:525
      kmalloc_array include/linux/slab.h:640 [inline]
      kcalloc include/linux/slab.h:671 [inline]
      tcp_cdg_init+0x10d/0x170 net/ipv4/tcp_cdg.c:380
      tcp_init_congestion_control+0xab/0x550 net/ipv4/tcp_cong.c:193
      tcp_reinit_congestion_control net/ipv4/tcp_cong.c:217 [inline]
      tcp_set_congestion_control+0x96c/0xaa0 net/ipv4/tcp_cong.c:391
      do_tcp_setsockopt+0x505/0x2320 net/ipv4/tcp.c:3513
      tcp_setsockopt+0xd4/0x100 net/ipv4/tcp.c:3801
      mptcp_setsockopt+0x35f/0x2570 net/mptcp/sockopt.c:844
      __sys_setsockopt+0x2d6/0x690 net/socket.c:2252
      __do_sys_setsockopt net/socket.c:2263 [inline]
      __se_sys_setsockopt net/socket.c:2260 [inline]
      __x64_sys_setsockopt+0xba/0x150 net/socket.c:2260
      do_syscall_x64 arch/x86/entry/common.c:50 [inline]
      do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
      entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Freed by task 16:
      kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
      kasan_set_track+0x21/0x30 mm/kasan/common.c:45
      kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
      ____kasan_slab_free mm/kasan/common.c:367 [inline]
      ____kasan_slab_free+0x166/0x1c0 mm/kasan/common.c:329
      kasan_slab_free include/linux/kasan.h:200 [inline]
      slab_free_hook mm/slub.c:1759 [inline]
      slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1785
      slab_free mm/slub.c:3539 [inline]
      kfree+0xe2/0x580 mm/slub.c:4567
      tcp_cleanup_congestion_control+0x70/0x120 net/ipv4/tcp_cong.c:226
      tcp_v4_destroy_sock+0xdd/0x750 net/ipv4/tcp_ipv4.c:2254
      tcp_v6_destroy_sock+0x11/0x20 net/ipv6/tcp_ipv6.c:1969
      inet_csk_destroy_sock+0x196/0x440 net/ipv4/inet_connection_sock.c:1157
      tcp_done+0x23b/0x340 net/ipv4/tcp.c:4649
      tcp_rcv_state_process+0x40e7/0x4990 net/ipv4/tcp_input.c:6624
      tcp_v6_do_rcv+0x3fc/0x13c0 net/ipv6/tcp_ipv6.c:1525
      tcp_v6_rcv+0x2e8e/0x3830 net/ipv6/tcp_ipv6.c:1759
      ip6_protocol_deliver_rcu+0x2db/0x1950 net/ipv6/ip6_input.c:439
      ip6_input_finish+0x14c/0x2c0 net/ipv6/ip6_input.c:484
      NF_HOOK include/linux/netfilter.h:302 [inline]
      NF_HOOK include/linux/netfilter.h:296 [inline]
      ip6_input+0x9c/0xd0 net/ipv6/ip6_input.c:493
      dst_input include/net/dst.h:455 [inline]
      ip6_rcv_finish+0x193/0x2c0 net/ipv6/ip6_input.c:79
      ip_sabotage_in net/bridge/br_netfilter_hooks.c:874 [inline]
      ip_sabotage_in+0x1fa/0x260 net/bridge/br_netfilter_hooks.c:865
      nf_hook_entry_hookfn include/linux/netfilter.h:142 [inline]
      nf_hook_slow+0xc5/0x1f0 net/netfilter/core.c:614
      nf_hook.constprop.0+0x3ac/0x650 include/linux/netfilter.h:257
      NF_HOOK include/linux/netfilter.h:300 [inline]
      ipv6_rcv+0x9e/0x380 net/ipv6/ip6_input.c:309
      __netif_receive_skb_one_core+0x114/0x180 net/core/dev.c:5485
      __netif_receive_skb+0x1f/0x1c0 net/core/dev.c:5599
      netif_receive_skb_internal net/core/dev.c:5685 [inline]
      netif_receive_skb+0x12f/0x8d0 net/core/dev.c:5744
      NF_HOOK include/linux/netfilter.h:302 [inline]
      NF_HOOK include/linux/netfilter.h:296 [inline]
      br_pass_frame_up+0x303/0x410 net/bridge/br_input.c:68
      br_handle_frame_finish+0x909/0x1aa0 net/bridge/br_input.c:199
      br_nf_hook_thresh+0x2f8/0x3d0 net/bridge/br_netfilter_hooks.c:1041
      br_nf_pre_routing_finish_ipv6+0x695/0xef0 net/bridge/br_netfilter_ipv6.c:207
      NF_HOOK include/linux/netfilter.h:302 [inline]
      br_nf_pre_routing_ipv6+0x417/0x7c0 net/bridge/br_netfilter_ipv6.c:237
      br_nf_pre_routing+0x1496/0x1fe0 net/bridge/br_netfilter_hooks.c:507
      nf_hook_entry_hookfn include/linux/netfilter.h:142 [inline]
      nf_hook_bridge_pre net/bridge/br_input.c:255 [inline]
      br_handle_frame+0x9c9/0x12d0 net/bridge/br_input.c:399
      __netif_receive_skb_core+0x9fe/0x38f0 net/core/dev.c:5379
      __netif_receive_skb_one_core+0xae/0x180 net/core/dev.c:5483
      __netif_receive_skb+0x1f/0x1c0 net/core/dev.c:5599
      process_backlog+0x3a0/0x7c0 net/core/dev.c:5927
      __napi_poll+0xb3/0x6d0 net/core/dev.c:6494
      napi_poll net/core/dev.c:6561 [inline]
      net_rx_action+0x9c1/0xd90 net/core/dev.c:6672
      __do_softirq+0x1d0/0x9c8 kernel/softirq.c:571
      
      Fixes: 2b0a8c9e
      
       ("tcp: add CDG congestion control")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0b191714
    • Ilpo Järvinen's avatar
      serial: 8250: Flush DMA Rx on RLSI · d8342d85
      Ilpo Järvinen authored
      commit 1980860e upstream.
      
      Returning true from handle_rx_dma() without flushing DMA first creates
      a data ordering hazard. If DMA Rx has handled any character at the
      point when RLSI occurs, the non-DMA path handles any pending characters
      jumping them ahead of those characters that are pending under DMA.
      
      Fixes: 75df022b
      
       ("serial: 8250_dma: Fix RX handling")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Link: https://lore.kernel.org/r/20221108121952.5497-5-ilpo.jarvinen@linux.intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d8342d85
    • Ryusuke Konishi's avatar
      nilfs2: fix use-after-free bug of ns_writer on remount · b2fbf100
      Ryusuke Konishi authored
      commit 8cccf05f
      
       upstream.
      
      If a nilfs2 filesystem is downgraded to read-only due to metadata
      corruption on disk and is remounted read/write, or if emergency read-only
      remount is performed, detaching a log writer and synchronizing the
      filesystem can be done at the same time.
      
      In these cases, use-after-free of the log writer (hereinafter
      nilfs->ns_writer) can happen as shown in the scenario below:
      
       Task1                               Task2
       --------------------------------    ------------------------------
       nilfs_construct_segment
         nilfs_segctor_sync
           init_wait
           init_waitqueue_entry
           add_wait_queue
           schedule
                                           nilfs_remount (R/W remount case)
      				       nilfs_attach_log_writer
                                               nilfs_detach_log_writer
                                                 nilfs_segctor_destroy
                                                   kfree
           finish_wait
             _raw_spin_lock_irqsave
               __raw_spin_lock_irqsave
                 do_raw_spin_lock
                   debug_spin_lock_before  <-- use-after-free
      
      While Task1 is sleeping, nilfs->ns_writer is freed by Task2.  After Task1
      waked up, Task1 accesses nilfs->ns_writer which is already freed.  This
      scenario diagram is based on the Shigeru Yoshida's post [1].
      
      This patch fixes the issue by not detaching nilfs->ns_writer on remount so
      that this UAF race doesn't happen.  Along with this change, this patch
      also inserts a few necessary read-only checks with superblock instance
      where only the ns_writer pointer was used to check if the filesystem is
      read-only.
      
      Link: https://syzkaller.appspot.com/bug?id=79a4c002e960419ca173d55e863bd09e8112df8b
      Link: https://lkml.kernel.org/r/20221103141759.1836312-1-syoshida@redhat.com [1]
      Link: https://lkml.kernel.org/r/20221104142959.28296-1-konishi.ryusuke@gmail.com
      Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Reported-by: default avatar <syzbot+f816fa82f8783f7a02bb@syzkaller.appspotmail.com>
      Reported-by: default avatarShigeru Yoshida <syoshida@redhat.com>
      Tested-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2fbf100
    • Alexander Potapenko's avatar
      misc/vmw_vmci: fix an infoleak in vmci_host_do_receive_datagram() · 7ccf7229
      Alexander Potapenko authored
      commit e5b0d06d
      
       upstream.
      
      `struct vmci_event_qp` allocated by qp_notify_peer() contains padding,
      which may carry uninitialized data to the userspace, as observed by
      KMSAN:
      
        BUG: KMSAN: kernel-infoleak in instrument_copy_to_user ./include/linux/instrumented.h:121
         instrument_copy_to_user ./include/linux/instrumented.h:121
         _copy_to_user+0x5f/0xb0 lib/usercopy.c:33
         copy_to_user ./include/linux/uaccess.h:169
         vmci_host_do_receive_datagram drivers/misc/vmw_vmci/vmci_host.c:431
         vmci_host_unlocked_ioctl+0x33d/0x43d0 drivers/misc/vmw_vmci/vmci_host.c:925
         vfs_ioctl fs/ioctl.c:51
        ...
      
        Uninit was stored to memory at:
         kmemdup+0x74/0xb0 mm/util.c:131
         dg_dispatch_as_host drivers/misc/vmw_vmci/vmci_datagram.c:271
         vmci_datagram_dispatch+0x4f8/0xfc0 drivers/misc/vmw_vmci/vmci_datagram.c:339
         qp_notify_peer+0x19a/0x290 drivers/misc/vmw_vmci/vmci_queue_pair.c:1479
         qp_broker_attach drivers/misc/vmw_vmci/vmci_queue_pair.c:1662
         qp_broker_alloc+0x2977/0x2f30 drivers/misc/vmw_vmci/vmci_queue_pair.c:1750
         vmci_qp_broker_alloc+0x96/0xd0 drivers/misc/vmw_vmci/vmci_queue_pair.c:1940
         vmci_host_do_alloc_queuepair drivers/misc/vmw_vmci/vmci_host.c:488
         vmci_host_unlocked_ioctl+0x24fd/0x43d0 drivers/misc/vmw_vmci/vmci_host.c:927
        ...
      
        Local variable ev created at:
         qp_notify_peer+0x54/0x290 drivers/misc/vmw_vmci/vmci_queue_pair.c:1456
         qp_broker_attach drivers/misc/vmw_vmci/vmci_queue_pair.c:1662
         qp_broker_alloc+0x2977/0x2f30 drivers/misc/vmw_vmci/vmci_queue_pair.c:1750
      
        Bytes 28-31 of 48 are uninitialized
        Memory access of size 48 starts at ffff888035155e00
        Data copied to user address 0000000020000100
      
      Use memset() to prevent the infoleaks.
      
      Also speculatively fix qp_notify_peer_local(), which may suffer from the
      same problem.
      
      Reported-by: default avatar <syzbot+39be4da489ed2493ba25@syzkaller.appspotmail.com>
      Cc: stable <stable@kernel.org>
      Fixes: 06164d2b
      
       ("VMCI: queue pairs implementation.")
      Signed-off-by: default avatarAlexander Potapenko <glider@google.com>
      Reviewed-by: default avatarVishnu Dasa <vdasa@vmware.com>
      Link: https://lore.kernel.org/r/20221104175849.2782567-1-glider@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7ccf7229
    • Yann Gautier's avatar
      mmc: core: properly select voltage range without power cycle · 12cb5582
      Yann Gautier authored
      commit 39a72dbf upstream.
      
      In mmc_select_voltage(), if there is no full power cycle, the voltage
      range selected at the end of the function will be on a single range
      (e.g. 3.3V/3.4V). To keep a range around the selected voltage (3.2V/3.4V),
      the mask shift should be reduced by 1.
      
      This issue was triggered by using a specific SD-card (Verbatim Premium
      16GB UHS-1) on an STM32MP157C-DK2 board. This board cannot do UHS modes
      and there is no power cycle. And the card was failing to switch to
      high-speed mode. When adding the range 3.2V/3.3V for this card with the
      proposed shift change, the card can switch to high-speed mode.
      
      Fixes: ce69d37b
      
       ("mmc: core: Prevent violation of specs while initializing cards")
      Signed-off-by: default avatarYann Gautier <yann.gautier@foss.st.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20221028073740.7259-1-yann.gautier@foss.st.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      12cb5582
    • Ilpo Järvinen's avatar
      serial: 8250_lpss: Configure DMA also w/o DMA filter · 08da4649
      Ilpo Järvinen authored
      commit 1bfcbe58
      
       upstream.
      
      If the platform doesn't use DMA device filter (as is the case with
      Elkhart Lake), whole lpss8250_dma_setup() setup is skipped. This
      results in skipping also *_maxburst setup which is undesirable.
      Refactor lpss8250_dma_setup() to configure DMA even if filter is not
      setup.
      
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Link: https://lore.kernel.org/r/20221108121952.5497-3-ilpo.jarvinen@linux.intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      08da4649
    • Ilpo Järvinen's avatar
      serial: 8250: Fall back to non-DMA Rx if IIR_RDI occurs · 03d2236c
      Ilpo Järvinen authored
      commit a931237c upstream.
      
      DW UART sometimes triggers IIR_RDI during DMA Rx when IIR_RX_TIMEOUT
      should have been triggered instead. Since IIR_RDI has higher priority
      than IIR_RX_TIMEOUT, this causes the Rx to hang into interrupt loop.
      The problem seems to occur at least with some combinations of
      small-sized transfers (I've reproduced the problem on Elkhart Lake PSE
      UARTs).
      
      If there's already an on-going Rx DMA and IIR_RDI triggers, fall
      graciously back to non-DMA Rx. That is, behave as if IIR_RX_TIMEOUT had
      occurred.
      
      8250_omap already considers IIR_RDI similar to this change so its
      nothing unheard of.
      
      Fixes: 75df022b
      
       ("serial: 8250_dma: Fix RX handling")
      Cc: <stable@vger.kernel.org>
      Co-developed-by: default avatarSrikanth Thokala <srikanth.thokala@intel.com>
      Signed-off-by: default avatarSrikanth Thokala <srikanth.thokala@intel.com>
      Co-developed-by: default avatarAman Kumar <aman.kumar@intel.com>
      Signed-off-by: default avatarAman Kumar <aman.kumar@intel.com>
      Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Link: https://lore.kernel.org/r/20221108121952.5497-2-ilpo.jarvinen@linux.intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      03d2236c
    • Mikulas Patocka's avatar
      dm ioctl: fix misbehavior if list_versions races with module loading · 0c8d4112
      Mikulas Patocka authored
      commit 4fe1ec99
      
       upstream.
      
      __list_versions will first estimate the required space using the
      "dm_target_iterate(list_version_get_needed, &needed)" call and then will
      fill the space using the "dm_target_iterate(list_version_get_info,
      &iter_info)" call. Each of these calls locks the targets using the
      "down_read(&_lock)" and "up_read(&_lock)" calls, however between the first
      and second "dm_target_iterate" there is no lock held and the target
      modules can be loaded at this point, so the second "dm_target_iterate"
      call may need more space than what was the first "dm_target_iterate"
      returned.
      
      The code tries to handle this overflow (see the beginning of
      list_version_get_info), however this handling is incorrect.
      
      The code sets "param->data_size = param->data_start + needed" and
      "iter_info.end = (char *)vers+len" - "needed" is the size returned by the
      first dm_target_iterate call; "len" is the size of the buffer allocated by
      userspace.
      
      "len" may be greater than "needed"; in this case, the code will write up
      to "len" bytes into the buffer, however param->data_size is set to
      "needed", so it may write data past the param->data_size value. The ioctl
      interface copies only up to param->data_size into userspace, thus part of
      the result will be truncated.
      
      Fix this bug by setting "iter_info.end = (char *)vers + needed;" - this
      guarantees that the second "dm_target_iterate" call will write only up to
      the "needed" buffer and it will exit with "DM_BUFFER_FULL_FLAG" if it
      overflows the "needed" space - in this case, userspace will allocate a
      larger buffer and retry.
      
      Note that there is also a bug in list_version_get_needed - we need to add
      "strlen(tt->name) + 1" to the needed size, not "strlen(tt->name)".
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0c8d4112
    • Mitja Spes's avatar
      iio: pressure: ms5611: changed hardcoded SPI speed to value limited · 34feb623
      Mitja Spes authored
      commit 741cec30
      
       upstream.
      
      Don't hardcode the ms5611 SPI speed, limit it instead.
      
      Signed-off-by: default avatarMitja Spes <mitja@lxnav.com>
      Fixes: c0644160
      
       ("iio: pressure: add support for MS5611 pressure and temperature sensor")
      Link: https://lore.kernel.org/r/20221021135827.1444793-3-mitja@lxnav.com
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      34feb623
    • Yang Yingliang's avatar
      iio: trigger: sysfs: fix possible memory leak in iio_sysfs_trig_init() · f68c9682
      Yang Yingliang authored
      commit efa17e90 upstream.
      
      dev_set_name() allocates memory for name, it need be freed
      when device_add() fails, call put_device() to give up the
      reference that hold in device_initialize(), so that it can
      be freed in kobject_cleanup() when the refcount hit to 0.
      
      Fault injection test can trigger this:
      
      unreferenced object 0xffff8e8340a7b4c0 (size 32):
        comm "modprobe", pid 243, jiffies 4294678145 (age 48.845s)
        hex dump (first 32 bytes):
          69 69 6f 5f 73 79 73 66 73 5f 74 72 69 67 67 65  iio_sysfs_trigge
          72 00 a7 40 83 8e ff ff 00 86 13 c4 f6 ee ff ff  r..@............
        backtrace:
          [<0000000074999de8>] __kmem_cache_alloc_node+0x1e9/0x360
          [<00000000497fd30b>] __kmalloc_node_track_caller+0x44/0x1a0
          [<000000003636c520>] kstrdup+0x2d/0x60
          [<0000000032f84da2>] kobject_set_name_vargs+0x1e/0x90
          [<0000000092efe493>] dev_set_name+0x4e/0x70
      
      Fixes: 1f785681
      
       ("staging:iio:trigger sysfs userspace trigger rework.")
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Cc: <Stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20221022074212.1386424-1-yangyingliang@huawei.com
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f68c9682
    • Yang Yingliang's avatar
      iio: adc: at91_adc: fix possible memory leak in at91_adc_allocate_trigger() · c3ce73f6
      Yang Yingliang authored
      commit 65f20301 upstream.
      
      If iio_trigger_register() returns error, it should call iio_trigger_free()
      to give up the reference that hold in iio_trigger_alloc(), so that it can
      call iio_trig_release() to free memory when the refcount hit to 0.
      
      Fixes: 0e589d5f
      
       ("ARM: AT91: IIO: Add AT91 ADC driver.")
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Link: https://lore.kernel.org/r/20221024084511.815096-1-yangyingliang@huawei.com
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c3ce73f6
    • Duoming Zhou's avatar
      usb: chipidea: fix deadlock in ci_otg_del_timer · 9c769316
      Duoming Zhou authored
      commit 7a58b8d6 upstream.
      
      There is a deadlock in ci_otg_del_timer(), the process is
      shown below:
      
          (thread 1)                  |        (thread 2)
      ci_otg_del_timer()              | ci_otg_hrtimer_func()
        ...                           |
        spin_lock_irqsave() //(1)     |  ...
        ...                           |
        hrtimer_cancel()              |  spin_lock_irqsave() //(2)
        (block forever)
      
      We hold ci->lock in position (1) and use hrtimer_cancel() to
      wait ci_otg_hrtimer_func() to stop, but ci_otg_hrtimer_func()
      also need ci->lock in position (2). As a result, the
      hrtimer_cancel() in ci_otg_del_timer() will be blocked forever.
      
      This patch extracts hrtimer_cancel() from the protection of
      spin_lock_irqsave() in order that the ci_otg_hrtimer_func()
      could obtain the ci->lock.
      
      What`s more, there will be no race happen. Because the
      "next_timer" is always under the protection of
      spin_lock_irqsave() and we only check whether "next_timer"
      equals to NUM_OTG_FSM_TIMERS in the following code.
      
      Fixes: 3a316ec4
      
       ("usb: chipidea: use hrtimer for otg fsm timers")
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarDuoming Zhou <duoming@zju.edu.cn>
      Link: https://lore.kernel.org/r/20220918033312.94348-1-duoming@zju.edu.cn
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9c769316
    • Nicolas Dumazet's avatar
      usb: add NO_LPM quirk for Realforce 87U Keyboard · f7b525b7
      Nicolas Dumazet authored
      commit 181135bb
      
       upstream.
      
      Before adding this quirk, this (mechanical keyboard) device would not be
      recognized, logging:
      
        new full-speed USB device number 56 using xhci_hcd
        unable to read config index 0 descriptor/start: -32
        chopping to 0 config(s)
      
      It would take dozens of plugging/unpuggling cycles for the keyboard to
      be recognized. Keyboard seems to simply work after applying this quirk.
      
      This issue had been reported by users in two places already ([1], [2])
      but nobody tried upstreaming a patch yet. After testing I believe their
      suggested fix (DELAY_INIT + NO_LPM + DEVICE_QUALIFIER) was probably a
      little overkill. I assume this particular combination was tested because
      it had been previously suggested in [3], but only NO_LPM seems
      sufficient for this device.
      
      [1]: https://qiita.com/float168/items/fed43d540c8e2201b543
      [2]: https://blog.kostic.dev/posts/making-the-realforce-87ub-work-with-usb30-on-Ubuntu/
      [3]: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1678477
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarNicolas Dumazet <ndumazet@google.com>
      Link: https://lore.kernel.org/r/20221109122946.706036-1-ndumazet@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f7b525b7
    • Reinhard Speyerer's avatar
      USB: serial: option: add Fibocom FM160 0x0111 composition · b63ddd89
      Reinhard Speyerer authored
      commit 148f4b32
      
       upstream.
      
      Add support for the following Fibocom FM160 composition:
      
      0x0111: MBIM + MODEM + DIAG + AT
      
      T:  Bus=01 Lev=02 Prnt=125 Port=01 Cnt=02 Dev#= 93 Spd=480  MxCh= 0
      D:  Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
      P:  Vendor=2cb7 ProdID=0111 Rev= 5.04
      S:  Manufacturer=Fibocom
      S:  Product=Fibocom FM160 Modem_SN:12345678
      S:  SerialNumber=12345678
      C:* #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=500mA
      A:  FirstIf#= 0 IfCount= 2 Cls=02(comm.) Sub=0e Prot=00
      I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0e Prot=00 Driver=cdc_mbim
      E:  Ad=81(I) Atr=03(Int.) MxPS=  64 Ivl=32ms
      I:  If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
      I:* If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
      E:  Ad=8e(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=0f(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option
      E:  Ad=83(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
      E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option
      E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option
      E:  Ad=86(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
      E:  Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      
      Signed-off-by: default avatarReinhard Speyerer <rspmn@arcor.de>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b63ddd89
    • Davide Tronchin's avatar
      USB: serial: option: add u-blox LARA-L6 modem · a13aff4d
      Davide Tronchin authored
      commit c1547f12
      
       upstream.
      
      Add LARA-L6 PIDs for three different USB compositions.
      
      LARA-L6 module can be configured (by AT interface) in three different
      USB modes:
      * Default mode (Vendor ID: 0x1546 Product ID: 0x1341) with 4 serial
      interfaces
      * RmNet mode (Vendor ID: 0x1546 Product ID: 0x1342) with 4 serial
      interfaces and 1 RmNet virtual network interface
      * CDC-ECM mode (Vendor ID: 0x1546 Product ID: 0x1343) with 4 serial
      interface and 1 CDC-ECM virtual network interface
      
      In default mode LARA-L6 exposes the following interfaces:
      If 0: Diagnostic
      If 1: AT parser
      If 2: AT parser
      If 3: AT parser/alternative functions
      
      In RmNet mode LARA-L6 exposes the following interfaces:
      If 0: Diagnostic
      If 1: AT parser
      If 2: AT parser
      If 3: AT parset/alternative functions
      If 4: RMNET interface
      
      In CDC-ECM mode LARA-L6 exposes the following interfaces:
      If 0: Diagnostic
      If 1: AT parser
      If 2: AT parser
      If 3: AT parset/alternative functions
      If 4: CDC-ECM interface
      
      Signed-off-by: default avatarDavide Tronchin <davide.tronchin.94@gmail.com>
      [ johan: drop PID defines in favour of comments ]
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a13aff4d
    • Davide Tronchin's avatar
      USB: serial: option: add u-blox LARA-R6 00B modem · 1b78c81d
      Davide Tronchin authored
      commit d9e37a5c
      
       upstream.
      
      The official LARA-R6 (00B) modem uses 0x908b PID. LARA-R6 00B does not
      implement a QMI interface on port 4, the reservation (RSVD(4)) has been
      added to meet other companies that implement QMI on that interface.
      
      LARA-R6 00B USB composition exposes the following interfaces:
      If 0: Diagnostic
      If 1: AT parser
      If 2: AT parser
      If 3: AT parser/alternative functions
      
      Signed-off-by: default avatarDavide Tronchin <davide.tronchin.94@gmail.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1b78c81d
    • Davide Tronchin's avatar
      USB: serial: option: remove old LARA-R6 PID · 2194406c
      Davide Tronchin authored
      commit 2ec106b9
      
       upstream.
      
      Remove the UBLOX_PRODUCT_R6XX 0x90fa association since LARA-R6 00B final
      product uses a new USB composition with different PID. 0x90fa PID used
      only by LARA-R6 internal prototypes.
      
      Move 0x90fa PID directly in the option_ids array since used by other
      Qualcomm based modem vendors as pointed out in:
      
        https://lore.kernel.org/all/6572c4e6-d8bc-b8d3-4396-d879e4e76338@gmail.com
      
      Signed-off-by: default avatarDavide Tronchin <davide.tronchin.94@gmail.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2194406c
    • Benoît Monin's avatar
      USB: serial: option: add Sierra Wireless EM9191 · 2cae18ab
      Benoît Monin authored
      commit df3414b0 upstream.
      
      Add support for the AT and diag ports, similar to other qualcomm SDX55
      modems. In QDL mode, the modem uses a different device ID and support
      is provided by qcserial in commit 11c52d25
      
       ("USB: serial: qcserial:
      add EM9191 QDL support").
      
      T:  Bus=08 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  3 Spd=5000 MxCh= 0
      D:  Ver= 3.20 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs=  1
      P:  Vendor=1199 ProdID=90d3 Rev=00.06
      S:  Manufacturer=Sierra Wireless, Incorporated
      S:  Product=Sierra Wireless EM9191
      S:  SerialNumber=xxxxxxxxxxxxxxxx
      C:  #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=896mA
      I:  If#=0x0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0e Prot=00 Driver=cdc_mbim
      I:  If#=0x1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
      I:  If#=0x3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
      I:  If#=0x4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=(none)
      
      Signed-off-by: default avatarBenoît Monin <benoit.monin@gmx.fr>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2cae18ab
    • Takashi Iwai's avatar
      ALSA: usb-audio: Drop snd_BUG_ON() from snd_usbmidi_output_open() · 872c9314
      Takashi Iwai authored
      commit ad72c3c3
      
       upstream.
      
      snd_usbmidi_output_open() has a check of the NULL port with
      snd_BUG_ON().  snd_BUG_ON() was used as this shouldn't have happened,
      but in reality, the NULL port may be seen when the device gives an
      invalid endpoint setup at the descriptor, hence the driver skips the
      allocation.  That is, the check itself is valid and snd_BUG_ON()
      should be dropped from there.  Otherwise it's confusing as if it were
      a real bug, as recently syzbot stumbled on it.
      
      Reported-by: default avatar <syzbot+9abda841d636d86c41da@syzkaller.appspotmail.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/syzbot+9abda841d636d86c41da@syzkaller.appspotmail.com
      Link: https://lore.kernel.org/r/20221112141223.6144-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      872c9314
    • Daniil Tatianin's avatar
      ring_buffer: Do not deactivate non-existant pages · f2302d65
      Daniil Tatianin authored
      commit 56f4ca0a upstream.
      
      rb_head_page_deactivate() expects cpu_buffer to contain a valid list of
      ->pages, so verify that the list is actually present before calling it.
      
      Found by Linux Verification Center (linuxtesting.org) with the SVACE
      static analysis tool.
      
      Link: https://lkml.kernel.org/r/20221114143129.3534443-1-d-tatianin@yandex-team.ru
      
      Cc: stable@vger.kernel.org
      Fixes: 77ae365e
      
       ("ring-buffer: make lockless")
      Signed-off-by: default avatarDaniil Tatianin <d-tatianin@yandex-team.ru>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f2302d65
    • Wang Wensheng's avatar
      ftrace: Optimize the allocation for mcount entries · f58d6876
      Wang Wensheng authored
      commit bcea02b0 upstream.
      
      If we can't allocate this size, try something smaller with half of the
      size. Its order should be decreased by one instead of divided by two.
      
      Link: https://lkml.kernel.org/r/20221109094434.84046-3-wangwensheng4@huawei.com
      
      Cc: <mhiramat@kernel.org>
      Cc: <mark.rutland@arm.com>
      Cc: stable@vger.kernel.org
      Fixes: a7900875
      
       ("ftrace: Allocate the mcount record pages as groups")
      Signed-off-by: default avatarWang Wensheng <wangwensheng4@huawei.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f58d6876
    • Wang Wensheng's avatar
      ftrace: Fix the possible incorrect kernel message · 763a0999
      Wang Wensheng authored
      commit 08948cae upstream.
      
      If the number of mcount entries is an integer multiple of
      ENTRIES_PER_PAGE, the page count showing on the console would be wrong.
      
      Link: https://lkml.kernel.org/r/20221109094434.84046-2-wangwensheng4@huawei.com
      
      Cc: <mhiramat@kernel.org>
      Cc: <mark.rutland@arm.com>
      Cc: stable@vger.kernel.org
      Fixes: 5821e1b7
      
       ("function tracing: fix wrong pos computing when read buffer has been fulfilled")
      Signed-off-by: default avatarWang Wensheng <wangwensheng4@huawei.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      763a0999
    • Zhang Xiaoxu's avatar
      cifs: Fix wrong return value checking when GETFLAGS · d7bbdb3a
      Zhang Xiaoxu authored
      [ Upstream commit 92bbd67a ]
      
      The return value of CIFSGetExtAttr is negative, should be checked
      with -EOPNOTSUPP rather than EOPNOTSUPP.
      
      Fixes: 64a5cfa6
      
       ("Allow setting per-file compression via SMB2/3")
      Signed-off-by: default avatarZhang Xiaoxu <zhangxiaoxu5@huawei.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d7bbdb3a
    • Wei Yongjun's avatar
      net/x25: Fix skb leak in x25_lapb_receive_frame() · fda0ba7c
      Wei Yongjun authored
      [ Upstream commit 2929cceb ]
      
      x25_lapb_receive_frame() using skb_copy() to get a private copy of
      skb, the new skb should be freed in the undersized/fragmented skb
      error handling path. Otherwise there is a memory leak.
      
      Fixes: cb101ed2
      
       ("x25: Handle undersized/fragmented skbs")
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Acked-by: default avatarMartin Schiller <ms@dev.tdt.de>
      Link: https://lore.kernel.org/r/20221114110519.514538-1-weiyongjun@huaweicloud.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fda0ba7c
    • Yang Yingliang's avatar
      xen/pcpu: fix possible memory leak in register_pcpu() · ccb22c87
      Yang Yingliang authored
      [ Upstream commit da36a2a7 ]
      
      In device_add(), dev_set_name() is called to allocate name, if it returns
      error, the name need be freed. As comment of device_register() says, it
      should use put_device() to give up the reference in the error path. So fix
      this by calling put_device(), then the name can be freed in kobject_cleanup().
      
      Fixes: f65c9bb3
      
       ("xen/pcpu: Xen physical cpus online/offline sys interface")
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Link: https://lore.kernel.org/r/20221110152441.401630-1-yangyingliang@huawei.com
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ccb22c87
    • Zhengchao Shao's avatar
      net: caif: fix double disconnect client in chnl_net_open() · 688a5d8e
      Zhengchao Shao authored
      [ Upstream commit 8fbb53c8 ]
      
      When connecting to client timeout, disconnect client for twice in
      chnl_net_open(). Remove one. Compile tested only.
      
      Fixes: 2aa40aef
      
       ("caif: Use link layer MTU instead of fixed MTU")
      Signed-off-by: default avatarZhengchao Shao <shaozhengchao@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      688a5d8e
    • Wang ShaoBo's avatar
      mISDN: fix misuse of put_device() in mISDN_register_device() · 44658d65
      Wang ShaoBo authored
      [ Upstream commit 2d25107e ]
      
      We should not release reference by put_device() before calling device_initialize().
      
      Fixes: e7d1d4d9
      
       ("mISDN: fix possible memory leak in mISDN_register_device()")
      Signed-off-by: default avatarWang ShaoBo <bobo.shaobowang@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      44658d65
    • Yang Yingliang's avatar
      mISDN: fix possible memory leak in mISDN_dsp_element_register() · bbd53d05
      Yang Yingliang authored
      [ Upstream commit 98a2ac1c ]
      
      Afer commit 1fa5ae85 ("driver core: get rid of struct device's
      bus_id string array"), the name of device is allocated dynamically,
      use put_device() to give up the reference, so that the name can be
      freed in kobject_cleanup() when the refcount is 0.
      
      The 'entry' is going to be freed in mISDN_dsp_dev_release(), so the
      kfree() is removed. list_del() is called in mISDN_dsp_dev_release(),
      so it need be initialized.
      
      Fixes: 1fa5ae85
      
       ("driver core: get rid of struct device's bus_id string array")
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Link: https://lore.kernel.org/r/20221109132832.3270119-1-yangyingliang@huawei.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bbd53d05
    • Zeng Heng's avatar
      pinctrl: devicetree: fix null pointer dereferencing in pinctrl_dt_to_map · aaf552c5
      Zeng Heng authored
      [ Upstream commit 91d5c506 ]
      
      Here is the BUG report by KASAN about null pointer dereference:
      
      BUG: KASAN: null-ptr-deref in strcmp+0x2e/0x50
      Read of size 1 at addr 0000000000000000 by task python3/2640
      Call Trace:
       strcmp
       __of_find_property
       of_find_property
       pinctrl_dt_to_map
      
      kasprintf() would return NULL pointer when kmalloc() fail to allocate.
      So directly return ENOMEM, if kasprintf() return NULL pointer.
      
      Fixes: 57291ce2
      
       ("pinctrl: core device tree mapping table parsing support")
      Signed-off-by: default avatarZeng Heng <zengheng4@huawei.com>
      Link: https://lore.kernel.org/r/20221110082056.2014898-1-zengheng4@huawei.com
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      aaf552c5
    • Maciej W. Rozycki's avatar
      parport_pc: Avoid FIFO port location truncation · ab736e44
      Maciej W. Rozycki authored
      [ Upstream commit ab126f51
      
       ]
      
      Match the data type of a temporary holding a reference to the FIFO port
      with the type of the original reference coming from `struct parport',
      avoiding data truncation with LP64 ports such as SPARC64 that refer to
      PCI port I/O locations via their corresponding MMIO addresses and will
      therefore have non-zero bits in the high 32-bit part of the reference.
      And in any case it is cleaner to have the data types matching here.
      
      Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Link: https://lore.kernel.org/linux-pci/20220419033752.GA1101844@bhelgaas/
      Acked-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Link: https://lore.kernel.org/r/alpine.DEB.2.21.2209231912550.29493@angie.orcam.me.uk
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ab736e44
    • Chen Zhongjin's avatar
      ASoC: soc-utils: Remove __exit for snd_soc_util_exit() · 0363f587
      Chen Zhongjin authored
      [ Upstream commit 314d34fe ]
      
      snd_soc_util_exit() is called in __init snd_soc_init() for cleanup.
      Remove the __exit annotation for it to fix the build warning:
      
      WARNING: modpost: sound/soc/snd-soc-core.o: section mismatch in reference: init_module (section: .init.text) -> snd_soc_util_exit (section: .exit.text)
      
      Fixes: 6ec27c53
      
       ("ASoC: core: Fix use-after-free in snd_soc_exit()")
      Signed-off-by: default avatarChen Zhongjin <chenzhongjin@huawei.com>
      Link: https://lore.kernel.org/r/20221031134031.256511-1-chenzhongjin@huawei.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0363f587
    • Duoming Zhou's avatar
      tty: n_gsm: fix sleep-in-atomic-context bug in gsm_control_send · b27e7519
      Duoming Zhou authored
      [ Upstream commit 7b7dfe48 ]
      
      The function gsm_dlci_t1() is a timer handler that runs in an
      atomic context, but it calls "kzalloc(..., GFP_KERNEL)" that
      may sleep. As a result, the sleep-in-atomic-context bug will
      happen. The process is shown below:
      
      gsm_dlci_t1()
       gsm_dlci_open()
        gsm_modem_update()
         gsm_modem_upd_via_msc()
          gsm_control_send()
           kzalloc(sizeof(.., GFP_KERNEL) //may sleep
      
      This patch changes the gfp_t parameter of kzalloc() from GFP_KERNEL to
      GFP_ATOMIC in order to mitigate the bug.
      
      Fixes: e1eaea46
      
       ("tty: n_gsm line discipline")
      Signed-off-by: default avatarDuoming Zhou <duoming@zju.edu.cn>
      Link: https://lore.kernel.org/r/20221002040709.27849-1-duoming@zju.edu.cn
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b27e7519
    • Tony Lindgren's avatar
      serial: 8250: omap: Flush PM QOS work on remove · 72a59786
      Tony Lindgren authored
      [ Upstream commit d0b68629 ]
      
      Rebinding 8250_omap in a loop will at some point produce a warning for
      kernel/power/qos.c:296 cpu_latency_qos_update_request() with error
      "cpu_latency_qos_update_request called for unknown object". Let's flush
      the possibly pending PM QOS work scheduled from omap8250_runtime_suspend()
      before we disable runtime PM.
      
      Fixes: 61929cf0
      
       ("tty: serial: Add 8250-core based omap driver")
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Link: https://lore.kernel.org/r/20221028110044.54719-1-tony@atomide.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      72a59786
    • Matthias Schiffer's avatar
      serial: 8250_omap: remove wait loop from Errata i202 workaround · 222ab129
      Matthias Schiffer authored
      [ Upstream commit e828e566 ]
      
      We were occasionally seeing the "Errata i202: timedout" on an AM335x
      board when repeatedly opening and closing a UART connected to an active
      sender. As new input may arrive at any time, it is possible to miss the
      "RX FIFO empty" condition, forcing the loop to wait until it times out.
      
      Nothing in the i202 Advisory states that such a wait is even necessary;
      other FIFO clear functions like serial8250_clear_fifos() do not wait
      either. For this reason, it seems safe to remove the wait, fixing the
      mentioned issue.
      
      Fixes: 61929cf0
      
       ("tty: serial: Add 8250-core based omap driver")
      Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
      Signed-off-by: default avatarMatthias Schiffer <matthias.schiffer@ew.tq-group.com>
      Link: https://lore.kernel.org/r/20221013112339.2540767-1-matthias.schiffer@ew.tq-group.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      222ab129
    • Chen Zhongjin's avatar
      ASoC: core: Fix use-after-free in snd_soc_exit() · 41fad4f7
      Chen Zhongjin authored
      [ Upstream commit 6ec27c53 ]
      
      KASAN reports a use-after-free:
      
      BUG: KASAN: use-after-free in device_del+0xb5b/0xc60
      Read of size 8 at addr ffff888008655050 by task rmmod/387
      CPU: 2 PID: 387 Comm: rmmod
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)
      Call Trace:
      <TASK>
      dump_stack_lvl+0x79/0x9a
      print_report+0x17f/0x47b
      kasan_report+0xbb/0xf0
      device_del+0xb5b/0xc60
      platform_device_del.part.0+0x24/0x200
      platform_device_unregister+0x2e/0x40
      snd_soc_exit+0xa/0x22 [snd_soc_core]
      __do_sys_delete_module.constprop.0+0x34f/0x5b0
      do_syscall_64+0x3a/0x90
      entry_SYSCALL_64_after_hwframe+0x63/0xcd
      ...
      </TASK>
      
      It's bacause in snd_soc_init(), snd_soc_util_init() is possble to fail,
      but its ret is ignored, which makes soc_dummy_dev unregistered twice.
      
      snd_soc_init()
          snd_soc_util_init()
              platform_device_register_simple(soc_dummy_dev)
              platform_driver_register() # fail
          	platform_device_unregister(soc_dummy_dev)
          platform_driver_register() # success
      ...
      snd_soc_exit()
          snd_soc_util_exit()
          # soc_dummy_dev will be unregistered for second time
      
      To fix it, handle error and stop snd_soc_init() when util_init() fail.
      Also clean debugfs when util_init() or driver_register() fail.
      
      Fixes: fb257897
      
       ("ASoC: Work around allmodconfig failure")
      Signed-off-by: default avatarChen Zhongjin <chenzhongjin@huawei.com>
      Link: https://lore.kernel.org/r/20221028031603.59416-1-chenzhongjin@huawei.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      41fad4f7
    • Luiz Augusto von Dentz's avatar
      Bluetooth: L2CAP: Fix l2cap_global_chan_by_psm · 5f0a3904
      Luiz Augusto von Dentz authored
      [ Upstream commit f937b758
      
       ]
      
      l2cap_global_chan_by_psm shall not return fixed channels as they are not
      meant to be connected by (S)PSM.
      
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Reviewed-by: default avatarTedd Ho-Jeong An <tedd.an@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5f0a3904
    • Nathan Huckleberry's avatar
      drm/imx: imx-tve: Fix return type of imx_tve_connector_mode_valid · 1601de35
      Nathan Huckleberry authored
      [ Upstream commit fc007fb8
      
       ]
      
      The mode_valid field in drm_connector_helper_funcs is expected to be of
      type:
      enum drm_mode_status (* mode_valid) (struct drm_connector *connector,
                                           struct drm_display_mode *mode);
      
      The mismatched return type breaks forward edge kCFI since the underlying
      function definition does not match the function hook definition.
      
      The return type of imx_tve_connector_mode_valid should be changed from
      int to enum drm_mode_status.
      
      Reported-by: default avatarDan Carpenter <error27@gmail.com>
      Link: https://github.com/ClangBuiltLinux/linux/issues/1703
      Cc: llvm@lists.linux.dev
      Signed-off-by: default avatarNathan Huckleberry <nhuck@google.com>
      Reviewed-by: default avatarNathan Chancellor <nathan@kernel.org>
      Reviewed-by: default avatarFabio Estevam <festevam@gmail.com>
      Reviewed-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
      Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220913205544.155106-1-nhuck@google.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1601de35
    • Borislav Petkov's avatar
      x86/cpu: Restore AMD's DE_CFG MSR after resume · e126f71f
      Borislav Petkov authored
      commit 2632daeb upstream.
      
      DE_CFG contains the LFENCE serializing bit, restore it on resume too.
      This is relevant to older families due to the way how they do S3.
      
      Unify and correct naming while at it.
      
      Fixes: e4d0e84e
      
       ("x86/cpu/AMD: Make LFENCE a serializing instruction")
      Reported-by: default avatarAndrew Cooper <Andrew.Cooper3@citrix.com>
      Reported-by: default avatarPawan Gupta <pawan.kumar.gupta@linux.intel.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: <stable@kernel.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e126f71f
    • Tudor Ambarus's avatar
      dmaengine: at_hdmac: Check return code of dma_async_device_register · 4cfd8d53
      Tudor Ambarus authored
      commit c47e6403 upstream.
      
      dma_async_device_register() can fail, check the return code and display an
      error.
      
      Fixes: dc78baa2
      
       ("dmaengine: at_hdmac: new driver for the Atmel AHB DMA Controller")
      Signed-off-by: default avatarTudor Ambarus <tudor.ambarus@microchip.com>
      Cc: stable@vger.kernel.org
      Acked-by: default avatarNicolas Ferre <nicolas.ferre@microchip.com>
      Link: https://lore.kernel.org/r/20221025090306.297886-1-tudor.ambarus@microchip.com
      Link: https://lore.kernel.org/r/20221025090306.297886-16-tudor.ambarus@microchip.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4cfd8d53