Skip to content
  1. Dec 08, 2022
    • ZhangPeng's avatar
      nilfs2: fix NULL pointer dereference in nilfs_palloc_commit_free_entry() · bc3fd329
      ZhangPeng authored
      commit f0a0ccda
      
       upstream.
      
      Syzbot reported a null-ptr-deref bug:
      
       NILFS (loop0): segctord starting. Construction interval = 5 seconds, CP
       frequency < 30 seconds
       general protection fault, probably for non-canonical address
       0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN
       KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
       CPU: 1 PID: 3603 Comm: segctord Not tainted
       6.1.0-rc2-syzkaller-00105-gb229b6ca5abb #0
       Hardware name: Google Compute Engine/Google Compute Engine, BIOS Google
       10/11/2022
       RIP: 0010:nilfs_palloc_commit_free_entry+0xe5/0x6b0
       fs/nilfs2/alloc.c:608
       Code: 00 00 00 00 fc ff df 80 3c 02 00 0f 85 cd 05 00 00 48 b8 00 00 00
       00 00 fc ff df 4c 8b 73 08 49 8d 7e 10 48 89 fa 48 c1 ea 03 <80> 3c 02
       00 0f 85 26 05 00 00 49 8b 46 10 be a6 00 00 00 48 c7 c7
       RSP: 0018:ffffc90003dff830 EFLAGS: 00010212
       RAX: dffffc0000000000 RBX: ffff88802594e218 RCX: 000000000000000d
       RDX: 0000000000000002 RSI: 0000000000002000 RDI: 0000000000000010
       RBP: ffff888071880222 R08: 0000000000000005 R09: 000000000000003f
       R10: 000000000000000d R11: 0000000000000000 R12: ffff888071880158
       R13: ffff88802594e220 R14: 0000000000000000 R15: 0000000000000004
       FS:  0000000000000000(0000) GS:ffff8880b9b00000(0000)
       knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 00007fb1c08316a8 CR3: 0000000018560000 CR4: 0000000000350ee0
       Call Trace:
        <TASK>
        nilfs_dat_commit_free fs/nilfs2/dat.c:114 [inline]
        nilfs_dat_commit_end+0x464/0x5f0 fs/nilfs2/dat.c:193
        nilfs_dat_commit_update+0x26/0x40 fs/nilfs2/dat.c:236
        nilfs_btree_commit_update_v+0x87/0x4a0 fs/nilfs2/btree.c:1940
        nilfs_btree_commit_propagate_v fs/nilfs2/btree.c:2016 [inline]
        nilfs_btree_propagate_v fs/nilfs2/btree.c:2046 [inline]
        nilfs_btree_propagate+0xa00/0xd60 fs/nilfs2/btree.c:2088
        nilfs_bmap_propagate+0x73/0x170 fs/nilfs2/bmap.c:337
        nilfs_collect_file_data+0x45/0xd0 fs/nilfs2/segment.c:568
        nilfs_segctor_apply_buffers+0x14a/0x470 fs/nilfs2/segment.c:1018
        nilfs_segctor_scan_file+0x3f4/0x6f0 fs/nilfs2/segment.c:1067
        nilfs_segctor_collect_blocks fs/nilfs2/segment.c:1197 [inline]
        nilfs_segctor_collect fs/nilfs2/segment.c:1503 [inline]
        nilfs_segctor_do_construct+0x12fc/0x6af0 fs/nilfs2/segment.c:2045
        nilfs_segctor_construct+0x8e3/0xb30 fs/nilfs2/segment.c:2379
        nilfs_segctor_thread_construct fs/nilfs2/segment.c:2487 [inline]
        nilfs_segctor_thread+0x3c3/0xf30 fs/nilfs2/segment.c:2570
        kthread+0x2e4/0x3a0 kernel/kthread.c:376
        ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
        </TASK>
       ...
      
      If DAT metadata file is corrupted on disk, there is a case where
      req->pr_desc_bh is NULL and blocknr is 0 at nilfs_dat_commit_end() during
      a b-tree operation that cascadingly updates ancestor nodes of the b-tree,
      because nilfs_dat_commit_alloc() for a lower level block can initialize
      the blocknr on the same DAT entry between nilfs_dat_prepare_end() and
      nilfs_dat_commit_end().
      
      If this happens, nilfs_dat_commit_end() calls nilfs_dat_commit_free()
      without valid buffer heads in req->pr_desc_bh and req->pr_bitmap_bh, and
      causes the NULL pointer dereference above in
      nilfs_palloc_commit_free_entry() function, which leads to a crash.
      
      Fix this by adding a NULL check on req->pr_desc_bh and req->pr_bitmap_bh
      before nilfs_palloc_commit_free_entry() in nilfs_dat_commit_free().
      
      This also calls nilfs_error() in that case to notify that there is a fatal
      flaw in the filesystem metadata and prevent further operations.
      
      Link: https://lkml.kernel.org/r/00000000000097c20205ebaea3d6@google.com
      Link: https://lkml.kernel.org/r/20221114040441.1649940-1-zhangpeng362@huawei.com
      Link: https://lkml.kernel.org/r/20221119120542.17204-1-konishi.ryusuke@gmail.com
      Signed-off-by: default avatarZhangPeng <zhangpeng362@huawei.com>
      Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Reported-by: default avatar <syzbot+ebe05ee8e98f755f61d0@syzkaller.appspotmail.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>
      bc3fd329
    • Tiezhu Yang's avatar
      tools/vm/slabinfo-gnuplot: use "grep -E" instead of "egrep" · 733c0908
      Tiezhu Yang authored
      commit a435874b
      
       upstream.
      
      The latest version of grep claims the egrep is now obsolete so the build
      now contains warnings that look like:
      
      	egrep: warning: egrep is obsolescent; using grep -E
      
      fix this up by moving the related file to use "grep -E" instead.
      
        sed -i "s/egrep/grep -E/g" `grep egrep -rwl tools/vm`
      
      Here are the steps to install the latest grep:
      
        wget http://ftp.gnu.org/gnu/grep/grep-3.8.tar.gz
        tar xf grep-3.8.tar.gz
        cd grep-3.8 && ./configure && make
        sudo make install
        export PATH=/usr/local/bin:$PATH
      
      Link: https://lkml.kernel.org/r/1668825419-30584-1-git-send-email-yangtiezhu@loongson.cn
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Reviewed-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      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>
      733c0908
    • Steven Rostedt (Google)'s avatar
      error-injection: Add prompt for function error injection · ef67a4a1
      Steven Rostedt (Google) authored
      commit a4412fdd upstream.
      
      The config to be able to inject error codes into any function annotated
      with ALLOW_ERROR_INJECTION() is enabled when FUNCTION_ERROR_INJECTION is
      enabled.  But unfortunately, this is always enabled on x86 when KPROBES
      is enabled, and there's no way to turn it off.
      
      As kprobes is useful for observability of the kernel, it is useful to
      have it enabled in production environments.  But error injection should
      be avoided.  Add a prompt to the config to allow it to be disabled even
      when kprobes is enabled, and get rid of the "def_bool y".
      
      This is a kernel debug feature (it's in Kconfig.debug), and should have
      never been something enabled by default.
      
      Cc: stable@vger.kernel.org
      Fixes: 540adea3
      
       ("error-injection: Separate error-injection from kprobe")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ef67a4a1
    • ChenXiaoSong's avatar
      btrfs: qgroup: fix sleep from invalid context bug in btrfs_qgroup_inherit() · f4b930a1
      ChenXiaoSong authored
      [ Upstream commit f7e942b5
      
       ]
      
      Syzkaller reported BUG as follows:
      
        BUG: sleeping function called from invalid context at
             include/linux/sched/mm.h:274
        Call Trace:
         <TASK>
         dump_stack_lvl+0xcd/0x134
         __might_resched.cold+0x222/0x26b
         kmem_cache_alloc+0x2e7/0x3c0
         update_qgroup_limit_item+0xe1/0x390
         btrfs_qgroup_inherit+0x147b/0x1ee0
         create_subvol+0x4eb/0x1710
         btrfs_mksubvol+0xfe5/0x13f0
         __btrfs_ioctl_snap_create+0x2b0/0x430
         btrfs_ioctl_snap_create_v2+0x25a/0x520
         btrfs_ioctl+0x2a1c/0x5ce0
         __x64_sys_ioctl+0x193/0x200
         do_syscall_64+0x35/0x80
      
      Fix this by calling qgroup_dirty() on @dstqgroup, and update limit item in
      btrfs_run_qgroups() later outside of the spinlock context.
      
      CC: stable@vger.kernel.org # 4.9+
      Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
      Signed-off-by: default avatarChenXiaoSong <chenxiaosong2@huawei.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f4b930a1
    • Yang Yingliang's avatar
      hwmon: (coretemp) fix pci device refcount leak in nv1a_ram_new() · 2f74cffc
      Yang Yingliang authored
      [ Upstream commit 7dec1453 ]
      
      As comment of pci_get_domain_bus_and_slot() says, it returns
      a pci device with refcount increment, when finish using it,
      the caller must decrement the reference count by calling
      pci_dev_put(). So call it after using to avoid refcount leak.
      
      Fixes: 14513ee6
      
       ("hwmon: (coretemp) Use PCI host bridge ID to identify CPU if necessary")
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Link: https://lore.kernel.org/r/20221118093303.214163-1-yangyingliang@huawei.com
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2f74cffc
    • Phil Auld's avatar
      hwmon: (coretemp) Check for null before removing sysfs attrs · 280110db
      Phil Auld authored
      [ Upstream commit a89ff5f5
      
       ]
      
      If coretemp_add_core() gets an error then pdata->core_data[indx]
      is already NULL and has been kfreed. Don't pass that to
      sysfs_remove_group() as that will crash in sysfs_remove_group().
      
      [Shortened for readability]
      [91854.020159] sysfs: cannot create duplicate filename '/devices/platform/coretemp.0/hwmon/hwmon2/temp20_label'
      <cpu offline>
      [91855.126115] BUG: kernel NULL pointer dereference, address: 0000000000000188
      [91855.165103] #PF: supervisor read access in kernel mode
      [91855.194506] #PF: error_code(0x0000) - not-present page
      [91855.224445] PGD 0 P4D 0
      [91855.238508] Oops: 0000 [#1] PREEMPT SMP PTI
      ...
      [91855.342716] RIP: 0010:sysfs_remove_group+0xc/0x80
      ...
      [91855.796571] Call Trace:
      [91855.810524]  coretemp_cpu_offline+0x12b/0x1dd [coretemp]
      [91855.841738]  ? coretemp_cpu_online+0x180/0x180 [coretemp]
      [91855.871107]  cpuhp_invoke_callback+0x105/0x4b0
      [91855.893432]  cpuhp_thread_fun+0x8e/0x150
      ...
      
      Fix this by checking for NULL first.
      
      Signed-off-by: default avatarPhil Auld <pauld@redhat.com>
      Cc: linux-hwmon@vger.kernel.org
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: Jean Delvare <jdelvare@suse.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/20221117162313.3164803-1-pauld@redhat.com
      Fixes: 199e0de7
      
       ("hwmon: (coretemp) Merge pkgtemp with coretemp")
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      280110db
    • Yoshihiro Shimoda's avatar
      net: ethernet: renesas: ravb: Fix promiscuous mode after system resumed · 5aa897c4
      Yoshihiro Shimoda authored
      [ Upstream commit d66233a3
      
       ]
      
      After system resumed on some environment board, the promiscuous mode
      is disabled because the SoC turned off. So, call ravb_set_rx_mode() in
      the ravb_resume() to fix the issue.
      
      Reported-by: default avatarTho Vu <tho.vu.wh@renesas.com>
      Fixes: 0184165b
      
       ("ravb: add sleep PM suspend/resume support")
      Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Reviewed-by: default avatarPavan Chebbi <pavan.chebbi@broadcom.com>
      Reviewed-by: default avatarSergey Shtylyov <s.shtylyov@omp.ru>
      Link: https://lore.kernel.org/r/20221128065604.1864391-1-yoshihiro.shimoda.uh@renesas.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5aa897c4
    • Willem de Bruijn's avatar
      packet: do not set TP_STATUS_CSUM_VALID on CHECKSUM_COMPLETE · 36e4b800
      Willem de Bruijn authored
      [ Upstream commit b85f628a ]
      
      CHECKSUM_COMPLETE signals that skb->csum stores the sum over the
      entire packet. It does not imply that an embedded l4 checksum
      field has been validated.
      
      Fixes: 682f048b
      
       ("af_packet: pass checksum validation status to the user")
      Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
      Link: https://lore.kernel.org/r/20221128161812.640098-1-willemdebruijn.kernel@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      36e4b800
    • Shigeru Yoshida's avatar
      net: tun: Fix use-after-free in tun_detach() · 1f23f189
      Shigeru Yoshida authored
      [ Upstream commit 5daadc86 ]
      
      syzbot reported use-after-free in tun_detach() [1].  This causes call
      trace like below:
      
      ==================================================================
      BUG: KASAN: use-after-free in notifier_call_chain+0x1ee/0x200 kernel/notifier.c:75
      Read of size 8 at addr ffff88807324e2a8 by task syz-executor.0/3673
      
      CPU: 0 PID: 3673 Comm: syz-executor.0 Not tainted 6.1.0-rc5-syzkaller-00044-gcc675d22e422 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106
       print_address_description mm/kasan/report.c:284 [inline]
       print_report+0x15e/0x461 mm/kasan/report.c:395
       kasan_report+0xbf/0x1f0 mm/kasan/report.c:495
       notifier_call_chain+0x1ee/0x200 kernel/notifier.c:75
       call_netdevice_notifiers_info+0x86/0x130 net/core/dev.c:1942
       call_netdevice_notifiers_extack net/core/dev.c:1983 [inline]
       call_netdevice_notifiers net/core/dev.c:1997 [inline]
       netdev_wait_allrefs_any net/core/dev.c:10237 [inline]
       netdev_run_todo+0xbc6/0x1100 net/core/dev.c:10351
       tun_detach drivers/net/tun.c:704 [inline]
       tun_chr_close+0xe4/0x190 drivers/net/tun.c:3467
       __fput+0x27c/0xa90 fs/file_table.c:320
       task_work_run+0x16f/0x270 kernel/task_work.c:179
       exit_task_work include/linux/task_work.h:38 [inline]
       do_exit+0xb3d/0x2a30 kernel/exit.c:820
       do_group_exit+0xd4/0x2a0 kernel/exit.c:950
       get_signal+0x21b1/0x2440 kernel/signal.c:2858
       arch_do_signal_or_restart+0x86/0x2300 arch/x86/kernel/signal.c:869
       exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
       exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203
       __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
       syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296
       do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      The cause of the issue is that sock_put() from __tun_detach() drops
      last reference count for struct net, and then notifier_call_chain()
      from netdev_state_change() accesses that struct net.
      
      This patch fixes the issue by calling sock_put() from tun_detach()
      after all necessary accesses for the struct net has done.
      
      Fixes: 83c1f36f
      
       ("tun: send netlink notification when the device is modified")
      Reported-by: default avatar <syzbot+106f9b687cd64ee70cd1@syzkaller.appspotmail.com>
      Link: https://syzkaller.appspot.com/bug?id=96eb7f1ce75ef933697f24eeab928c4a716edefe [1]
      Signed-off-by: default avatarShigeru Yoshida <syoshida@redhat.com>
      Link: https://lore.kernel.org/r/20221124175134.1589053-1-syoshida@redhat.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1f23f189
    • YueHaibing's avatar
      net: hsr: Fix potential use-after-free · b35d8998
      YueHaibing authored
      [ Upstream commit 7e177d32 ]
      
      The skb is delivered to netif_rx() which may free it, after calling this,
      dereferencing skb may trigger use-after-free.
      
      Fixes: f421436a
      
       ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)")
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Link: https://lore.kernel.org/r/20221125075724.27912-1-yuehaibing@huawei.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b35d8998
    • Jerry Ray's avatar
      dsa: lan9303: Correct stat name · 97dbb844
      Jerry Ray authored
      [ Upstream commit 39f59bca ]
      
      This patch changes the reported ethtool statistics for the lan9303
      family of parts covered by this driver.
      
      The TxUnderRun statistic label is renamed to RxShort to accurately
      reflect what stat the device is reporting.  I did not reorder the
      statistics as that might cause problems with existing user code that
      are expecting the stats at a certain offset.
      
      Fixes: a1292595
      
       ("net: dsa: add new DSA switch driver for the SMSC-LAN9303")
      Signed-off-by: default avatarJerry Ray <jerry.ray@microchip.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20221128193559.6572-1-jerry.ray@microchip.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      97dbb844
    • Wang Hai's avatar
      net/9p: Fix a potential socket leak in p9_socket_open · 8b14bd0b
      Wang Hai authored
      [ Upstream commit dcc14cfd ]
      
      Both p9_fd_create_tcp() and p9_fd_create_unix() will call
      p9_socket_open(). If the creation of p9_trans_fd fails,
      p9_fd_create_tcp() and p9_fd_create_unix() will return an
      error directly instead of releasing the cscoket, which will
      result in a socket leak.
      
      This patch adds sock_release() to fix the leak issue.
      
      Fixes: 6b18662e
      
       ("9p connect fixes")
      Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
      ACKed-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8b14bd0b
    • Yuan Can's avatar
      net: net_netdev: Fix error handling in ntb_netdev_init_module() · af0935e8
      Yuan Can authored
      [ Upstream commit b8f79dcc ]
      
      The ntb_netdev_init_module() returns the ntb_transport_register_client()
      directly without checking its return value, if
      ntb_transport_register_client() failed, the NTB client device is not
      unregistered.
      
      Fix by unregister NTB client device when ntb_transport_register_client()
      failed.
      
      Fixes: 548c237c
      
       ("net: Add support for NTB virtual ethernet device")
      Signed-off-by: default avatarYuan Can <yuancan@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      af0935e8
    • Yang Yingliang's avatar
      net: phy: fix null-ptr-deref while probe() failed · 0744c7be
      Yang Yingliang authored
      [ Upstream commit 369eb2c9 ]
      
      I got a null-ptr-deref report as following when doing fault injection test:
      
      BUG: kernel NULL pointer dereference, address: 0000000000000058
      Oops: 0000 [#1] PREEMPT SMP KASAN PTI
      CPU: 1 PID: 253 Comm: 507-spi-dm9051 Tainted: G    B            N 6.1.0-rc3+
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
      RIP: 0010:klist_put+0x2d/0xd0
      Call Trace:
       <TASK>
       klist_remove+0xf1/0x1c0
       device_release_driver_internal+0x23e/0x2d0
       bus_remove_device+0x1bd/0x240
       device_del+0x357/0x770
       phy_device_remove+0x11/0x30
       mdiobus_unregister+0xa5/0x140
       release_nodes+0x6a/0xa0
       devres_release_all+0xf8/0x150
       device_unbind_cleanup+0x19/0xd0
      
      //probe path:
      phy_device_register()
        device_add()
      
      phy_connect
        phy_attach_direct() //set device driver
          probe() //it's failed, driver is not bound
          device_bind_driver() // probe failed, it's not called
      
      //remove path:
      phy_device_remove()
        device_del()
          device_release_driver_internal()
            __device_release_driver() //dev->drv is not NULL
              klist_remove() <- knode_driver is not added yet, cause null-ptr-deref
      
      In phy_attach_direct(), after setting the 'dev->driver', probe() fails,
      device_bind_driver() is not called, so the knode_driver->n_klist is not
      set, then it causes null-ptr-deref in __device_release_driver() while
      deleting device. Fix this by setting dev->driver to NULL in the error
      path in phy_attach_direct().
      
      Fixes: e1393456
      
       ("[PATCH] PHY Layer fixup")
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0744c7be
    • Duoming Zhou's avatar
      qlcnic: fix sleep-in-atomic-context bugs caused by msleep · 115313eb
      Duoming Zhou authored
      [ Upstream commit 8dbd6e4c ]
      
      The watchdog timer is used to monitor whether the process
      of transmitting data is timeout. If we use qlcnic driver,
      the dev_watchdog() that is the timer handler of watchdog
      timer will call qlcnic_tx_timeout() to process the timeout.
      But the qlcnic_tx_timeout() calls msleep(), as a result,
      the sleep-in-atomic-context bugs will happen. The processes
      are shown below:
      
         (atomic context)
      dev_watchdog
        qlcnic_tx_timeout
          qlcnic_83xx_idc_request_reset
            qlcnic_83xx_lock_driver
              msleep
      
      ---------------------------
      
         (atomic context)
      dev_watchdog
        qlcnic_tx_timeout
          qlcnic_83xx_idc_request_reset
            qlcnic_83xx_lock_driver
              qlcnic_83xx_recover_driver_lock
                msleep
      
      Fix by changing msleep() to mdelay(), the mdelay() is
      busy-waiting and the bugs could be mitigated.
      
      Fixes: 629263ac
      
       ("qlcnic: 83xx CNA inter driver communication mechanism")
      Signed-off-by: default avatarDuoming Zhou <duoming@zju.edu.cn>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      115313eb
    • Zhang Changzhong's avatar
      can: cc770: cc770_isa_probe(): add missing free_cc770dev() · ddbe5ea1
      Zhang Changzhong authored
      [ Upstream commit 62ec89e7 ]
      
      Add the missing free_cc770dev() before return from cc770_isa_probe()
      in the register_cc770dev() error handling case.
      
      In addition, remove blanks before goto labels.
      
      Fixes: 7e02e543
      
       ("can: cc770: legacy CC770 ISA bus driver")
      Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
      Link: https://lore.kernel.org/all/1668168557-6024-1-git-send-email-zhangchangzhong@huawei.com
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ddbe5ea1
    • Zhang Changzhong's avatar
      can: sja1000_isa: sja1000_isa_probe(): add missing free_sja1000dev() · 000f79f3
      Zhang Changzhong authored
      [ Upstream commit 92dfd931 ]
      
      Add the missing free_sja1000dev() before return from
      sja1000_isa_probe() in the register_sja1000dev() error handling case.
      
      In addition, remove blanks before goto labels.
      
      Fixes: 2a6ba39a
      
       ("can: sja1000: legacy SJA1000 ISA bus driver")
      Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
      Link: https://lore.kernel.org/all/1668168521-5540-1-git-send-email-zhangchangzhong@huawei.com
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      000f79f3
    • YueHaibing's avatar
      net/mlx5: Fix uninitialized variable bug in outlen_write() · 367ff8f1
      YueHaibing authored
      [ Upstream commit 3f5769a0 ]
      
      If sscanf() return 0, outlen is uninitialized and used in kzalloc(),
      this is unexpected. We should return -EINVAL if the string is invalid.
      
      Fixes: e126ba97
      
       ("mlx5: Add driver for Mellanox Connect-IB adapters")
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      367ff8f1
    • Yang Yingliang's avatar
      of: property: decrement node refcount in of_fwnode_get_reference_args() · 171d5fcc
      Yang Yingliang authored
      [ Upstream commit 60d865bd ]
      
      In of_fwnode_get_reference_args(), the refcount of of_args.np has
      been incremented in the case of successful return from
      of_parse_phandle_with_args() or of_parse_phandle_with_fixed_args().
      
      Decrement the refcount if of_args is not returned to the caller of
      of_fwnode_get_reference_args().
      
      Fixes: 3e3119d3
      
       ("device property: Introduce fwnode_property_get_reference_args")
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Reviewed-by: default avatarFrank Rowand <frowand.list@gmail.com>
      Link: https://lore.kernel.org/r/20221121023209.3909759-1-yangyingliang@huawei.com
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      171d5fcc
    • Gaosheng Cui's avatar
      hwmon: (ibmpex) Fix possible UAF when ibmpex_register_bmc() fails · 24b9633f
      Gaosheng Cui authored
      [ Upstream commit e2a87785 ]
      
      Smatch report warning as follows:
      
      drivers/hwmon/ibmpex.c:509 ibmpex_register_bmc() warn:
        '&data->list' not removed from list
      
      If ibmpex_find_sensors() fails in ibmpex_register_bmc(), data will
      be freed, but data->list will not be removed from driver_data.bmc_data,
      then list traversal may cause UAF.
      
      Fix by removeing it from driver_data.bmc_data before free().
      
      Fixes: 57c7c3a0
      
       ("hwmon: IBM power meter driver")
      Signed-off-by: default avatarGaosheng Cui <cuigaosheng1@huawei.com>
      Link: https://lore.kernel.org/r/20221117034423.2935739-1-cuigaosheng1@huawei.com
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      24b9633f
    • Yang Yingliang's avatar
      hwmon: (i5500_temp) fix missing pci_disable_device() · be6275a1
      Yang Yingliang authored
      [ Upstream commit 3b7f98f2 ]
      
      pci_disable_device() need be called while module exiting, switch to use
      pcim_enable(), pci_disable_device() will be called in pcim_release().
      
      Fixes: ada07281
      
       ("hwmon: (i5500_temp) New driver for the Intel 5500/5520/X58 chipsets")
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Link: https://lore.kernel.org/r/20221112125606.3751430-1-yangyingliang@huawei.com
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      be6275a1
    • Srikar Dronamraju's avatar
      scripts/faddr2line: Fix regression in name resolution on ppc64le · 836431e9
      Srikar Dronamraju authored
      [ Upstream commit 2d77de15 ]
      
      Commit 1d1a0e7c ("scripts/faddr2line: Fix overlapping text section
      failures") can cause faddr2line to fail on ppc64le on some
      distributions, while it works fine on other distributions. The failure
      can be attributed to differences in the readelf output.
      
        $ ./scripts/faddr2line vmlinux find_busiest_group+0x00
        no match for find_busiest_group+0x00
      
      On ppc64le, readelf adds the localentry tag before the symbol name on
      some distributions, and adds the localentry tag after the symbol name on
      other distributions. This problem has been discussed previously:
      
        https://lore.kernel.org/bpf/20191211160133.GB4580@calabresa/
      
      This problem can be overcome by filtering out the localentry tags in the
      readelf output. Similar fixes are already present in the kernel by way
      of the following commits:
      
        1fd6cee1 ("libbpf: Fix VERSIONED_SYM_COUNT number parsing")
        aa915931 ("libbpf: Fix readelf output parsing for Fedora")
      
      [jpoimboe: rework commit log]
      
      Fixes: 1d1a0e7c
      
       ("scripts/faddr2line: Fix overlapping text section failures")
      Signed-off-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
      Acked-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Reviewed-by: default avatarThadeu Lima de Souza Cascardo <cascardo@canonical.com>
      Link: https://lore.kernel.org/r/20220927075211.897152-1-srikar@linux.vnet.ibm.com
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
      Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      836431e9
    • Paul Gazzillo's avatar
      iio: light: rpr0521: add missing Kconfig dependencies · bc51349d
      Paul Gazzillo authored
      [ Upstream commit 6ac12303 ]
      
      Fix an implicit declaration of function error for rpr0521 under some configs
      
      When CONFIG_RPR0521 is enabled without CONFIG_IIO_TRIGGERED_BUFFER,
      the build results in "implicit declaration of function" errors, e.g.,
        drivers/iio/light/rpr0521.c:434:3: error: implicit declaration of function
                 'iio_trigger_poll_chained' [-Werror=implicit-function-declaration]
          434 |   iio_trigger_poll_chained(data->drdy_trigger0);
              |   ^~~~~~~~~~~~~~~~~~~~~~~~
      
      This fix adds select dependencies to RPR0521's configuration declaration.
      
      Fixes: e12ffd24
      
       ("iio: light: rpr0521 triggered buffer")
      Signed-off-by: default avatarPaul Gazzillo <paul@pgazz.com>
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=216678
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Link: https://lore.kernel.org/r/20221110214729.ls5ixav5kxpeftk7@device
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bc51349d
    • Wei Yongjun's avatar
      iio: health: afe4404: Fix oob read in afe4404_[read|write]_raw · f5575041
      Wei Yongjun authored
      [ Upstream commit fc92d9e3 ]
      
      KASAN report out-of-bounds read as follows:
      
      BUG: KASAN: global-out-of-bounds in afe4404_read_raw+0x2ce/0x380
      Read of size 4 at addr ffffffffc00e4658 by task cat/278
      
      Call Trace:
       afe4404_read_raw
       iio_read_channel_info
       dev_attr_show
      
      The buggy address belongs to the variable:
       afe4404_channel_leds+0x18/0xffffffffffffe9c0
      
      This issue can be reproduce by singe command:
      
       $ cat /sys/bus/i2c/devices/0-0058/iio\:device0/in_intensity6_raw
      
      The array size of afe4404_channel_leds and afe4404_channel_offdacs
      are less than channels, so access with chan->address cause OOB read
      in afe4404_[read|write]_raw. Fix it by moving access before use them.
      
      Fixes: b36e8257
      
       ("iio: health/afe440x: Use regmap fields")
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Acked-by: default avatarAndrew Davis <afd@ti.com>
      Link: https://lore.kernel.org/r/20221107152010.95937-1-weiyongjun@huaweicloud.com
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f5575041
    • Wei Yongjun's avatar
      iio: health: afe4403: Fix oob read in afe4403_read_raw · 726fa3e4
      Wei Yongjun authored
      [ Upstream commit 58143c1e ]
      
      KASAN report out-of-bounds read as follows:
      
      BUG: KASAN: global-out-of-bounds in afe4403_read_raw+0x42e/0x4c0
      Read of size 4 at addr ffffffffc02ac638 by task cat/279
      
      Call Trace:
       afe4403_read_raw
       iio_read_channel_info
       dev_attr_show
      
      The buggy address belongs to the variable:
       afe4403_channel_leds+0x18/0xffffffffffffe9e0
      
      This issue can be reproduced by singe command:
      
       $ cat /sys/bus/spi/devices/spi0.0/iio\:device0/in_intensity6_raw
      
      The array size of afe4403_channel_leds is less than channels, so access
      with chan->address cause OOB read in afe4403_read_raw. Fix it by moving
      access before use it.
      
      Fixes: b36e8257
      
       ("iio: health/afe440x: Use regmap fields")
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Acked-by: default avatarAndrew Davis <afd@ti.com>
      Link: https://lore.kernel.org/r/20221107151946.89260-1-weiyongjun@huaweicloud.com
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      726fa3e4
    • Ben Hutchings's avatar
      Revert "x86/speculation: Change FILL_RETURN_BUFFER to work with objtool" · 367f2a84
      Ben Hutchings authored
      This reverts commit 9f3330d4, which
      was commit 089dd8e5
      
       upstream.
      
      The necessary changes to objtool have not been backported to 4.19.
      Backporting this commit alone only added build warnings.
      
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      367f2a84
    • Linus Torvalds's avatar
      v4l2: don't fall back to follow_pfn() if pin_user_pages_fast() fails · c6a663f6
      Linus Torvalds authored
      commit 6647e76a
      
       upstream.
      
      The V4L2_MEMORY_USERPTR interface is long deprecated and shouldn't be
      used (and is discouraged for any modern v4l drivers).  And Seth Jenkins
      points out that the fallback to VM_PFNMAP/VM_IO is fundamentally racy
      and dangerous.
      
      Note that it's not even a case that should trigger, since any normal
      user pointer logic ends up just using the pin_user_pages_fast() call
      that does the proper page reference counting.  That's not the problem
      case, only if you try to use special device mappings do you have any
      issues.
      
      Normally I'd just remove this during the merge window, but since Seth
      pointed out the problem cases, we really want to know as soon as
      possible if there are actually any users of this odd special case of a
      legacy interface.  Neither Hans nor Mauro seem to think that such
      mis-uses of the old legacy interface should exist.  As Mauro says:
      
       "See, V4L2 has actually 4 streaming APIs:
              - Kernel-allocated mmap (usually referred simply as just mmap);
              - USERPTR mmap;
              - read();
              - dmabuf;
      
        The USERPTR is one of the oldest way to use it, coming from V4L
        version 1 times, and by far the least used one"
      
      And Hans chimed in on the USERPTR interface:
      
       "To be honest, I wouldn't mind if it goes away completely, but that's a
        bit of a pipe dream right now"
      
      but while removing this legacy interface entirely may be a pipe dream we
      can at least try to remove the unlikely (and actively broken) case of
      using special device mappings for USERPTR accesses.
      
      This replaces it with a WARN_ONCE() that we can remove once we've
      hopefully confirmed that no actual users exist.
      
      NOTE! Longer term, this means that a 'struct frame_vector' only ever
      contains proper page pointers, and all the games we have with converting
      them to pages can go away (grep for 'frame_vector_to_pages()' and the
      uses of 'vec->is_pfns').  But this is just the first step, to verify
      that this code really is all dead, and do so as quickly as possible.
      
      Reported-by: default avatarSeth Jenkins <sethjenkins@google.com>
      Acked-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
      Acked-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: Jan Kara <jack@suse.cz>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c6a663f6
    • Linus Torvalds's avatar
      proc: proc_skip_spaces() shouldn't think it is working on C strings · a9c309fb
      Linus Torvalds authored
      commit bce93322
      
       upstream.
      
      proc_skip_spaces() seems to think it is working on C strings, and ends
      up being just a wrapper around skip_spaces() with a really odd calling
      convention.
      
      Instead of basing it on skip_spaces(), it should have looked more like
      proc_skip_char(), which really is the exact same function (except it
      skips a particular character, rather than whitespace).  So use that as
      inspiration, odd coding and all.
      
      Now the calling convention actually makes sense and works for the
      intended purpose.
      
      Reported-and-tested-by: default avatarKyle Zeng <zengyhkyle@gmail.com>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a9c309fb
    • Linus Torvalds's avatar
      proc: avoid integer type confusion in get_proc_long · fe84d7f0
      Linus Torvalds authored
      commit e6cfaf34
      
       upstream.
      
      proc_get_long() is passed a size_t, but then assigns it to an 'int'
      variable for the length.  Let's not do that, even if our IO paths are
      limited to MAX_RW_COUNT (exactly because of these kinds of type errors).
      
      So do the proper test in the rigth type.
      
      Reported-by: default avatarKyle Zeng <zengyhkyle@gmail.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fe84d7f0
    • Frieder Schrempf's avatar
      spi: spi-imx: Fix spi_bus_clk if requested clock is higher than input clock · 5c559611
      Frieder Schrempf authored
      [ Upstream commit db2d2dc9 ]
      
      In case the requested bus clock is higher than the input clock, the correct
      dividers (pre = 0, post = 0) are returned from mx51_ecspi_clkdiv(), but
      *fres is left uninitialized and therefore contains an arbitrary value.
      
      This causes trouble for the recently introduced PIO polling feature as the
      value in spi_imx->spi_bus_clk is used there to calculate for which
      transfers to enable PIO polling.
      
      Fix this by setting *fres even if no clock dividers are in use.
      
      This issue was observed on Kontron BL i.MX8MM with an SPI peripheral clock set
      to 50 MHz by default and a requested SPI bus clock of 80 MHz for the SPI NOR
      flash.
      
      With the fix applied the debug message from mx51_ecspi_clkdiv() now prints the
      following:
      
      spi_imx 30820000.spi: mx51_ecspi_clkdiv: fin: 50000000, fspi: 50000000,
      post: 0, pre: 0
      
      Fixes: 6fd8b850 ("spi: spi-imx: Fix out-of-order CS/SCLK operation at low speeds")
      Fixes: 07e75938
      
       ("spi: spi-imx: add PIO polling support")
      Cc: Marc Kleine-Budde <mkl@pengutronix.de>
      Cc: David Jander <david@protonic.nl>
      Cc: Fabio Estevam <festevam@gmail.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Marek Vasut <marex@denx.de>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarFrieder Schrempf <frieder.schrempf@kontron.de>
      Tested-by: default avatarFabio Estevam <festevam@gmail.com>
      Acked-by: default avatarMarek Vasut <marex@denx.de>
      Link: https://lore.kernel.org/r/20221115181002.2068270-1-frieder@fris.de
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5c559611
    • Anand Jain's avatar
      btrfs: free btrfs_path before copying inodes to userspace · 35a78cb2
      Anand Jain authored
      [ Upstream commit 418ffb9e
      
       ]
      
      btrfs_ioctl_logical_to_ino() frees the search path after the userspace
      copy from the temp buffer @inodes. Which potentially can lead to a lock
      splat.
      
      Fix this by freeing the path before we copy @inodes to userspace.
      
      CC: stable@vger.kernel.org # 4.19+
      Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      35a78cb2
    • Christian König's avatar
      drm/amdgpu: always register an MMU notifier for userptr · 93704980
      Christian König authored
      commit b39df63b
      
       upstream.
      
      Since switching to HMM we always need that because we no longer grab
      references to the pages.
      
      Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
      Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Acked-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
      CC: stable@vger.kernel.org
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93704980
    • Lyude Paul's avatar
      drm/amd/dc/dce120: Fix audio register mapping, stop triggering KASAN · d0075f49
      Lyude Paul authored
      commit 44035ec2
      
       upstream.
      
      There's been a very long running bug that seems to have been neglected for
      a while, where amdgpu consistently triggers a KASAN error at start:
      
        BUG: KASAN: global-out-of-bounds in read_indirect_azalia_reg+0x1d4/0x2a0 [amdgpu]
        Read of size 4 at addr ffffffffc2274b28 by task modprobe/1889
      
      After digging through amd's rather creative method for accessing registers,
      I eventually discovered the problem likely has to do with the fact that on
      my dce120 GPU there are supposedly 7 sets of audio registers. But we only
      define a register mapping for 6 sets.
      
      So, fix this and fix the KASAN warning finally.
      
      Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d0075f49
    • Anand Jain's avatar
      btrfs: free btrfs_path before copying subvol info to userspace · 5400e33b
      Anand Jain authored
      commit 013c1c55
      
       upstream.
      
      btrfs_ioctl_get_subvol_info() frees the search path after the userspace
      copy from the temp buffer @subvol_info. This can lead to a lock splat
      warning.
      
      Fix this by freeing the path before we copy it to userspace.
      
      CC: stable@vger.kernel.org # 4.19+
      Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5400e33b
    • Anand Jain's avatar
      btrfs: free btrfs_path before copying fspath to userspace · 9f9980fa
      Anand Jain authored
      commit 8cf96b40
      
       upstream.
      
      btrfs_ioctl_ino_to_path() frees the search path after the userspace copy
      from the temp buffer @ipath->fspath. Which potentially can lead to a lock
      splat warning.
      
      Fix this by freeing the path before we copy it to userspace.
      
      CC: stable@vger.kernel.org # 4.19+
      Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9f9980fa
    • Josef Bacik's avatar
      btrfs: free btrfs_path before copying root refs to userspace · cf178919
      Josef Bacik authored
      commit b740d806
      
       upstream.
      
      Syzbot reported the following lockdep splat
      
      ======================================================
      WARNING: possible circular locking dependency detected
      6.0.0-rc7-syzkaller-18095-gbbed346d5a96 #0 Not tainted
      ------------------------------------------------------
      syz-executor307/3029 is trying to acquire lock:
      ffff0000c02525d8 (&mm->mmap_lock){++++}-{3:3}, at: __might_fault+0x54/0xb4 mm/memory.c:5576
      
      but task is already holding lock:
      ffff0000c958a608 (btrfs-root-00){++++}-{3:3}, at: __btrfs_tree_read_lock fs/btrfs/locking.c:134 [inline]
      ffff0000c958a608 (btrfs-root-00){++++}-{3:3}, at: btrfs_tree_read_lock fs/btrfs/locking.c:140 [inline]
      ffff0000c958a608 (btrfs-root-00){++++}-{3:3}, at: btrfs_read_lock_root_node+0x13c/0x1c0 fs/btrfs/locking.c:279
      
      which lock already depends on the new lock.
      
      the existing dependency chain (in reverse order) is:
      
      -> #3 (btrfs-root-00){++++}-{3:3}:
             down_read_nested+0x64/0x84 kernel/locking/rwsem.c:1624
             __btrfs_tree_read_lock fs/btrfs/locking.c:134 [inline]
             btrfs_tree_read_lock fs/btrfs/locking.c:140 [inline]
             btrfs_read_lock_root_node+0x13c/0x1c0 fs/btrfs/locking.c:279
             btrfs_search_slot_get_root+0x74/0x338 fs/btrfs/ctree.c:1637
             btrfs_search_slot+0x1b0/0xfd8 fs/btrfs/ctree.c:1944
             btrfs_update_root+0x6c/0x5a0 fs/btrfs/root-tree.c:132
             commit_fs_roots+0x1f0/0x33c fs/btrfs/transaction.c:1459
             btrfs_commit_transaction+0x89c/0x12d8 fs/btrfs/transaction.c:2343
             flush_space+0x66c/0x738 fs/btrfs/space-info.c:786
             btrfs_async_reclaim_metadata_space+0x43c/0x4e0 fs/btrfs/space-info.c:1059
             process_one_work+0x2d8/0x504 kernel/workqueue.c:2289
             worker_thread+0x340/0x610 kernel/workqueue.c:2436
             kthread+0x12c/0x158 kernel/kthread.c:376
             ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860
      
      -> #2 (&fs_info->reloc_mutex){+.+.}-{3:3}:
             __mutex_lock_common+0xd4/0xca8 kernel/locking/mutex.c:603
             __mutex_lock kernel/locking/mutex.c:747 [inline]
             mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
             btrfs_record_root_in_trans fs/btrfs/transaction.c:516 [inline]
             start_transaction+0x248/0x944 fs/btrfs/transaction.c:752
             btrfs_start_transaction+0x34/0x44 fs/btrfs/transaction.c:781
             btrfs_create_common+0xf0/0x1b4 fs/btrfs/inode.c:6651
             btrfs_create+0x8c/0xb0 fs/btrfs/inode.c:6697
             lookup_open fs/namei.c:3413 [inline]
             open_last_lookups fs/namei.c:3481 [inline]
             path_openat+0x804/0x11c4 fs/namei.c:3688
             do_filp_open+0xdc/0x1b8 fs/namei.c:3718
             do_sys_openat2+0xb8/0x22c fs/open.c:1313
             do_sys_open fs/open.c:1329 [inline]
             __do_sys_openat fs/open.c:1345 [inline]
             __se_sys_openat fs/open.c:1340 [inline]
             __arm64_sys_openat+0xb0/0xe0 fs/open.c:1340
             __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
             invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
             el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
             do_el0_svc+0x48/0x164 arch/arm64/kernel/syscall.c:206
             el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:636
             el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:654
             el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581
      
      -> #1 (sb_internal#2){.+.+}-{0:0}:
             percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
             __sb_start_write include/linux/fs.h:1826 [inline]
             sb_start_intwrite include/linux/fs.h:1948 [inline]
             start_transaction+0x360/0x944 fs/btrfs/transaction.c:683
             btrfs_join_transaction+0x30/0x40 fs/btrfs/transaction.c:795
             btrfs_dirty_inode+0x50/0x140 fs/btrfs/inode.c:6103
             btrfs_update_time+0x1c0/0x1e8 fs/btrfs/inode.c:6145
             inode_update_time fs/inode.c:1872 [inline]
             touch_atime+0x1f0/0x4a8 fs/inode.c:1945
             file_accessed include/linux/fs.h:2516 [inline]
             btrfs_file_mmap+0x50/0x88 fs/btrfs/file.c:2407
             call_mmap include/linux/fs.h:2192 [inline]
             mmap_region+0x7fc/0xc14 mm/mmap.c:1752
             do_mmap+0x644/0x97c mm/mmap.c:1540
             vm_mmap_pgoff+0xe8/0x1d0 mm/util.c:552
             ksys_mmap_pgoff+0x1cc/0x278 mm/mmap.c:1586
             __do_sys_mmap arch/arm64/kernel/sys.c:28 [inline]
             __se_sys_mmap arch/arm64/kernel/sys.c:21 [inline]
             __arm64_sys_mmap+0x58/0x6c arch/arm64/kernel/sys.c:21
             __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
             invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
             el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
             do_el0_svc+0x48/0x164 arch/arm64/kernel/syscall.c:206
             el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:636
             el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:654
             el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581
      
      -> #0 (&mm->mmap_lock){++++}-{3:3}:
             check_prev_add kernel/locking/lockdep.c:3095 [inline]
             check_prevs_add kernel/locking/lockdep.c:3214 [inline]
             validate_chain kernel/locking/lockdep.c:3829 [inline]
             __lock_acquire+0x1530/0x30a4 kernel/locking/lockdep.c:5053
             lock_acquire+0x100/0x1f8 kernel/locking/lockdep.c:5666
             __might_fault+0x7c/0xb4 mm/memory.c:5577
             _copy_to_user include/linux/uaccess.h:134 [inline]
             copy_to_user include/linux/uaccess.h:160 [inline]
             btrfs_ioctl_get_subvol_rootref+0x3a8/0x4bc fs/btrfs/ioctl.c:3203
             btrfs_ioctl+0xa08/0xa64 fs/btrfs/ioctl.c:5556
             vfs_ioctl fs/ioctl.c:51 [inline]
             __do_sys_ioctl fs/ioctl.c:870 [inline]
             __se_sys_ioctl fs/ioctl.c:856 [inline]
             __arm64_sys_ioctl+0xd0/0x140 fs/ioctl.c:856
             __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
             invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
             el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
             do_el0_svc+0x48/0x164 arch/arm64/kernel/syscall.c:206
             el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:636
             el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:654
             el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581
      
      other info that might help us debug this:
      
      Chain exists of:
        &mm->mmap_lock --> &fs_info->reloc_mutex --> btrfs-root-00
      
       Possible unsafe locking scenario:
      
             CPU0                    CPU1
             ----                    ----
        lock(btrfs-root-00);
                                     lock(&fs_info->reloc_mutex);
                                     lock(btrfs-root-00);
        lock(&mm->mmap_lock);
      
       *** DEADLOCK ***
      
      1 lock held by syz-executor307/3029:
       #0: ffff0000c958a608 (btrfs-root-00){++++}-{3:3}, at: __btrfs_tree_read_lock fs/btrfs/locking.c:134 [inline]
       #0: ffff0000c958a608 (btrfs-root-00){++++}-{3:3}, at: btrfs_tree_read_lock fs/btrfs/locking.c:140 [inline]
       #0: ffff0000c958a608 (btrfs-root-00){++++}-{3:3}, at: btrfs_read_lock_root_node+0x13c/0x1c0 fs/btrfs/locking.c:279
      
      stack backtrace:
      CPU: 0 PID: 3029 Comm: syz-executor307 Not tainted 6.0.0-rc7-syzkaller-18095-gbbed346d5a96 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/30/2022
      Call trace:
       dump_backtrace+0x1c4/0x1f0 arch/arm64/kernel/stacktrace.c:156
       show_stack+0x2c/0x54 arch/arm64/kernel/stacktrace.c:163
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x104/0x16c lib/dump_stack.c:106
       dump_stack+0x1c/0x58 lib/dump_stack.c:113
       print_circular_bug+0x2c4/0x2c8 kernel/locking/lockdep.c:2053
       check_noncircular+0x14c/0x154 kernel/locking/lockdep.c:2175
       check_prev_add kernel/locking/lockdep.c:3095 [inline]
       check_prevs_add kernel/locking/lockdep.c:3214 [inline]
       validate_chain kernel/locking/lockdep.c:3829 [inline]
       __lock_acquire+0x1530/0x30a4 kernel/locking/lockdep.c:5053
       lock_acquire+0x100/0x1f8 kernel/locking/lockdep.c:5666
       __might_fault+0x7c/0xb4 mm/memory.c:5577
       _copy_to_user include/linux/uaccess.h:134 [inline]
       copy_to_user include/linux/uaccess.h:160 [inline]
       btrfs_ioctl_get_subvol_rootref+0x3a8/0x4bc fs/btrfs/ioctl.c:3203
       btrfs_ioctl+0xa08/0xa64 fs/btrfs/ioctl.c:5556
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:870 [inline]
       __se_sys_ioctl fs/ioctl.c:856 [inline]
       __arm64_sys_ioctl+0xd0/0x140 fs/ioctl.c:856
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
       el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x48/0x164 arch/arm64/kernel/syscall.c:206
       el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:636
       el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:654
       el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581
      
      We do generally the right thing here, copying the references into a
      temporary buffer, however we are still holding the path when we do
      copy_to_user from the temporary buffer.  Fix this by freeing the path
      before we copy to user space.
      
      Reported-by: default avatar <syzbot+4ef9e52e464c6ff47d9d@syzkaller.appspotmail.com>
      CC: stable@vger.kernel.org # 4.19+
      Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
      Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cf178919
    • Mikulas Patocka's avatar
      dm integrity: flush the journal on suspend · 3ea2f587
      Mikulas Patocka authored
      [ Upstream commit 5e5dab5e
      
       ]
      
      This commit flushes the journal on suspend. It is prerequisite for the
      next commit that enables activating dm integrity devices in read-only mode.
      
      Note that we deliberately didn't flush the journal on suspend, so that the
      journal replay code would be tested. However, the dm-integrity code is 5
      years old now, so that journal replay is well-tested, and we can make this
      change now.
      
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3ea2f587
    • Enrico Sau's avatar
      net: usb: qmi_wwan: add Telit 0x103a composition · ae8db6e5
      Enrico Sau authored
      [ Upstream commit e103ba33
      
       ]
      
      Add the following Telit LE910C4-WWX composition:
      
      0x103a: rmnet
      
      Signed-off-by: default avatarEnrico Sau <enrico.sau@gmail.com>
      Acked-by: default avatarBjørn Mork <bjorn@mork.no>
      Link: https://lore.kernel.org/r/20221115105859.14324-1-enrico.sau@gmail.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ae8db6e5
    • Gleb Mazovetskiy's avatar
      tcp: configurable source port perturb table size · 0f140835
      Gleb Mazovetskiy authored
      [ Upstream commit aeac4ec8 ]
      
      On embedded systems with little memory and no relevant
      security concerns, it is beneficial to reduce the size
      of the table.
      
      Reducing the size from 2^16 to 2^8 saves 255 KiB
      of kernel RAM.
      
      Makes the table size configurable as an expert option.
      
      The size was previously increased from 2^8 to 2^16
      in commit 4c2c8f03
      
       ("tcp: increase source port perturb table to
      2^16").
      
      Signed-off-by: default avatarGleb Mazovetskiy <glex.spb@gmail.com>
      Reviewed-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0f140835
    • Kai-Heng Feng's avatar
      platform/x86: hp-wmi: Ignore Smart Experience App event · 893c3f1d
      Kai-Heng Feng authored
      [ Upstream commit 8b9b6a04
      
       ]
      
      Sometimes hp-wmi driver complains on system resume:
      [ 483.116451] hp_wmi: Unknown event_id - 33 - 0x0
      
      According to HP it's a feature called "HP Smart Experience App" and it's
      safe to be ignored.
      
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Link: https://lore.kernel.org/r/20221114073842.205392-1-kai.heng.feng@canonical.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>
      893c3f1d