Skip to content
  1. Jan 11, 2022
    • Eric Dumazet's avatar
      sch_qfq: prevent shift-out-of-bounds in qfq_init_qdisc · d655e8f4
      Eric Dumazet authored
      commit 7d18a078 upstream.
      
      tx_queue_len can be set to ~0U, we need to be more
      careful about overflows.
      
      __fls(0) is undefined, as this report shows:
      
      UBSAN: shift-out-of-bounds in net/sched/sch_qfq.c:1430:24
      shift exponent 51770272 is too large for 32-bit type 'int'
      CPU: 0 PID: 25574 Comm: syz-executor.0 Not tainted 5.16.0-rc7-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x201/0x2d8 lib/dump_stack.c:106
       ubsan_epilogue lib/ubsan.c:151 [inline]
       __ubsan_handle_shift_out_of_bounds+0x494/0x530 lib/ubsan.c:330
       qfq_init_qdisc+0x43f/0x450 net/sched/sch_qfq.c:1430
       qdisc_create+0x895/0x1430 net/sched/sch_api.c:1253
       tc_modify_qdisc+0x9d9/0x1e20 net/sched/sch_api.c:1660
       rtnetlink_rcv_msg+0x934/0xe60 net/core/rtnetlink.c:5571
       netlink_rcv_skb+0x200/0x470 net/netlink/af_netlink.c:2496
       netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
       netlink_unicast+0x814/0x9f0 net/netlink/af_netlink.c:1345
       netlink_sendmsg+0xaea/0xe60 net/netlink/af_netlink.c:1921
       sock_sendmsg_nosec net/socket.c:704 [inline]
       sock_sendmsg net/socket.c:724 [inline]
       ____sys_sendmsg+0x5b9/0x910 net/socket.c:2409
       ___sys_sendmsg net/socket.c:2463 [inline]
       __sys_sendmsg+0x280/0x370 net/socket.c:2492
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Fixes: 462dbc91
      
       ("pkt_sched: QFQ Plus: fair-queueing service at DRR cost")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d655e8f4
    • David Ahern's avatar
      ipv6: Check attribute length for RTA_GATEWAY when deleting multipath route · 652d322a
      David Ahern authored
      commit 1ff15a71 upstream.
      
      Make sure RTA_GATEWAY for IPv6 multipath route has enough bytes to hold
      an IPv6 address.
      
      Fixes: 6b9ea5a6
      
       ("ipv6: fix multipath route replace error recovery")
      Signed-off-by: default avatarDavid Ahern <dsahern@kernel.org>
      Cc: Roopa Prabhu <roopa@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      652d322a
    • David Ahern's avatar
      ipv6: Check attribute length for RTA_GATEWAY in multipath route · 647cbb5e
      David Ahern authored
      commit 4619bcf9 upstream.
      
      Commit referenced in the Fixes tag used nla_memcpy for RTA_GATEWAY as
      does the current nla_get_in6_addr. nla_memcpy protects against accessing
      memory greater than what is in the attribute, but there is no check
      requiring the attribute to have an IPv6 address. Add it.
      
      Fixes: 51ebd318
      
       ("ipv6: add support of equal cost multipath (ECMP)")
      Signed-off-by: default avatarDavid Ahern <dsahern@kernel.org>
      Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      647cbb5e
    • Jedrzej Jagielski's avatar
      i40e: Fix incorrect netdev's real number of RX/TX queues · 3eb47187
      Jedrzej Jagielski authored
      commit e738451d upstream.
      
      There was a wrong queues representation in sysfs during
      driver's reinitialization in case of online cpus number is
      less than combined queues. It was caused by stopped
      NetworkManager, which is responsible for calling vsi_open
      function during driver's initialization.
      In specific situation (ex. 12 cpus online) there were 16 queues
      in /sys/class/net/<iface>/queues. In case of modifying queues with
      value higher, than number of online cpus, then it caused write
      errors and other errors.
      Add updating of sysfs's queues representation during driver
      initialization.
      
      Fixes: 41c445ff
      
       ("i40e: main driver core")
      Signed-off-by: default avatarLukasz Cieplicki <lukaszx.cieplicki@intel.com>
      Signed-off-by: default avatarJedrzej Jagielski <jedrzej.jagielski@intel.com>
      Tested-by: default avatarGurucharan G <gurucharanx.g@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3eb47187
    • Di Zhu's avatar
      i40e: fix use-after-free in i40e_sync_filters_subtask() · 2784cebc
      Di Zhu authored
      commit 3116f59c upstream.
      
      Using ifconfig command to delete the ipv6 address will cause
      the i40e network card driver to delete its internal mac_filter and
      i40e_service_task kernel thread will concurrently access the mac_filter.
      These two processes are not protected by lock
      so causing the following use-after-free problems.
      
       print_address_description+0x70/0x360
       ? vprintk_func+0x5e/0xf0
       kasan_report+0x1b2/0x330
       i40e_sync_vsi_filters+0x4f0/0x1850 [i40e]
       i40e_sync_filters_subtask+0xe3/0x130 [i40e]
       i40e_service_task+0x195/0x24c0 [i40e]
       process_one_work+0x3f5/0x7d0
       worker_thread+0x61/0x6c0
       ? process_one_work+0x7d0/0x7d0
       kthread+0x1c3/0x1f0
       ? kthread_park+0xc0/0xc0
       ret_from_fork+0x35/0x40
      
      Allocated by task 2279810:
       kasan_kmalloc+0xa0/0xd0
       kmem_cache_alloc_trace+0xf3/0x1e0
       i40e_add_filter+0x127/0x2b0 [i40e]
       i40e_add_mac_filter+0x156/0x190 [i40e]
       i40e_addr_sync+0x2d/0x40 [i40e]
       __hw_addr_sync_dev+0x154/0x210
       i40e_set_rx_mode+0x6d/0xf0 [i40e]
       __dev_set_rx_mode+0xfb/0x1f0
       __dev_mc_add+0x6c/0x90
       igmp6_group_added+0x214/0x230
       __ipv6_dev_mc_inc+0x338/0x4f0
       addrconf_join_solict.part.7+0xa2/0xd0
       addrconf_dad_work+0x500/0x980
       process_one_work+0x3f5/0x7d0
       worker_thread+0x61/0x6c0
       kthread+0x1c3/0x1f0
       ret_from_fork+0x35/0x40
      
      Freed by task 2547073:
       __kasan_slab_free+0x130/0x180
       kfree+0x90/0x1b0
       __i40e_del_filter+0xa3/0xf0 [i40e]
       i40e_del_mac_filter+0xf3/0x130 [i40e]
       i40e_addr_unsync+0x85/0xa0 [i40e]
       __hw_addr_sync_dev+0x9d/0x210
       i40e_set_rx_mode+0x6d/0xf0 [i40e]
       __dev_set_rx_mode+0xfb/0x1f0
       __dev_mc_del+0x69/0x80
       igmp6_group_dropped+0x279/0x510
       __ipv6_dev_mc_dec+0x174/0x220
       addrconf_leave_solict.part.8+0xa2/0xd0
       __ipv6_ifa_notify+0x4cd/0x570
       ipv6_ifa_notify+0x58/0x80
       ipv6_del_addr+0x259/0x4a0
       inet6_addr_del+0x188/0x260
       addrconf_del_ifaddr+0xcc/0x130
       inet6_ioctl+0x152/0x190
       sock_do_ioctl+0xd8/0x2b0
       sock_ioctl+0x2e5/0x4c0
       do_vfs_ioctl+0x14e/0xa80
       ksys_ioctl+0x7c/0xa0
       __x64_sys_ioctl+0x42/0x50
       do_syscall_64+0x98/0x2c0
       entry_SYSCALL_64_after_hwframe+0x65/0xca
      
      Fixes: 41c445ff
      
       ("i40e: main driver core")
      Signed-off-by: default avatarDi Zhu <zhudi2@huawei.com>
      Signed-off-by: default avatarRui Zhang <zhangrui182@huawei.com>
      Tested-by: default avatarGurucharan G <gurucharanx.g@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2784cebc
    • Tom Rix's avatar
      mac80211: initialize variable have_higher_than_11mbit · 11b3880b
      Tom Rix authored
      commit 68a18ad7 upstream.
      
      Clang static analysis reports this warnings
      
      mlme.c:5332:7: warning: Branch condition evaluates to a
        garbage value
          have_higher_than_11mbit)
          ^~~~~~~~~~~~~~~~~~~~~~~
      
      have_higher_than_11mbit is only set to true some of the time in
      ieee80211_get_rates() but is checked all of the time.  So
      have_higher_than_11mbit needs to be initialized to false.
      
      Fixes: 5d6a1b06
      
       ("mac80211: set basic rates earlier")
      Signed-off-by: default avatarTom Rix <trix@redhat.com>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Link: https://lore.kernel.org/r/20211223162848.3243702-1-trix@redhat.com
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      11b3880b
    • Leon Romanovsky's avatar
      RDMA/core: Don't infoleak GRH fields · 50ef6d3c
      Leon Romanovsky authored
      commit b35a0f4d upstream.
      
      If dst->is_global field is not set, the GRH fields are not cleared
      and the following infoleak is reported.
      
      =====================================================
      BUG: KMSAN: kernel-infoleak in instrument_copy_to_user include/linux/instrumented.h:121 [inline]
      BUG: KMSAN: kernel-infoleak in _copy_to_user+0x1c9/0x270 lib/usercopy.c:33
       instrument_copy_to_user include/linux/instrumented.h:121 [inline]
       _copy_to_user+0x1c9/0x270 lib/usercopy.c:33
       copy_to_user include/linux/uaccess.h:209 [inline]
       ucma_init_qp_attr+0x8c7/0xb10 drivers/infiniband/core/ucma.c:1242
       ucma_write+0x637/0x6c0 drivers/infiniband/core/ucma.c:1732
       vfs_write+0x8ce/0x2030 fs/read_write.c:588
       ksys_write+0x28b/0x510 fs/read_write.c:643
       __do_sys_write fs/read_write.c:655 [inline]
       __se_sys_write fs/read_write.c:652 [inline]
       __ia32_sys_write+0xdb/0x120 fs/read_write.c:652
       do_syscall_32_irqs_on arch/x86/entry/common.c:114 [inline]
       __do_fast_syscall_32+0x96/0xf0 arch/x86/entry/common.c:180
       do_fast_syscall_32+0x34/0x70 arch/x86/entry/common.c:205
       do_SYSENTER_32+0x1b/0x20 arch/x86/entry/common.c:248
       entry_SYSENTER_compat_after_hwframe+0x4d/0x5c
      
      Local variable resp created at:
       ucma_init_qp_attr+0xa4/0xb10 drivers/infiniband/core/ucma.c:1214
       ucma_write+0x637/0x6c0 drivers/infiniband/core/ucma.c:1732
      
      Bytes 40-59 of 144 are uninitialized
      Memory access of size 144 starts at ffff888167523b00
      Data copied to user address 0000000020000100
      
      CPU: 1 PID: 25910 Comm: syz-executor.1 Not tainted 5.16.0-rc5-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      =====================================================
      
      Fixes: 4ba66093
      
       ("IB/core: Check for global flag when using ah_attr")
      Link: https://lore.kernel.org/r/0e9dd51f93410b7b2f4f5562f52befc878b71afa.1641298868.git.leonro@nvidia.com
      Reported-by: default avatar <syzbot+6d532fa8f9463da290bc@syzkaller.appspotmail.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      50ef6d3c
    • Pavel Skripkin's avatar
      ieee802154: atusb: fix uninit value in atusb_set_extended_addr · 94c035d9
      Pavel Skripkin authored
      commit 754e4382 upstream.
      
      Alexander reported a use of uninitialized value in
      atusb_set_extended_addr(), that is caused by reading 0 bytes via
      usb_control_msg().
      
      Fix it by validating if the number of bytes transferred is actually
      correct, since usb_control_msg() may read less bytes, than was requested
      by caller.
      
      Fail log:
      
      BUG: KASAN: uninit-cmp in ieee802154_is_valid_extended_unicast_addr include/linux/ieee802154.h:310 [inline]
      BUG: KASAN: uninit-cmp in atusb_set_extended_addr drivers/net/ieee802154/atusb.c:1000 [inline]
      BUG: KASAN: uninit-cmp in atusb_probe.cold+0x29f/0x14db drivers/net/ieee802154/atusb.c:1056
      Uninit value used in comparison: 311daa649a2003bd stack handle: 000000009a2003bd
       ieee802154_is_valid_extended_unicast_addr include/linux/ieee802154.h:310 [inline]
       atusb_set_extended_addr drivers/net/ieee802154/atusb.c:1000 [inline]
       atusb_probe.cold+0x29f/0x14db drivers/net/ieee802154/atusb.c:1056
       usb_probe_interface+0x314/0x7f0 drivers/usb/core/driver.c:396
      
      Fixes: 7490b008
      
       ("ieee802154: add support for atusb transceiver")
      Reported-by: default avatarAlexander Potapenko <glider@google.com>
      Acked-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Link: https://lore.kernel.org/r/20220104182806.7188-1-paskripkin@gmail.com
      Signed-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      94c035d9
    • Parav Pandit's avatar
      virtio_pci: Support surprise removal of virtio pci device · 3b74cb45
      Parav Pandit authored
      commit 43bb40c5
      
       upstream.
      
      When a virtio pci device undergo surprise removal (aka async removal in
      PCIe spec), mark the device as broken so that any upper layer drivers can
      abort any outstanding operation.
      
      When a virtio net pci device undergo surprise removal which is used by a
      NetworkManager, a below call trace was observed.
      
      kernel:watchdog: BUG: soft lockup - CPU#1 stuck for 26s! [kworker/1:1:27059]
      watchdog: BUG: soft lockup - CPU#1 stuck for 52s! [kworker/1:1:27059]
      CPU: 1 PID: 27059 Comm: kworker/1:1 Tainted: G S      W I  L    5.13.0-hotplug+ #8
      Hardware name: Dell Inc. PowerEdge R640/0H28RR, BIOS 2.9.4 11/06/2020
      Workqueue: events linkwatch_event
      RIP: 0010:virtnet_send_command+0xfc/0x150 [virtio_net]
      Call Trace:
       virtnet_set_rx_mode+0xcf/0x2a7 [virtio_net]
       ? __hw_addr_create_ex+0x85/0xc0
       __dev_mc_add+0x72/0x80
       igmp6_group_added+0xa7/0xd0
       ipv6_mc_up+0x3c/0x60
       ipv6_find_idev+0x36/0x80
       addrconf_add_dev+0x1e/0xa0
       addrconf_dev_config+0x71/0x130
       addrconf_notify+0x1f5/0xb40
       ? rtnl_is_locked+0x11/0x20
       ? __switch_to_asm+0x42/0x70
       ? finish_task_switch+0xaf/0x2c0
       ? raw_notifier_call_chain+0x3e/0x50
       raw_notifier_call_chain+0x3e/0x50
       netdev_state_change+0x67/0x90
       linkwatch_do_dev+0x3c/0x50
       __linkwatch_run_queue+0xd2/0x220
       linkwatch_event+0x21/0x30
       process_one_work+0x1c8/0x370
       worker_thread+0x30/0x380
       ? process_one_work+0x370/0x370
       kthread+0x118/0x140
       ? set_kthread_struct+0x40/0x40
       ret_from_fork+0x1f/0x30
      
      Hence, add the ability to abort the command on surprise removal
      which prevents infinite loop and system lockup.
      
      Signed-off-by: default avatarParav Pandit <parav@nvidia.com>
      Link: https://lore.kernel.org/r/20210721142648.1525924-5-parav@nvidia.com
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarYang Wei <yang.wei@linux.alibaba.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3b74cb45
    • Naveen N. Rao's avatar
      tracing: Tag trace_percpu_buffer as a percpu pointer · ec5f1f44
      Naveen N. Rao authored
      commit f28439db
      
       upstream.
      
      Tag trace_percpu_buffer as a percpu pointer to resolve warnings
      reported by sparse:
        /linux/kernel/trace/trace.c:3218:46: warning: incorrect type in initializer (different address spaces)
        /linux/kernel/trace/trace.c:3218:46:    expected void const [noderef] __percpu *__vpp_verify
        /linux/kernel/trace/trace.c:3218:46:    got struct trace_buffer_struct *
        /linux/kernel/trace/trace.c:3234:9: warning: incorrect type in initializer (different address spaces)
        /linux/kernel/trace/trace.c:3234:9:    expected void const [noderef] __percpu *__vpp_verify
        /linux/kernel/trace/trace.c:3234:9:    got int *
      
      Link: https://lkml.kernel.org/r/ebabd3f23101d89cb75671b68b6f819f5edc830b.1640255304.git.naveen.n.rao@linux.vnet.ibm.com
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Fixes: 07d777fe
      
       ("tracing: Add percpu buffers for trace_printk()")
      Signed-off-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ec5f1f44
    • Naveen N. Rao's avatar
      tracing: Fix check for trace_percpu_buffer validity in get_trace_buf() · 294e5ae1
      Naveen N. Rao authored
      commit 823e670f upstream.
      
      With the new osnoise tracer, we are seeing the below splat:
          Kernel attempted to read user page (c7d880000) - exploit attempt? (uid: 0)
          BUG: Unable to handle kernel data access on read at 0xc7d880000
          Faulting instruction address: 0xc0000000002ffa10
          Oops: Kernel access of bad area, sig: 11 [#1]
          LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries
          ...
          NIP [c0000000002ffa10] __trace_array_vprintk.part.0+0x70/0x2f0
          LR [c0000000002ff9fc] __trace_array_vprintk.part.0+0x5c/0x2f0
          Call Trace:
          [c0000008bdd73b80] [c0000000001c49cc] put_prev_task_fair+0x3c/0x60 (unreliable)
          [c0000008bdd73be0] [c000000000301430] trace_array_printk_buf+0x70/0x90
          [c0000008bdd73c00] [c0000000003178b0] trace_sched_switch_callback+0x250/0x290
          [c0000008bdd73c90] [c000000000e70d60] __schedule+0x410/0x710
          [c0000008bdd73d40] [c000000000e710c0] schedule+0x60/0x130
          [c0000008bdd73d70] [c000000000030614] interrupt_exit_user_prepare_main+0x264/0x270
          [c0000008bdd73de0] [c000000000030a70] syscall_exit_prepare+0x150/0x180
          [c0000008bdd73e10] [c00000000000c174] system_call_vectored_common+0xf4/0x278
      
      osnoise tracer on ppc64le is triggering osnoise_taint() for negative
      duration in get_int_safe_duration() called from
      trace_sched_switch_callback()->thread_exit().
      
      The problem though is that the check for a valid trace_percpu_buffer is
      incorrect in get_trace_buf(). The check is being done after calculating
      the pointer for the current cpu, rather than on the main percpu pointer.
      Fix the check to be against trace_percpu_buffer.
      
      Link: https://lkml.kernel.org/r/a920e4272e0b0635cf20c444707cbce1b2c8973d.1640255304.git.naveen.n.rao@linux.vnet.ibm.com
      
      Cc: stable@vger.kernel.org
      Fixes: e2ace001
      
       ("tracing: Choose static tp_printk buffer by explicit nesting count")
      Signed-off-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      294e5ae1
    • Takashi Iwai's avatar
      Bluetooth: btusb: Apply QCA Rome patches for some ATH3012 models · b428e312
      Takashi Iwai authored
      commit 803cdb8c upstream.
      
      In commit f44cb4b1 ("Bluetooth: btusb: Fix quirk for Atheros
      1525/QCA6174") we tried to address the non-working Atheros BT devices
      by changing the quirk from BTUSB_ATH3012 to BTUSB_QCA_ROME.  This made
      such devices working while it turned out to break other existing chips
      with the very same USB ID, hence it was reverted afterwards.
      
      This is another attempt to tackle the issue.  The essential point to
      use BTUSB_QCA_ROME is to apply the btusb_setup_qca() and do RAM-
      patching.  And the previous attempt failed because btusb_setup_qca()
      returns -ENODEV if the ROM version doesn't match with the expected
      ones.  For some devices that have already the "correct" ROM versions,
      we may just skip the setup procedure and continue the rest.
      
      So, the first fix we'll need is to add a check of the ROM version in
      the function to skip the setup if the ROM version looks already sane,
      so that it can be applied for all ath devices.
      
      However, the world is a bit more complex than that simple solution.
      Since BTUSB_ATH3012 quirk checks the bcdDevice and bails out when it's
      0x0001 at the beginning of probing, so the device probe always aborts
      here.
      
      In this patch, we add another check of ROM version again, and if the
      device needs patching, the probe continues.  For that, a slight
      refactoring of btusb_qca_send_vendor_req() was required so that the
      probe function can pass usb_device pointer directly before allocating
      hci_dev stuff.
      
      Fixes: commit f44cb4b1
      
       ("Bluetooth: btusb: Fix quirk for Atheros 1525/QCA6174")
      Bugzilla: http://bugzilla.opensuse.org/show_bug.cgi?id=1082504
      Tested-by: default avatarIvan Levshin <ivan.levshin@microfocus.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b428e312
  2. Jan 05, 2022
    • Greg Kroah-Hartman's avatar
      Linux 4.14.261 · bfdef05c
      Greg Kroah-Hartman authored
      
      
      Link: https://lore.kernel.org/r/20220103142052.068378906@linuxfoundation.org
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Tested-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Tested-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Tested-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      v4.14.261
      bfdef05c
    • Xin Long's avatar
      sctp: use call_rcu to free endpoint · 8873140f
      Xin Long authored
      commit 5ec7d18d
      
       upstream.
      
      This patch is to delay the endpoint free by calling call_rcu() to fix
      another use-after-free issue in sctp_sock_dump():
      
        BUG: KASAN: use-after-free in __lock_acquire+0x36d9/0x4c20
        Call Trace:
          __lock_acquire+0x36d9/0x4c20 kernel/locking/lockdep.c:3218
          lock_acquire+0x1ed/0x520 kernel/locking/lockdep.c:3844
          __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline]
          _raw_spin_lock_bh+0x31/0x40 kernel/locking/spinlock.c:168
          spin_lock_bh include/linux/spinlock.h:334 [inline]
          __lock_sock+0x203/0x350 net/core/sock.c:2253
          lock_sock_nested+0xfe/0x120 net/core/sock.c:2774
          lock_sock include/net/sock.h:1492 [inline]
          sctp_sock_dump+0x122/0xb20 net/sctp/diag.c:324
          sctp_for_each_transport+0x2b5/0x370 net/sctp/socket.c:5091
          sctp_diag_dump+0x3ac/0x660 net/sctp/diag.c:527
          __inet_diag_dump+0xa8/0x140 net/ipv4/inet_diag.c:1049
          inet_diag_dump+0x9b/0x110 net/ipv4/inet_diag.c:1065
          netlink_dump+0x606/0x1080 net/netlink/af_netlink.c:2244
          __netlink_dump_start+0x59a/0x7c0 net/netlink/af_netlink.c:2352
          netlink_dump_start include/linux/netlink.h:216 [inline]
          inet_diag_handler_cmd+0x2ce/0x3f0 net/ipv4/inet_diag.c:1170
          __sock_diag_cmd net/core/sock_diag.c:232 [inline]
          sock_diag_rcv_msg+0x31d/0x410 net/core/sock_diag.c:263
          netlink_rcv_skb+0x172/0x440 net/netlink/af_netlink.c:2477
          sock_diag_rcv+0x2a/0x40 net/core/sock_diag.c:274
      
      This issue occurs when asoc is peeled off and the old sk is freed after
      getting it by asoc->base.sk and before calling lock_sock(sk).
      
      To prevent the sk free, as a holder of the sk, ep should be alive when
      calling lock_sock(). This patch uses call_rcu() and moves sock_put and
      ep free into sctp_endpoint_destroy_rcu(), so that it's safe to try to
      hold the ep under rcu_read_lock in sctp_transport_traverse_process().
      
      If sctp_endpoint_hold() returns true, it means this ep is still alive
      and we have held it and can continue to dump it; If it returns false,
      it means this ep is dead and can be freed after rcu_read_unlock, and
      we should skip it.
      
      In sctp_sock_dump(), after locking the sk, if this ep is different from
      tsp->asoc->ep, it means during this dumping, this asoc was peeled off
      before calling lock_sock(), and the sk should be skipped; If this ep is
      the same with tsp->asoc->ep, it means no peeloff happens on this asoc,
      and due to lock_sock, no peeloff will happen either until release_sock.
      
      Note that delaying endpoint free won't delay the port release, as the
      port release happens in sctp_endpoint_destroy() before calling call_rcu().
      Also, freeing endpoint by call_rcu() makes it safe to access the sk by
      asoc->base.sk in sctp_assocs_seq_show() and sctp_rcv().
      
      Thanks Jones to bring this issue up.
      
      v1->v2:
        - improve the changelog.
        - add kfree(ep) into sctp_endpoint_destroy_rcu(), as Jakub noticed.
      
      Reported-by: default avatar <syzbot+9276d76e83e3bcde6c99@syzkaller.appspotmail.com>
      Reported-by: default avatarLee Jones <lee.jones@linaro.org>
      Fixes: d25adbeb
      
       ("sctp: fix an use-after-free issue in sctp_sock_dump")
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8873140f
    • Muchun Song's avatar
      net: fix use-after-free in tw_timer_handler · 5c2fe20a
      Muchun Song authored
      commit e22e45fc upstream.
      
      A real world panic issue was found as follow in Linux 5.4.
      
          BUG: unable to handle page fault for address: ffffde49a863de28
          PGD 7e6fe62067 P4D 7e6fe62067 PUD 7e6fe63067 PMD f51e064067 PTE 0
          RIP: 0010:tw_timer_handler+0x20/0x40
          Call Trace:
           <IRQ>
           call_timer_fn+0x2b/0x120
           run_timer_softirq+0x1ef/0x450
           __do_softirq+0x10d/0x2b8
           irq_exit+0xc7/0xd0
           smp_apic_timer_interrupt+0x68/0x120
           apic_timer_interrupt+0xf/0x20
      
      This issue was also reported since 2017 in the thread [1],
      unfortunately, the issue was still can be reproduced after fixing
      DCCP.
      
      The ipv4_mib_exit_net is called before tcp_sk_exit_batch when a net
      namespace is destroyed since tcp_sk_ops is registered befrore
      ipv4_mib_ops, which means tcp_sk_ops is in the front of ipv4_mib_ops
      in the list of pernet_list. There will be a use-after-free on
      net->mib.net_statistics in tw_timer_handler after ipv4_mib_exit_net
      if there are some inflight time-wait timers.
      
      This bug is not introduced by commit f2bf415c ("mib: add net to
      NET_ADD_STATS_BH") since the net_statistics is a global variable
      instead of dynamic allocation and freeing. Actually, commit
      61a7e260 ("mib: put net statistics on struct net") introduces
      the bug since it put net statistics on struct net and free it when
      net namespace is destroyed.
      
      Moving init_ipv4_mibs() to the front of tcp_init() to fix this bug
      and replace pr_crit() with panic() since continuing is meaningless
      when init_ipv4_mibs() fails.
      
      [1] https://groups.google.com/g/syzkaller/c/p1tn-_Kc6l4/m/smuL_FMAAgAJ?pli=1
      
      Fixes: 61a7e260
      
       ("mib: put net statistics on struct net")
      Signed-off-by: default avatarMuchun Song <songmuchun@bytedance.com>
      Cc: Cong Wang <cong.wang@bytedance.com>
      Cc: Fam Zheng <fam.zheng@bytedance.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20211228104145.9426-1-songmuchun@bytedance.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5c2fe20a
    • Leo L. Schwab's avatar
      Input: spaceball - fix parsing of movement data packets · dd57d1c7
      Leo L. Schwab authored
      commit bc7ec917
      
       upstream.
      
      The spaceball.c module was not properly parsing the movement reports
      coming from the device.  The code read axis data as signed 16-bit
      little-endian values starting at offset 2.
      
      In fact, axis data in Spaceball movement reports are signed 16-bit
      big-endian values starting at offset 3.  This was determined first by
      visually inspecting the data packets, and later verified by consulting:
      http://spacemice.org/pdf/SpaceBall_2003-3003_Protocol.pdf
      
      If this ever worked properly, it was in the time before Git...
      
      Signed-off-by: default avatarLeo L. Schwab <ewhac@ewhac.org>
      Link: https://lore.kernel.org/r/20211221101630.1146385-1-ewhac@ewhac.org
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dd57d1c7
    • Pavel Skripkin's avatar
      Input: appletouch - initialize work before device registration · 292d2ac6
      Pavel Skripkin authored
      commit 9f3ccdc3 upstream.
      
      Syzbot has reported warning in __flush_work(). This warning is caused by
      work->func == NULL, which means missing work initialization.
      
      This may happen, since input_dev->close() calls
      cancel_work_sync(&dev->work), but dev->work initalization happens _after_
      input_register_device() call.
      
      So this patch moves dev->work initialization before registering input
      device
      
      Fixes: 5a6eb676
      
       ("Input: appletouch - improve powersaving for Geyser3 devices")
      Reported-and-tested-by: default avatar <syzbot+b88c5eae27386b252bbd@syzkaller.appspotmail.com>
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Link: https://lore.kernel.org/r/20211230141151.17300-1-paskripkin@gmail.com
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      292d2ac6
    • Alexey Makhalov's avatar
      scsi: vmw_pvscsi: Set residual data length conditionally · 3efece94
      Alexey Makhalov authored
      commit 142c779d upstream.
      
      The PVSCSI implementation in the VMware hypervisor under specific
      configuration ("SCSI Bus Sharing" set to "Physical") returns zero dataLen
      in the completion descriptor for READ CAPACITY(16). As a result, the kernel
      can not detect proper disk geometry. This can be recognized by the kernel
      message:
      
        [ 0.776588] sd 1:0:0:0: [sdb] Sector size 0 reported, assuming 512.
      
      The PVSCSI implementation in QEMU does not set dataLen at all, keeping it
      zeroed. This leads to a boot hang as was reported by Shmulik Ladkani.
      
      It is likely that the controller returns the garbage at the end of the
      buffer. Residual length should be set by the driver in that case. The SCSI
      layer will erase corresponding data. See commit bdb2b8ca ("[SCSI] erase
      invalid data returned by device") for details.
      
      Commit e662502b ("scsi: vmw_pvscsi: Set correct residual data length")
      introduced the issue by setting residual length unconditionally, causing
      the SCSI layer to erase the useful payload beyond dataLen when this value
      is returned as 0.
      
      As a result, considering existing issues in implementations of PVSCSI
      controllers, we do not want to call scsi_set_resid() when dataLen ==
      0. Calling scsi_set_resid() has no effect if dataLen equals buffer length.
      
      Link: https://lore.kernel.org/lkml/20210824120028.30d9c071@blondie/
      Link: https://lore.kernel.org/r/20211220190514.55935-1-amakhalov@vmware.com
      Fixes: e662502b
      
       ("scsi: vmw_pvscsi: Set correct residual data length")
      Cc: Matt Wang <wwentao@vmware.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Vishal Bhakta <vbhakta@vmware.com>
      Cc: VMware PV-Drivers <pv-drivers@vmware.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: linux-scsi@vger.kernel.org
      Cc: stable@vger.kernel.org
      Reported-and-suggested-by: default avatarShmulik Ladkani <shmulik.ladkani@gmail.com>
      Signed-off-by: default avatarAlexey Makhalov <amakhalov@vmware.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3efece94
    • Todd Kjos's avatar
      binder: fix async_free_space accounting for empty parcels · 2d2df539
      Todd Kjos authored
      commit cfd0d84b upstream.
      
      In 4.13, commit 74310e06 ("android: binder: Move buffer out of area shared with user space")
      fixed a kernel structure visibility issue. As part of that patch,
      sizeof(void *) was used as the buffer size for 0-length data payloads so
      the driver could detect abusive clients sending 0-length asynchronous
      transactions to a server by enforcing limits on async_free_size.
      
      Unfortunately, on the "free" side, the accounting of async_free_space
      did not add the sizeof(void *) back. The result was that up to 8-bytes of
      async_free_space were leaked on every async transaction of 8-bytes or
      less.  These small transactions are uncommon, so this accounting issue
      has gone undetected for several years.
      
      The fix is to use "buffer_size" (the allocated buffer size) instead of
      "size" (the logical buffer size) when updating the async_free_space
      during the free operation. These are the same except for this
      corner case of asynchronous transactions with payloads < 8 bytes.
      
      Fixes: 74310e06
      
       ("android: binder: Move buffer out of area shared with user space")
      Signed-off-by: default avatarTodd Kjos <tkjos@google.com>
      Cc: stable@vger.kernel.org # 4.14+
      Link: https://lore.kernel.org/r/20211220190150.2107077-1-tkjos@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2d2df539
    • Vincent Pelletier's avatar
      usb: gadget: f_fs: Clear ffs_eventfd in ffs_data_clear. · 52500239
      Vincent Pelletier authored
      commit b1e08873 upstream.
      
      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.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      52500239
    • Mathias Nyman's avatar
      xhci: Fresco FL1100 controller should not have BROKEN_MSI quirk set. · 70e7f1a9
      Mathias Nyman authored
      commit e4844092 upstream.
      
      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.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      70e7f1a9
    • Dmitry V. Levin's avatar
      uapi: fix linux/nfc.h userspace compilation errors · 6456e345
      Dmitry V. Levin authored
      commit 7175f02c upstream.
      
      Replace sa_family_t with __kernel_sa_family_t to fix the following
      linux/nfc.h userspace compilation errors:
      
      /usr/include/linux/nfc.h:266:2: error: unknown type name 'sa_family_t'
        sa_family_t sa_family;
      /usr/include/linux/nfc.h:274:2: error: unknown type name 'sa_family_t'
        sa_family_t sa_family;
      
      Fixes: 23b7869c ("NFC: add the NFC socket raw protocol")
      Fixes: d646960f
      
       ("NFC: Initial LLCP support")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarDmitry V. Levin <ldv@altlinux.org>
      Reviewed-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>
      6456e345
    • Krzysztof Kozlowski's avatar
      nfc: uapi: use kernel size_t to fix user-space builds · 709a0cc0
      Krzysztof Kozlowski authored
      commit 79b69a83 upstream.
      
      Fix user-space builds if it includes /usr/include/linux/nfc.h before
      some of other headers:
      
        /usr/include/linux/nfc.h:281:9: error: unknown type name ‘size_t’
          281 |         size_t service_name_len;
              |         ^~~~~~
      
      Fixes: d646960f
      
       ("NFC: Initial LLCP support")
      Cc: <stable@vger.kernel.org>
      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>
      709a0cc0
    • Miaoqian Lin's avatar
      fsl/fman: Fix missing put_device() call in fman_port_probe · e3cccaa5
      Miaoqian Lin authored
      [ Upstream commit bf2b09fe ]
      
      The reference taken by 'of_find_device_by_node()' must be released when
      not needed anymore.
      Add the corresponding 'put_device()' in the and error handling paths.
      
      Fixes: 18a6c85f
      
       ("fsl/fman: Add FMan Port Support")
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e3cccaa5
    • Wei Yongjun's avatar
      NFC: st21nfca: Fix memory leak in device probe and remove · 38c3e320
      Wei Yongjun authored
      [ Upstream commit 1b9dadba ]
      
      'phy->pending_skb' is alloced when device probe, but forgot to free
      in the error handling path and remove path, this cause memory leak
      as follows:
      
      unreferenced object 0xffff88800bc06800 (size 512):
        comm "8", pid 11775, jiffies 4295159829 (age 9.032s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<00000000d66c09ce>] __kmalloc_node_track_caller+0x1ed/0x450
          [<00000000c93382b3>] kmalloc_reserve+0x37/0xd0
          [<000000005fea522c>] __alloc_skb+0x124/0x380
          [<0000000019f29f9a>] st21nfca_hci_i2c_probe+0x170/0x8f2
      
      Fix it by freeing 'pending_skb' in error and remove.
      
      Fixes: 68957303
      
       ("NFC: ST21NFCA: Add driver for STMicroelectronics ST21NFCA NFC Chip")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      38c3e320
    • Matthias-Christian Ott's avatar
      net: usb: pegasus: Do not drop long Ethernet frames · 5920f258
      Matthias-Christian Ott authored
      [ Upstream commit ca506fca ]
      
      The D-Link DSB-650TX (2001:4002) is unable to receive Ethernet frames
      that are longer than 1518 octets, for example, Ethernet frames that
      contain 802.1Q VLAN tags.
      
      The frames are sent to the pegasus driver via USB but the driver
      discards them because they have the Long_pkt field set to 1 in the
      received status report. The function read_bulk_callback of the pegasus
      driver treats such received "packets" (in the terminology of the
      hardware) as errors but the field simply does just indicate that the
      Ethernet frame (MAC destination to FCS) is longer than 1518 octets.
      
      It seems that in the 1990s there was a distinction between
      "giant" (> 1518) and "runt" (< 64) frames and the hardware includes
      flags to indicate this distinction. It seems that the purpose of the
      distinction "giant" frames was to not allow infinitely long frames due
      to transmission errors and to allow hardware to have an upper limit of
      the frame size. However, the hardware already has such limit with its
      2048 octet receive buffer and, therefore, Long_pkt is merely a
      convention and should not be treated as a receive error.
      
      Actually, the hardware is even able to receive Ethernet frames with 2048
      octets which exceeds the claimed limit frame size limit of the driver of
      1536 octets (PEGASUS_MTU).
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarMatthias-Christian Ott <ott@mirix.org>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5920f258
    • Dan Carpenter's avatar
      scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write() · 058a534e
      Dan Carpenter authored
      [ Upstream commit 9020be11 ]
      
      The "mybuf" string comes from the user, so we need to ensure that it is NUL
      terminated.
      
      Link: https://lore.kernel.org/r/20211214070527.GA27934@kili
      Fixes: bd2cdd5e
      
       ("scsi: lpfc: NVME Initiator: Add debugfs support")
      Reviewed-by: default avatarJames Smart <jsmart2021@gmail.com>
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      058a534e
    • Tom Rix's avatar
      selinux: initialize proto variable in selinux_ip_postroute_compat() · 8a264452
      Tom Rix authored
      commit 732bc2ff upstream.
      
      Clang static analysis reports this warning
      
      hooks.c:5765:6: warning: 4th function call argument is an uninitialized
                      value
              if (selinux_xfrm_postroute_last(sksec->sid, skb, &ad, proto))
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      selinux_parse_skb() can return ok without setting proto.  The later call
      to selinux_xfrm_postroute_last() does an early check of proto and can
      return ok if the garbage proto value matches.  So initialize proto.
      
      Cc: stable@vger.kernel.org
      Fixes: eef9b416
      
       ("selinux: cleanup selinux_xfrm_sock_rcv_skb() and selinux_xfrm_postroute_last()")
      Signed-off-by: default avatarTom Rix <trix@redhat.com>
      [PM: typo/spelling and checkpatch.pl description fixes]
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8a264452
    • Heiko Carstens's avatar
      recordmcount.pl: fix typo in s390 mcount regex · 49bcc084
      Heiko Carstens authored
      commit 4eb1782e upstream.
      
      Commit 85bf17b2
      
       ("recordmcount.pl: look for jgnop instruction as well
      as bcrl on s390") added a new alternative mnemonic for the existing brcl
      instruction. This is required for the combination old gcc version (pre 9.0)
      and binutils since version 2.37.
      However at the same time this commit introduced a typo, replacing brcl with
      bcrl. As a result no mcount locations are detected anymore with old gcc
      versions (pre 9.0) and binutils before version 2.37.
      Fix this by using the correct mnemonic again.
      
      Reported-by: default avatarMiroslav Benes <mbenes@suse.cz>
      Cc: Jerome Marchand <jmarchan@redhat.com>
      Cc: <stable@vger.kernel.org>
      Fixes: 85bf17b2
      
       ("recordmcount.pl: look for jgnop instruction as well as bcrl on s390")
      Link: https://lore.kernel.org/r/alpine.LSU.2.21.2112230949520.19849@pobox.suse.cz
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      49bcc084
    • Wang Qing's avatar
      platform/x86: apple-gmux: use resource_size() with res · 3df97bd3
      Wang Qing authored
      [ Upstream commit eb66fb03
      
       ]
      
      This should be (res->end - res->start + 1) here actually,
      use resource_size() derectly.
      
      Signed-off-by: default avatarWang Qing <wangqing@vivo.com>
      Link: https://lore.kernel.org/r/1639484316-75873-1-git-send-email-wangqing@vivo.com
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3df97bd3
    • Jens Wiklander's avatar
      tee: handle lookup of shm with reference count 0 · 3d556a28
      Jens Wiklander authored
      commit dfd0743f upstream.
      
      Since the tee subsystem does not keep a strong reference to its idle
      shared memory buffers, it races with other threads that try to destroy a
      shared memory through a close of its dma-buf fd or by unmapping the
      memory.
      
      In tee_shm_get_from_id() when a lookup in teedev->idr has been
      successful, it is possible that the tee_shm is in the dma-buf teardown
      path, but that path is blocked by the teedev mutex. Since we don't have
      an API to tell if the tee_shm is in the dma-buf teardown path or not we
      must find another way of detecting this condition.
      
      Fix this by doing the reference counting directly on the tee_shm using a
      new refcount_t refcount field. dma-buf is replaced by using
      anon_inode_getfd() instead, this separates the life-cycle of the
      underlying file from the tee_shm. tee_shm_put() is updated to hold the
      mutex when decreasing the refcount to 0 and then remove the tee_shm from
      teedev->idr before releasing the mutex. This means that the tee_shm can
      never be found unless it has a refcount larger than 0.
      
      Fixes: 967c9cca
      
       ("tee: generic TEE subsystem")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: default avatarLars Persson <larper@axis.com>
      Reviewed-by: default avatarSumit Garg <sumit.garg@linaro.org>
      Reported-by: default avatarPatrik Lantz <patrik.lantz@axis.com>
      [JW: backported to 4.14-stable]
      Signed-off-by: default avatarJens Wiklander <jens.wiklander@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3d556a28
    • Hans de Goede's avatar
      HID: asus: Add depends on USB_HID to HID_ASUS Kconfig option · 2e319767
      Hans de Goede authored
      commit c4f0126d upstream.
      
      Since commit 4bc43a42 ("HID: asus: Add
      hid_is_using_ll_driver(usb_hid_driver) check") the hid-asus.c depends
      on the usb_hid_driver symbol. Add a depends on USB_HID to Kconfig to
      fix missing symbols errors in hid-asus when USB_HID is not enabled.
      
      Fixes: 4bc43a42
      
       ("HID: asus: Add hid_is_using_ll_driver(usb_hid_driver) check")
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Cc: Jason Self <jason@bluehome.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2e319767
  3. Dec 29, 2021