1. 14 8月, 2023 1 次提交
  2. 09 8月, 2023 3 次提交
  3. 08 8月, 2023 6 次提交
  4. 07 8月, 2023 2 次提交
  5. 04 8月, 2023 3 次提交
  6. 03 8月, 2023 7 次提交
    • L
      net: nfc: Fix use-after-free caused by nfc_llcp_find_local · 99ffc29e
      Lin Ma 提交于
      stable inclusion
      from stable-v5.10.188
      commit 96f2c6f272ec04083d828de46285a7d7b17d1aad
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I7NLJR
      CVE: CVE-2023-3863
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=96f2c6f272ec04083d828de46285a7d7b17d1aad
      
      ---------------------------
      
      [ Upstream commit 6709d4b7bc2e079241fdef15d1160581c5261c10 ]
      
      This commit fixes several use-after-free that caused by function
      nfc_llcp_find_local(). For example, one UAF can happen when below buggy
      time window occurs.
      
      // nfc_genl_llc_get_params   | // nfc_unregister_device
                                   |
      dev = nfc_get_device(idx);   | device_lock(...)
      if (!dev)                    | dev->shutting_down = true;
          return -ENODEV;          | device_unlock(...);
                                   |
      device_lock(...);            |   // nfc_llcp_unregister_device
                                   |   nfc_llcp_find_local()
      nfc_llcp_find_local(...);    |
                                   |   local_cleanup()
      if (!local) {                |
          rc = -ENODEV;            |     // nfc_llcp_local_put
          goto exit;               |     kref_put(.., local_release)
      }                            |
                                   |       // local_release
                                   |       list_del(&local->list)
        // nfc_genl_send_params    |       kfree()
        local->dev->idx !!!UAF!!!  |
                                   |
      
      and the crash trace for the one of the discussed UAF like:
      
      BUG: KASAN: slab-use-after-free in nfc_genl_llc_get_params+0x72f/0x780  net/nfc/netlink.c:1045
      Read of size 8 at addr ffff888105b0e410 by task 20114
      
      Call Trace:
       <TASK>
       __dump_stack  lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x72/0xa0  lib/dump_stack.c:106
       print_address_description  mm/kasan/report.c:319 [inline]
       print_report+0xcc/0x620  mm/kasan/report.c:430
       kasan_report+0xb2/0xe0  mm/kasan/report.c:536
       nfc_genl_send_params  net/nfc/netlink.c:999 [inline]
       nfc_genl_llc_get_params+0x72f/0x780  net/nfc/netlink.c:1045
       genl_family_rcv_msg_doit.isra.0+0x1ee/0x2e0  net/netlink/genetlink.c:968
       genl_family_rcv_msg  net/netlink/genetlink.c:1048 [inline]
       genl_rcv_msg+0x503/0x7d0  net/netlink/genetlink.c:1065
       netlink_rcv_skb+0x161/0x430  net/netlink/af_netlink.c:2548
       genl_rcv+0x28/0x40  net/netlink/genetlink.c:1076
       netlink_unicast_kernel  net/netlink/af_netlink.c:1339 [inline]
       netlink_unicast+0x644/0x900  net/netlink/af_netlink.c:1365
       netlink_sendmsg+0x934/0xe70  net/netlink/af_netlink.c:1913
       sock_sendmsg_nosec  net/socket.c:724 [inline]
       sock_sendmsg+0x1b6/0x200  net/socket.c:747
       ____sys_sendmsg+0x6e9/0x890  net/socket.c:2501
       ___sys_sendmsg+0x110/0x1b0  net/socket.c:2555
       __sys_sendmsg+0xf7/0x1d0  net/socket.c:2584
       do_syscall_x64  arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3f/0x90  arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x72/0xdc
      RIP: 0033:0x7f34640a2389
      RSP: 002b:00007f3463415168 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 00007f34641c1f80 RCX: 00007f34640a2389
      RDX: 0000000000000000 RSI: 0000000020000240 RDI: 0000000000000006
      RBP: 00007f34640ed493 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
      R13: 00007ffe38449ecf R14: 00007f3463415300 R15: 0000000000022000
       </TASK>
      
      Allocated by task 20116:
       kasan_save_stack+0x22/0x50  mm/kasan/common.c:45
       kasan_set_track+0x25/0x30  mm/kasan/common.c:52
       ____kasan_kmalloc  mm/kasan/common.c:374 [inline]
       __kasan_kmalloc+0x7f/0x90  mm/kasan/common.c:383
       kmalloc  include/linux/slab.h:580 [inline]
       kzalloc  include/linux/slab.h:720 [inline]
       nfc_llcp_register_device+0x49/0xa40  net/nfc/llcp_core.c:1567
       nfc_register_device+0x61/0x260  net/nfc/core.c:1124
       nci_register_device+0x776/0xb20  net/nfc/nci/core.c:1257
       virtual_ncidev_open+0x147/0x230  drivers/nfc/virtual_ncidev.c:148
       misc_open+0x379/0x4a0  drivers/char/misc.c:165
       chrdev_open+0x26c/0x780  fs/char_dev.c:414
       do_dentry_open+0x6c4/0x12a0  fs/open.c:920
       do_open  fs/namei.c:3560 [inline]
       path_openat+0x24fe/0x37e0  fs/namei.c:3715
       do_filp_open+0x1ba/0x410  fs/namei.c:3742
       do_sys_openat2+0x171/0x4c0  fs/open.c:1356
       do_sys_open  fs/open.c:1372 [inline]
       __do_sys_openat  fs/open.c:1388 [inline]
       __se_sys_openat  fs/open.c:1383 [inline]
       __x64_sys_openat+0x143/0x200  fs/open.c:1383
       do_syscall_x64  arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3f/0x90  arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      Freed by task 20115:
       kasan_save_stack+0x22/0x50  mm/kasan/common.c:45
       kasan_set_track+0x25/0x30  mm/kasan/common.c:52
       kasan_save_free_info+0x2e/0x50  mm/kasan/generic.c:521
       ____kasan_slab_free  mm/kasan/common.c:236 [inline]
       ____kasan_slab_free  mm/kasan/common.c:200 [inline]
       __kasan_slab_free+0x10a/0x190  mm/kasan/common.c:244
       kasan_slab_free  include/linux/kasan.h:162 [inline]
       slab_free_hook  mm/slub.c:1781 [inline]
       slab_free_freelist_hook  mm/slub.c:1807 [inline]
       slab_free  mm/slub.c:3787 [inline]
       __kmem_cache_free+0x7a/0x190  mm/slub.c:3800
       local_release  net/nfc/llcp_core.c:174 [inline]
       kref_put  include/linux/kref.h:65 [inline]
       nfc_llcp_local_put  net/nfc/llcp_core.c:182 [inline]
       nfc_llcp_local_put  net/nfc/llcp_core.c:177 [inline]
       nfc_llcp_unregister_device+0x206/0x290  net/nfc/llcp_core.c:1620
       nfc_unregister_device+0x160/0x1d0  net/nfc/core.c:1179
       virtual_ncidev_close+0x52/0xa0  drivers/nfc/virtual_ncidev.c:163
       __fput+0x252/0xa20  fs/file_table.c:321
       task_work_run+0x174/0x270  kernel/task_work.c:179
       resume_user_mode_work  include/linux/resume_user_mode.h:49 [inline]
       exit_to_user_mode_loop  kernel/entry/common.c:171 [inline]
       exit_to_user_mode_prepare+0x108/0x110  kernel/entry/common.c:204
       __syscall_exit_to_user_mode_work  kernel/entry/common.c:286 [inline]
       syscall_exit_to_user_mode+0x21/0x50  kernel/entry/common.c:297
       do_syscall_64+0x4c/0x90  arch/x86/entry/common.c:86
       entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      Last potentially related work creation:
       kasan_save_stack+0x22/0x50  mm/kasan/common.c:45
       __kasan_record_aux_stack+0x95/0xb0  mm/kasan/generic.c:491
       kvfree_call_rcu+0x29/0xa80  kernel/rcu/tree.c:3328
       drop_sysctl_table+0x3be/0x4e0  fs/proc/proc_sysctl.c:1735
       unregister_sysctl_table.part.0+0x9c/0x190  fs/proc/proc_sysctl.c:1773
       unregister_sysctl_table+0x24/0x30  fs/proc/proc_sysctl.c:1753
       neigh_sysctl_unregister+0x5f/0x80  net/core/neighbour.c:3895
       addrconf_notify+0x140/0x17b0  net/ipv6/addrconf.c:3684
       notifier_call_chain+0xbe/0x210  kernel/notifier.c:87
       call_netdevice_notifiers_info+0xb5/0x150  net/core/dev.c:1937
       call_netdevice_notifiers_extack  net/core/dev.c:1975 [inline]
       call_netdevice_notifiers  net/core/dev.c:1989 [inline]
       dev_change_name+0x3c3/0x870  net/core/dev.c:1211
       dev_ifsioc+0x800/0xf70  net/core/dev_ioctl.c:376
       dev_ioctl+0x3d9/0xf80  net/core/dev_ioctl.c:542
       sock_do_ioctl+0x160/0x260  net/socket.c:1213
       sock_ioctl+0x3f9/0x670  net/socket.c:1316
       vfs_ioctl  fs/ioctl.c:51 [inline]
       __do_sys_ioctl  fs/ioctl.c:870 [inline]
       __se_sys_ioctl  fs/ioctl.c:856 [inline]
       __x64_sys_ioctl+0x19e/0x210  fs/ioctl.c:856
       do_syscall_x64  arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3f/0x90  arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      The buggy address belongs to the object at ffff888105b0e400
       which belongs to the cache kmalloc-1k of size 1024
      The buggy address is located 16 bytes inside of
       freed 1024-byte region [ffff888105b0e400, ffff888105b0e800)
      
      The buggy address belongs to the physical page:
      head:ffffea000416c200 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
      flags: 0x200000000010200(slab|head|node=0|zone=2)
      raw: 0200000000010200 ffff8881000430c0 ffffea00044c7010 ffffea0004510e10
      raw: 0000000000000000 00000000000a000a 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
       ffff888105b0e300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
       ffff888105b0e380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      >ffff888105b0e400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
       ffff888105b0e480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       ffff888105b0e500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      
      In summary, this patch solves those use-after-free by
      
      1. Re-implement the nfc_llcp_find_local(). The current version does not
      grab the reference when getting the local from the linked list.  For
      example, the llcp_sock_bind() gets the reference like below:
      
      // llcp_sock_bind()
      
          local = nfc_llcp_find_local(dev); // A
          ..... \
                 | raceable
          ..... /
          llcp_sock->local = nfc_llcp_local_get(local); // B
      
      There is an apparent race window that one can  drop the reference
      and free the local object fetched in (A) before (B) gets the reference.
      
      2. Some callers of the nfc_llcp_find_local() do not grab the reference
      at all. For example, the nfc_genl_llc_{{get/set}_params/sdreq} functions.
      We add the nfc_llcp_local_put() for them. Moreover, we add the necessary
      error handling function to put the reference.
      
      3. Add the nfc_llcp_remove_local() helper. The local object is removed
      from the linked list in local_release() when all reference is gone. This
      patch removes it when nfc_llcp_unregister_device() is called.
      
      Therefore, every caller of nfc_llcp_find_local() will get a reference
      even when the nfc_llcp_unregister_device() is called. This promises no
      use-after-free for the local object is ever possible.
      
      Fixes: 52feb444 ("NFC: Extend netlink interface for LTO, RW, and MIUX parameters support")
      Fixes: c7aa1225 ("NFC: Take a reference on the LLCP local pointer when creating a socket")
      Signed-off-by: NLin Ma <linma@zju.edu.cn>
      Reviewed-by: NSimon Horman <simon.horman@corigine.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NZiyang Xuan <william.xuanziyang@huawei.com>
      (cherry picked from commit d0ea613f)
      99ffc29e
    • K
      nfc: llcp: simplify llcp_sock_connect() error paths · 6920ebcc
      Krzysztof Kozlowski 提交于
      stable inclusion
      from stable-v5.10.188
      commit a3a1550c4d2e5fecbd317778ef2832e933d4774b
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I7NLJR
      CVE: CVE-2023-3863
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=a3a1550c4d2e5fecbd317778ef2832e933d4774b
      
      ---------------------------
      
      [ Upstream commit ec10fd15 ]
      
      The llcp_sock_connect() error paths were using a mixed way of central
      exit (goto) and cleanup
      Signed-off-by: NKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Stable-dep-of: 6709d4b7bc2e ("net: nfc: Fix use-after-free caused by nfc_llcp_find_local")
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NZiyang Xuan <william.xuanziyang@huawei.com>
      (cherry picked from commit 81636dc6)
      6920ebcc
    • O
      !1589 [sync] PR-1557: net/sched: cls_fw: Fix improper refcount update leads to use-after-free · f878aa7e
      openeuler-ci-bot 提交于
      Merge Pull Request from: @openeuler-sync-bot 
       
      
      Origin pull request: 
      https://gitee.com/openeuler/kernel/pulls/1557 
       
      PR sync from: Dong Chenchen <dongchenchen2@huawei.com>
      https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/233WCLKDGOFGUPF6WDFRIM426TVBRFML/ 
       
      https://gitee.com/src-openeuler/kernel/issues/I7N3N3 
       
      Link:https://gitee.com/openeuler/kernel/pulls/1589 
      
      Reviewed-by: Yue Haibing <yuehaibing@huawei.com> 
      Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com> 
      f878aa7e
    • O
      !1584 [sync] PR-1480: ksmbd: fix wrong UserName check in session_user · 6118e952
      openeuler-ci-bot 提交于
      Merge Pull Request from: @openeuler-sync-bot 
       
      
      Origin pull request: 
      https://gitee.com/openeuler/kernel/pulls/1480 
       
      PR sync from: Li Lingfeng <lilingfeng3@huawei.com>
      https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/Y2W37QUMGCXHZUAFBDA3UDH5CQW3KN2Z/ 
       
      https://gitee.com/src-openeuler/kernel/issues/I7LU3D 
       
      Link:https://gitee.com/openeuler/kernel/pulls/1584 
      
      Reviewed-by: Jialin Zhang <zhangjialin11@huawei.com> 
      Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com> 
      6118e952
    • O
      !1600 [sync] PR-1547: binder: fix UAF caused by faulty buffer cleanup · 1a1db7b2
      openeuler-ci-bot 提交于
      Merge Pull Request from: @openeuler-sync-bot 
       
      
      Origin pull request: 
      https://gitee.com/openeuler/kernel/pulls/1547 
       
      PR sync from: Longlong Xia <xialonglong1@huawei.com>
      https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/MRUYLTWKNNGDLYTDA5J4NZTSS63O4NQD/ 
       
      https://gitee.com/src-openeuler/kernel/issues/I7L0Z9 
       
      Link:https://gitee.com/openeuler/kernel/pulls/1600 
      
      Reviewed-by: Jialin Zhang <zhangjialin11@huawei.com> 
      Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com> 
      1a1db7b2
    • O
      !1603 [sync] PR-1581: psi: fix compile error for psi cgroupv1 when CONFIG_CGROUP=n · 75b43cab
      openeuler-ci-bot 提交于
      Merge Pull Request from: @openeuler-sync-bot 
       
      
      Origin pull request: 
      https://gitee.com/openeuler/kernel/pulls/1581 
       
      PR sync from: Lu Jialin <lujialin4@huawei.com>
      https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/PC6T7HRTE7LIGXV2HL57QYEPFKPNYTCX/ 
       
      https://gitee.com/openeuler/kernel/issues/I7OOZR 
       
      Link:https://gitee.com/openeuler/kernel/pulls/1603 
      
      Reviewed-by: Jialin Zhang <zhangjialin11@huawei.com> 
      Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com> 
      75b43cab
    • O
      !1616 [sync] PR-1591: net/sched: cls_u32: Fix reference counter leak leading to overflow · fed5a767
      openeuler-ci-bot 提交于
      Merge Pull Request from: @openeuler-sync-bot 
       
      
      Origin pull request: 
      https://gitee.com/openeuler/kernel/pulls/1591 
       
      PR sync from: Lu Wei <luwei32@huawei.com>
      https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/BHZDZMZMO33GAMZUG6UGXE75EWRFJO7B/ 
       
      https://gitee.com/src-openeuler/kernel/issues/I7N3N2 
       
      Link:https://gitee.com/openeuler/kernel/pulls/1616 
      
      Reviewed-by: Yue Haibing <yuehaibing@huawei.com> 
      Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com> 
      fed5a767
  7. 02 8月, 2023 2 次提交
  8. 01 8月, 2023 3 次提交
  9. 31 7月, 2023 13 次提交
    • C
      ksmbd: fix global-out-of-bounds in smb2_find_context_vals · dff38610
      Chih-Yen Chang 提交于
      mainline inclusion
      from mainline-v6.4-rc2
      commit 02f76c40
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I7LU2N
      CVE: CVE-2023-38426
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=02f76c401d17e409ed45bf7887148fcc22c93c85
      
      --------------------------------
      
      Add tag_len argument in smb2_find_context_vals() to avoid out-of-bound
      read when create_context's name_len is larger than tag length.
      
      [    7.995411] ==================================================================
      [    7.995866] BUG: KASAN: global-out-of-bounds in memcmp+0x83/0xa0
      [    7.996248] Read of size 8 at addr ffffffff8258d940 by task kworker/0:0/7
      ...
      [    7.998191] Call Trace:
      [    7.998358]  <TASK>
      [    7.998503]  dump_stack_lvl+0x33/0x50
      [    7.998743]  print_report+0xcc/0x620
      [    7.999458]  kasan_report+0xae/0xe0
      [    7.999895]  kasan_check_range+0x35/0x1b0
      [    8.000152]  memcmp+0x83/0xa0
      [    8.000347]  smb2_find_context_vals+0xf7/0x1e0
      [    8.000635]  smb2_open+0x1df2/0x43a0
      [    8.006398]  handle_ksmbd_work+0x274/0x810
      [    8.006666]  process_one_work+0x419/0x760
      [    8.006922]  worker_thread+0x2a2/0x6f0
      [    8.007429]  kthread+0x160/0x190
      [    8.007946]  ret_from_fork+0x1f/0x30
      [    8.008181]  </TASK>
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NChih-Yen Chang <cc85nod@gmail.com>
      Acked-by: NNamjae Jeon <linkinjeon@kernel.org>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Signed-off-by: NLong Li <leo.lilong@huawei.com>
      (cherry picked from commit 1997409a)
      dff38610
    • M
      net/sched: cls_fw: Fix improper refcount update leads to use-after-free · 8a423144
      M A Ramdhan 提交于
      stable inclusion
      from stable-v5.10.187
      commit 80e0e8d5f54397c5048fa2274144134dd9dc91b5
      category: bugfix
      bugzilla: 189032,https://gitee.com/src-openeuler/kernel/issues/I7N3N3
      CVE: CVE-2023-3776
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=80e0e8d5f54397c5048fa2274144134dd9dc91b5
      
      ---------------------------
      
      [ Upstream commit 0323bce598eea038714f941ce2b22541c46d488f ]
      
      In the event of a failure in tcf_change_indev(), fw_set_parms() will
      immediately return an error after incrementing or decrementing
      reference counter in tcf_bind_filter().  If attacker can control
      reference counter to zero and make reference freed, leading to
      use after free.
      
      In order to prevent this, move the point of possible failure above the
      point where the TC_FW_CLASSID is handled.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Reported-by: NM A Ramdhan <ramdhan@starlabs.sg>
      Signed-off-by: NM A Ramdhan <ramdhan@starlabs.sg>
      Acked-by: NJamal Hadi Salim <jhs@mojatatu.com>
      Reviewed-by: NPedro Tammela <pctammela@mojatatu.com>
      Message-ID: <20230705161530.52003-1-ramdhan@starlabs.sg>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NDong Chenchen <dongchenchen2@huawei.com>
      (cherry picked from commit 85657d6d)
      8a423144
    • C
      ksmbd: fix wrong UserName check in session_user · 22adac10
      Chih-Yen Chang 提交于
      mainline inclusion
      from mainline-v6.4-rc3
      commit f0a96d1a
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I7LU3D
      CVE: CVE-2023-38428
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/fs/ksmbd?id=f0a96d1aafd8964e1f9955c830a3e5cb3c60a90f
      
      --------------------------------
      
      The offset of UserName is related to the address of security
      buffer. To ensure the validaty of UserName, we need to compare name_off
      + name_len with secbuf_len instead of auth_msg_len.
      
      [   27.096243] ==================================================================
      [   27.096890] BUG: KASAN: slab-out-of-bounds in smb_strndup_from_utf16+0x188/0x350
      [   27.097609] Read of size 2 at addr ffff888005e3b542 by task kworker/0:0/7
      ...
      [   27.099950] Call Trace:
      [   27.100194]  <TASK>
      [   27.100397]  dump_stack_lvl+0x33/0x50
      [   27.100752]  print_report+0xcc/0x620
      [   27.102305]  kasan_report+0xae/0xe0
      [   27.103072]  kasan_check_range+0x35/0x1b0
      [   27.103757]  smb_strndup_from_utf16+0x188/0x350
      [   27.105474]  smb2_sess_setup+0xaf8/0x19c0
      [   27.107935]  handle_ksmbd_work+0x274/0x810
      [   27.108315]  process_one_work+0x419/0x760
      [   27.108689]  worker_thread+0x2a2/0x6f0
      [   27.109385]  kthread+0x160/0x190
      [   27.110129]  ret_from_fork+0x1f/0x30
      [   27.110454]  </TASK>
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NChih-Yen Chang <cc85nod@gmail.com>
      Acked-by: NNamjae Jeon <linkinjeon@kernel.org>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Signed-off-by: NLi Lingfeng <lilingfeng3@huawei.com>
      (cherry picked from commit 2a2a280a)
      22adac10
    • F
      can: esd_usb: Allow REC and TEC to return to zero · 14ea8b68
      Frank Jungclaus 提交于
      stable inclusion
      from stable-v5.10.159
      commit 4fd6f84e0a0c432d1acc56b7ae76e7676587081d
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I7NTXH
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=4fd6f84e0a0c432d1acc56b7ae76e7676587081d
      
      --------------------------------
      
      [ Upstream commit 918ee491 ]
      
      We don't get any further EVENT from an esd CAN USB device for changes
      on REC or TEC while those counters converge to 0 (with ecc == 0). So
      when handling the "Back to Error Active"-event force txerr = rxerr =
      0, otherwise the berr-counters might stay on values like 95 forever.
      
      Also, to make life easier during the ongoing development a
      netdev_dbg() has been introduced to allow dumping error events send by
      an esd CAN USB device.
      
      Fixes: 96d8e903 ("can: Add driver for esd CAN-USB/2 device")
      Signed-off-by: NFrank Jungclaus <frank.jungclaus@esd.eu>
      Link: https://lore.kernel.org/all/20221130202242.3998219-2-frank.jungclaus@esd.eu
      Cc: stable@vger.kernel.org
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
      (cherry picked from commit 82e4861c)
      14ea8b68
    • E
      macsec: add missing attribute validation for offload · ad4e3b43
      Emeel Hakim 提交于
      stable inclusion
      from stable-v5.10.159
      commit cf0e42310648a23188a411f7287dd95599086fce
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I7NTXH
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=cf0e42310648a23188a411f7287dd95599086fce
      
      --------------------------------
      
      [ Upstream commit 38099024 ]
      
      Add missing attribute validation for IFLA_MACSEC_OFFLOAD
      to the netlink policy.
      
      Fixes: 791bb3fc ("net: macsec: add support for specifying offload upon link creation")
      Signed-off-by: NEmeel Hakim <ehakim@nvidia.com>
      Reviewed-by: NJiri Pirko <jiri@nvidia.com>
      Reviewed-by: NSabrina Dubroca <sd@queasysnail.net>
      Link: https://lore.kernel.org/r/20221207101618.989-1-ehakim@nvidia.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
      (cherry picked from commit 3208e0ec)
      ad4e3b43
    • D
      net: mvneta: Fix an out of bounds check · e1d15b99
      Dan Carpenter 提交于
      stable inclusion
      from stable-v5.10.159
      commit 6b03e41767c7125d36c2fc4b59dd3ccc5da0738e
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I7NTXH
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6b03e41767c7125d36c2fc4b59dd3ccc5da0738e
      
      --------------------------------
      
      [ Upstream commit cdd97383 ]
      
      In an earlier commit, I added a bounds check to prevent an out of bounds
      read and a WARN().  On further discussion and consideration that check
      was probably too aggressive.  Instead of returning -EINVAL, a better fix
      would be to just prevent the out of bounds read but continue the process.
      
      Background: The value of "pp->rxq_def" is a number between 0-7 by default,
      or even higher depending on the value of "rxq_number", which is a module
      parameter. If the value is more than the number of available CPUs then
      it will trigger the WARN() in cpu_max_bits_warn().
      
      Fixes: e8b4fc13 ("net: mvneta: Prevent out of bounds read in mvneta_config_rss()")
      Signed-off-by: NDan Carpenter <error27@gmail.com>
      Reviewed-by: NLeon Romanovsky <leonro@nvidia.com>
      Link: https://lore.kernel.org/r/Y5A7d1E5ccwHTYPf@kadamSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
      (cherry picked from commit 52664784)
      e1d15b99
    • E
      ipv6: avoid use-after-free in ip6_fragment() · e49e8c49
      Eric Dumazet 提交于
      stable inclusion
      from stable-v5.10.159
      commit 8208d7e56b1e579320b9ff3712739ad2e63e1f86
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I7NTXH
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=8208d7e56b1e579320b9ff3712739ad2e63e1f86
      
      --------------------------------
      
      [ Upstream commit 803e8486 ]
      
      Blamed commit claimed rcu_read_lock() was held by ip6_fragment() callers.
      
      It seems to not be always true, at least for UDP stack.
      
      syzbot reported:
      
      BUG: KASAN: use-after-free in ip6_dst_idev include/net/ip6_fib.h:245 [inline]
      BUG: KASAN: use-after-free in ip6_fragment+0x2724/0x2770 net/ipv6/ip6_output.c:951
      Read of size 8 at addr ffff88801d403e80 by task syz-executor.3/7618
      
      CPU: 1 PID: 7618 Comm: syz-executor.3 Not tainted 6.1.0-rc6-syzkaller-00012-g4312098b #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/0x45d mm/kasan/report.c:395
       kasan_report+0xbf/0x1f0 mm/kasan/report.c:495
       ip6_dst_idev include/net/ip6_fib.h:245 [inline]
       ip6_fragment+0x2724/0x2770 net/ipv6/ip6_output.c:951
       __ip6_finish_output net/ipv6/ip6_output.c:193 [inline]
       ip6_finish_output+0x9a3/0x1170 net/ipv6/ip6_output.c:206
       NF_HOOK_COND include/linux/netfilter.h:291 [inline]
       ip6_output+0x1f1/0x540 net/ipv6/ip6_output.c:227
       dst_output include/net/dst.h:445 [inline]
       ip6_local_out+0xb3/0x1a0 net/ipv6/output_core.c:161
       ip6_send_skb+0xbb/0x340 net/ipv6/ip6_output.c:1966
       udp_v6_send_skb+0x82a/0x18a0 net/ipv6/udp.c:1286
       udp_v6_push_pending_frames+0x140/0x200 net/ipv6/udp.c:1313
       udpv6_sendmsg+0x18da/0x2c80 net/ipv6/udp.c:1606
       inet6_sendmsg+0x9d/0xe0 net/ipv6/af_inet6.c:665
       sock_sendmsg_nosec net/socket.c:714 [inline]
       sock_sendmsg+0xd3/0x120 net/socket.c:734
       sock_write_iter+0x295/0x3d0 net/socket.c:1108
       call_write_iter include/linux/fs.h:2191 [inline]
       new_sync_write fs/read_write.c:491 [inline]
       vfs_write+0x9ed/0xdd0 fs/read_write.c:584
       ksys_write+0x1ec/0x250 fs/read_write.c:637
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      RIP: 0033:0x7fde3588c0d9
      Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007fde365b6168 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
      RAX: ffffffffffffffda RBX: 00007fde359ac050 RCX: 00007fde3588c0d9
      RDX: 000000000000ffdc RSI: 00000000200000c0 RDI: 000000000000000a
      RBP: 00007fde358e7ae9 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
      R13: 00007fde35acfb1f R14: 00007fde365b6300 R15: 0000000000022000
       </TASK>
      
      Allocated by task 7618:
       kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
       kasan_set_track+0x25/0x30 mm/kasan/common.c:52
       __kasan_slab_alloc+0x82/0x90 mm/kasan/common.c:325
       kasan_slab_alloc include/linux/kasan.h:201 [inline]
       slab_post_alloc_hook mm/slab.h:737 [inline]
       slab_alloc_node mm/slub.c:3398 [inline]
       slab_alloc mm/slub.c:3406 [inline]
       __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
       kmem_cache_alloc+0x2b4/0x3d0 mm/slub.c:3422
       dst_alloc+0x14a/0x1f0 net/core/dst.c:92
       ip6_dst_alloc+0x32/0xa0 net/ipv6/route.c:344
       ip6_rt_pcpu_alloc net/ipv6/route.c:1369 [inline]
       rt6_make_pcpu_route net/ipv6/route.c:1417 [inline]
       ip6_pol_route+0x901/0x1190 net/ipv6/route.c:2254
       pol_lookup_func include/net/ip6_fib.h:582 [inline]
       fib6_rule_lookup+0x52e/0x6f0 net/ipv6/fib6_rules.c:121
       ip6_route_output_flags_noref+0x2e6/0x380 net/ipv6/route.c:2625
       ip6_route_output_flags+0x76/0x320 net/ipv6/route.c:2638
       ip6_route_output include/net/ip6_route.h:98 [inline]
       ip6_dst_lookup_tail+0x5ab/0x1620 net/ipv6/ip6_output.c:1092
       ip6_dst_lookup_flow+0x90/0x1d0 net/ipv6/ip6_output.c:1222
       ip6_sk_dst_lookup_flow+0x553/0x980 net/ipv6/ip6_output.c:1260
       udpv6_sendmsg+0x151d/0x2c80 net/ipv6/udp.c:1554
       inet6_sendmsg+0x9d/0xe0 net/ipv6/af_inet6.c:665
       sock_sendmsg_nosec net/socket.c:714 [inline]
       sock_sendmsg+0xd3/0x120 net/socket.c:734
       __sys_sendto+0x23a/0x340 net/socket.c:2117
       __do_sys_sendto net/socket.c:2129 [inline]
       __se_sys_sendto net/socket.c:2125 [inline]
       __x64_sys_sendto+0xe1/0x1b0 net/socket.c:2125
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Freed by task 7599:
       kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
       kasan_set_track+0x25/0x30 mm/kasan/common.c:52
       kasan_save_free_info+0x2e/0x40 mm/kasan/generic.c:511
       ____kasan_slab_free mm/kasan/common.c:236 [inline]
       ____kasan_slab_free+0x160/0x1c0 mm/kasan/common.c:200
       kasan_slab_free include/linux/kasan.h:177 [inline]
       slab_free_hook mm/slub.c:1724 [inline]
       slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1750
       slab_free mm/slub.c:3661 [inline]
       kmem_cache_free+0xee/0x5c0 mm/slub.c:3683
       dst_destroy+0x2ea/0x400 net/core/dst.c:127
       rcu_do_batch kernel/rcu/tree.c:2250 [inline]
       rcu_core+0x81f/0x1980 kernel/rcu/tree.c:2510
       __do_softirq+0x1fb/0xadc kernel/softirq.c:571
      
      Last potentially related work creation:
       kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
       __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:481
       call_rcu+0x9d/0x820 kernel/rcu/tree.c:2798
       dst_release net/core/dst.c:177 [inline]
       dst_release+0x7d/0xe0 net/core/dst.c:167
       refdst_drop include/net/dst.h:256 [inline]
       skb_dst_drop include/net/dst.h:268 [inline]
       skb_release_head_state+0x250/0x2a0 net/core/skbuff.c:838
       skb_release_all net/core/skbuff.c:852 [inline]
       __kfree_skb net/core/skbuff.c:868 [inline]
       kfree_skb_reason+0x151/0x4b0 net/core/skbuff.c:891
       kfree_skb_list_reason+0x4b/0x70 net/core/skbuff.c:901
       kfree_skb_list include/linux/skbuff.h:1227 [inline]
       ip6_fragment+0x2026/0x2770 net/ipv6/ip6_output.c:949
       __ip6_finish_output net/ipv6/ip6_output.c:193 [inline]
       ip6_finish_output+0x9a3/0x1170 net/ipv6/ip6_output.c:206
       NF_HOOK_COND include/linux/netfilter.h:291 [inline]
       ip6_output+0x1f1/0x540 net/ipv6/ip6_output.c:227
       dst_output include/net/dst.h:445 [inline]
       ip6_local_out+0xb3/0x1a0 net/ipv6/output_core.c:161
       ip6_send_skb+0xbb/0x340 net/ipv6/ip6_output.c:1966
       udp_v6_send_skb+0x82a/0x18a0 net/ipv6/udp.c:1286
       udp_v6_push_pending_frames+0x140/0x200 net/ipv6/udp.c:1313
       udpv6_sendmsg+0x18da/0x2c80 net/ipv6/udp.c:1606
       inet6_sendmsg+0x9d/0xe0 net/ipv6/af_inet6.c:665
       sock_sendmsg_nosec net/socket.c:714 [inline]
       sock_sendmsg+0xd3/0x120 net/socket.c:734
       sock_write_iter+0x295/0x3d0 net/socket.c:1108
       call_write_iter include/linux/fs.h:2191 [inline]
       new_sync_write fs/read_write.c:491 [inline]
       vfs_write+0x9ed/0xdd0 fs/read_write.c:584
       ksys_write+0x1ec/0x250 fs/read_write.c:637
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Second to last potentially related work creation:
       kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
       __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:481
       call_rcu+0x9d/0x820 kernel/rcu/tree.c:2798
       dst_release net/core/dst.c:177 [inline]
       dst_release+0x7d/0xe0 net/core/dst.c:167
       refdst_drop include/net/dst.h:256 [inline]
       skb_dst_drop include/net/dst.h:268 [inline]
       __dev_queue_xmit+0x1b9d/0x3ba0 net/core/dev.c:4211
       dev_queue_xmit include/linux/netdevice.h:3008 [inline]
       neigh_resolve_output net/core/neighbour.c:1552 [inline]
       neigh_resolve_output+0x51b/0x840 net/core/neighbour.c:1532
       neigh_output include/net/neighbour.h:546 [inline]
       ip6_finish_output2+0x56c/0x1530 net/ipv6/ip6_output.c:134
       __ip6_finish_output net/ipv6/ip6_output.c:195 [inline]
       ip6_finish_output+0x694/0x1170 net/ipv6/ip6_output.c:206
       NF_HOOK_COND include/linux/netfilter.h:291 [inline]
       ip6_output+0x1f1/0x540 net/ipv6/ip6_output.c:227
       dst_output include/net/dst.h:445 [inline]
       NF_HOOK include/linux/netfilter.h:302 [inline]
       NF_HOOK include/linux/netfilter.h:296 [inline]
       mld_sendpack+0xa09/0xe70 net/ipv6/mcast.c:1820
       mld_send_cr net/ipv6/mcast.c:2121 [inline]
       mld_ifc_work+0x720/0xdc0 net/ipv6/mcast.c:2653
       process_one_work+0x9bf/0x1710 kernel/workqueue.c:2289
       worker_thread+0x669/0x1090 kernel/workqueue.c:2436
       kthread+0x2e8/0x3a0 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
      
      The buggy address belongs to the object at ffff88801d403dc0
       which belongs to the cache ip6_dst_cache of size 240
      The buggy address is located 192 bytes inside of
       240-byte region [ffff88801d403dc0, ffff88801d403eb0)
      
      The buggy address belongs to the physical page:
      page:ffffea00007500c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1d403
      memcg:ffff888022f49c81
      flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
      raw: 00fff00000000200 ffffea0001ef6580 dead000000000002 ffff88814addf640
      raw: 0000000000000000 00000000800c000c 00000001ffffffff ffff888022f49c81
      page dumped because: kasan: bad access detected
      page_owner tracks the page as allocated
      page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL), pid 3719, tgid 3719 (kworker/0:6), ts 136223432244, free_ts 136222971441
       prep_new_page mm/page_alloc.c:2539 [inline]
       get_page_from_freelist+0x10b5/0x2d50 mm/page_alloc.c:4288
       __alloc_pages+0x1cb/0x5b0 mm/page_alloc.c:5555
       alloc_pages+0x1aa/0x270 mm/mempolicy.c:2285
       alloc_slab_page mm/slub.c:1794 [inline]
       allocate_slab+0x213/0x300 mm/slub.c:1939
       new_slab mm/slub.c:1992 [inline]
       ___slab_alloc+0xa91/0x1400 mm/slub.c:3180
       __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3279
       slab_alloc_node mm/slub.c:3364 [inline]
       slab_alloc mm/slub.c:3406 [inline]
       __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
       kmem_cache_alloc+0x31a/0x3d0 mm/slub.c:3422
       dst_alloc+0x14a/0x1f0 net/core/dst.c:92
       ip6_dst_alloc+0x32/0xa0 net/ipv6/route.c:344
       icmp6_dst_alloc+0x71/0x680 net/ipv6/route.c:3261
       mld_sendpack+0x5de/0xe70 net/ipv6/mcast.c:1809
       mld_send_cr net/ipv6/mcast.c:2121 [inline]
       mld_ifc_work+0x720/0xdc0 net/ipv6/mcast.c:2653
       process_one_work+0x9bf/0x1710 kernel/workqueue.c:2289
       worker_thread+0x669/0x1090 kernel/workqueue.c:2436
       kthread+0x2e8/0x3a0 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
      page last free stack trace:
       reset_page_owner include/linux/page_owner.h:24 [inline]
       free_pages_prepare mm/page_alloc.c:1459 [inline]
       free_pcp_prepare+0x65c/0xd90 mm/page_alloc.c:1509
       free_unref_page_prepare mm/page_alloc.c:3387 [inline]
       free_unref_page+0x1d/0x4d0 mm/page_alloc.c:3483
       __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2586
       qlink_free mm/kasan/quarantine.c:168 [inline]
       qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187
       kasan_quarantine_reduce+0x184/0x210 mm/kasan/quarantine.c:294
       __kasan_slab_alloc+0x66/0x90 mm/kasan/common.c:302
       kasan_slab_alloc include/linux/kasan.h:201 [inline]
       slab_post_alloc_hook mm/slab.h:737 [inline]
       slab_alloc_node mm/slub.c:3398 [inline]
       kmem_cache_alloc_node+0x304/0x410 mm/slub.c:3443
       __alloc_skb+0x214/0x300 net/core/skbuff.c:497
       alloc_skb include/linux/skbuff.h:1267 [inline]
       netlink_alloc_large_skb net/netlink/af_netlink.c:1191 [inline]
       netlink_sendmsg+0x9a6/0xe10 net/netlink/af_netlink.c:1896
       sock_sendmsg_nosec net/socket.c:714 [inline]
       sock_sendmsg+0xd3/0x120 net/socket.c:734
       __sys_sendto+0x23a/0x340 net/socket.c:2117
       __do_sys_sendto net/socket.c:2129 [inline]
       __se_sys_sendto net/socket.c:2125 [inline]
       __x64_sys_sendto+0xe1/0x1b0 net/socket.c:2125
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Fixes: 1758fd46 ("ipv6: remove unnecessary dst_hold() in ip6_fragment()")
      Reported-by: syzbot+8c0ac31aa9681abb9e2d@syzkaller.appspotmail.com
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Cc: Wei Wang <weiwan@google.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Link: https://lore.kernel.org/r/20221206101351.2037285-1-edumazet@google.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
      (cherry picked from commit 55c08155)
      e49e8c49
    • Y
      net: plip: don't call kfree_skb/dev_kfree_skb() under spin_lock_irq() · c3f86364
      Yang Yingliang 提交于
      stable inclusion
      from stable-v5.10.159
      commit 3d59adad126d0f22e06506449f530fcc16277e61
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I7NTXH
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=3d59adad126d0f22e06506449f530fcc16277e61
      
      --------------------------------
      
      [ Upstream commit 7d8c19bf ]
      
      It is not allowed to call kfree_skb() or consume_skb() from
      hardware interrupt context or with interrupts being disabled.
      So replace kfree_skb/dev_kfree_skb() with dev_kfree_skb_irq()
      and dev_consume_skb_irq() under spin_lock_irq().
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: NJiri Pirko <jiri@nvidia.com>
      Link: https://lore.kernel.org/r/20221207015310.2984909-1-yangyingliang@huawei.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
      (cherry picked from commit 3bd674f7)
      c3f86364
    • Z
      ethernet: aeroflex: fix potential skb leak in greth_init_rings() · 3e45f419
      Zhang Changzhong 提交于
      stable inclusion
      from stable-v5.10.159
      commit 87277bdf2c370ab2d07cfe77dfa9b37f82bbe1e5
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I7NTXH
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=87277bdf2c370ab2d07cfe77dfa9b37f82bbe1e5
      
      --------------------------------
      
      [ Upstream commit 063a932b ]
      
      The greth_init_rings() function won't free the newly allocated skb when
      dma_mapping_error() returns error, so add dev_kfree_skb() to fix it.
      
      Compile tested only.
      
      Fixes: d4c41139 ("net: Add Aeroflex Gaisler 10/100/1G Ethernet MAC driver")
      Signed-off-by: NZhang Changzhong <zhangchangzhong@huawei.com>
      Reviewed-by: NLeon Romanovsky <leonro@nvidia.com>
      Link: https://lore.kernel.org/r/1670134149-29516-1-git-send-email-zhangchangzhong@huawei.comSigned-off-by: NPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
      (cherry picked from commit c3862675)
      3e45f419
    • X
      tipc: call tipc_lxc_xmit without holding node_read_lock · 0adee5ba
      Xin Long 提交于
      stable inclusion
      from stable-v5.10.159
      commit cc668fddde4262f608baca2c9d85b9cf333e41c3
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I7NTXH
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=cc668fddde4262f608baca2c9d85b9cf333e41c3
      
      --------------------------------
      
      [ Upstream commit 88956177 ]
      
      When sending packets between nodes in netns, it calls tipc_lxc_xmit() for
      peer node to receive the packets where tipc_sk_mcast_rcv()/tipc_sk_rcv()
      might be called, and it's pretty much like in tipc_rcv().
      
      Currently the local 'node rw lock' is held during calling tipc_lxc_xmit()
      to protect the peer_net not being freed by another thread. However, when
      receiving these packets, tipc_node_add_conn() might be called where the
      peer 'node rw lock' is acquired. Then a dead lock warning is triggered by
      lockdep detector, although it is not a real dead lock:
      
          WARNING: possible recursive locking detected
          --------------------------------------------
          conn_server/1086 is trying to acquire lock:
          ffff8880065cb020 (&n->lock#2){++--}-{2:2}, \
                           at: tipc_node_add_conn.cold.76+0xaa/0x211 [tipc]
      
          but task is already holding lock:
          ffff8880065cd020 (&n->lock#2){++--}-{2:2}, \
                           at: tipc_node_xmit+0x285/0xb30 [tipc]
      
          other info that might help us debug this:
           Possible unsafe locking scenario:
      
                 CPU0
                 ----
            lock(&n->lock#2);
            lock(&n->lock#2);
      
           *** DEADLOCK ***
      
           May be due to missing lock nesting notation
      
          4 locks held by conn_server/1086:
           #0: ffff8880036d1e40 (sk_lock-AF_TIPC){+.+.}-{0:0}, \
                                at: tipc_accept+0x9c0/0x10b0 [tipc]
           #1: ffff8880036d5f80 (sk_lock-AF_TIPC/1){+.+.}-{0:0}, \
                                at: tipc_accept+0x363/0x10b0 [tipc]
           #2: ffff8880065cd020 (&n->lock#2){++--}-{2:2}, \
                                at: tipc_node_xmit+0x285/0xb30 [tipc]
           #3: ffff888012e13370 (slock-AF_TIPC){+...}-{2:2}, \
                                at: tipc_sk_rcv+0x2da/0x1b40 [tipc]
      
          Call Trace:
           <TASK>
           dump_stack_lvl+0x44/0x5b
           __lock_acquire.cold.77+0x1f2/0x3d7
           lock_acquire+0x1d2/0x610
           _raw_write_lock_bh+0x38/0x80
           tipc_node_add_conn.cold.76+0xaa/0x211 [tipc]
           tipc_sk_finish_conn+0x21e/0x640 [tipc]
           tipc_sk_filter_rcv+0x147b/0x3030 [tipc]
           tipc_sk_rcv+0xbb4/0x1b40 [tipc]
           tipc_lxc_xmit+0x225/0x26b [tipc]
           tipc_node_xmit.cold.82+0x4a/0x102 [tipc]
           __tipc_sendstream+0x879/0xff0 [tipc]
           tipc_accept+0x966/0x10b0 [tipc]
           do_accept+0x37d/0x590
      
      This patch avoids this warning by not holding the 'node rw lock' before
      calling tipc_lxc_xmit(). As to protect the 'peer_net', rcu_read_lock()
      should be enough, as in cleanup_net() when freeing the netns, it calls
      synchronize_rcu() before the free is continued.
      
      Also since tipc_lxc_xmit() is like the RX path in tipc_rcv(), it makes
      sense to call it under rcu_read_lock(). Note that the right lock order
      must be:
      
         rcu_read_lock();
         tipc_node_read_lock(n);
         tipc_node_read_unlock(n);
         tipc_lxc_xmit();
         rcu_read_unlock();
      
      instead of:
      
         tipc_node_read_lock(n);
         rcu_read_lock();
         tipc_node_read_unlock(n);
         tipc_lxc_xmit();
         rcu_read_unlock();
      
      and we have to call tipc_node_read_lock/unlock() twice in
      tipc_node_xmit().
      
      Fixes: f73b1281 ("tipc: improve throughput between nodes in netns")
      Reported-by: NShuang Li <shuali@redhat.com>
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Link: https://lore.kernel.org/r/5bdd1f8fee9db695cfff4528a48c9b9d0523fb00.1670110641.git.lucien.xin@gmail.comSigned-off-by: NPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
      (cherry picked from commit 30d020f3)
      0adee5ba
    • Z
      net: dsa: sja1105: fix memory leak in sja1105_setup_devlink_regions() · ab3b4198
      Zhengchao Shao 提交于
      stable inclusion
      from stable-v5.10.159
      commit 4be43e46c3f945fc7dd9e23c73a7a66927a3b814
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I7NTXH
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=4be43e46c3f945fc7dd9e23c73a7a66927a3b814
      
      --------------------------------
      
      [ Upstream commit 78a9ea43 ]
      
      When dsa_devlink_region_create failed in sja1105_setup_devlink_regions(),
      priv->regions is not released.
      
      Fixes: bf425b82 ("net: dsa: sja1105: expose static config as devlink region")
      Signed-off-by: NZhengchao Shao <shaozhengchao@huawei.com>
      Reviewed-by: NVladimir Oltean <olteanv@gmail.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20221205012132.2110979-1-shaozhengchao@huawei.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
      (cherry picked from commit 9c81b638)
      ab3b4198
    • I
      ipv4: Fix incorrect route flushing when table ID 0 is used · 93d0912e
      Ido Schimmel 提交于
      stable inclusion
      from stable-v5.10.159
      commit 8e3f9ac00956442ecfbdd4e6c5c731b8ab6f77a0
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I7NTXH
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=8e3f9ac00956442ecfbdd4e6c5c731b8ab6f77a0
      
      --------------------------------
      
      [ Upstream commit c0d99934 ]
      
      Cited commit added the table ID to the FIB info structure, but did not
      properly initialize it when table ID 0 is used. This can lead to a route
      in the default VRF with a preferred source address not being flushed
      when the address is deleted.
      
      Consider the following example:
      
       # ip address add dev dummy1 192.0.2.1/28
       # ip address add dev dummy1 192.0.2.17/28
       # ip route add 198.51.100.0/24 via 192.0.2.2 src 192.0.2.17 metric 100
       # ip route add table 0 198.51.100.0/24 via 192.0.2.2 src 192.0.2.17 metric 200
       # ip route show 198.51.100.0/24
       198.51.100.0/24 via 192.0.2.2 dev dummy1 src 192.0.2.17 metric 100
       198.51.100.0/24 via 192.0.2.2 dev dummy1 src 192.0.2.17 metric 200
      
      Both routes are installed in the default VRF, but they are using two
      different FIB info structures. One with a metric of 100 and table ID of
      254 (main) and one with a metric of 200 and table ID of 0. Therefore,
      when the preferred source address is deleted from the default VRF,
      the second route is not flushed:
      
       # ip address del dev dummy1 192.0.2.17/28
       # ip route show 198.51.100.0/24
       198.51.100.0/24 via 192.0.2.2 dev dummy1 src 192.0.2.17 metric 200
      
      Fix by storing a table ID of 254 instead of 0 in the route configuration
      structure.
      
      Add a test case that fails before the fix:
      
       # ./fib_tests.sh -t ipv4_del_addr
      
       IPv4 delete address route tests
           Regular FIB info
           TEST: Route removed from VRF when source address deleted            [ OK ]
           TEST: Route in default VRF not removed                              [ OK ]
           TEST: Route removed in default VRF when source address deleted      [ OK ]
           TEST: Route in VRF is not removed by address delete                 [ OK ]
           Identical FIB info with different table ID
           TEST: Route removed from VRF when source address deleted            [ OK ]
           TEST: Route in default VRF not removed                              [ OK ]
           TEST: Route removed in default VRF when source address deleted      [ OK ]
           TEST: Route in VRF is not removed by address delete                 [ OK ]
           Table ID 0
           TEST: Route removed in default VRF when source address deleted      [FAIL]
      
       Tests passed:   8
       Tests failed:   1
      
      And passes after:
      
       # ./fib_tests.sh -t ipv4_del_addr
      
       IPv4 delete address route tests
           Regular FIB info
           TEST: Route removed from VRF when source address deleted            [ OK ]
           TEST: Route in default VRF not removed                              [ OK ]
           TEST: Route removed in default VRF when source address deleted      [ OK ]
           TEST: Route in VRF is not removed by address delete                 [ OK ]
           Identical FIB info with different table ID
           TEST: Route removed from VRF when source address deleted            [ OK ]
           TEST: Route in default VRF not removed                              [ OK ]
           TEST: Route removed in default VRF when source address deleted      [ OK ]
           TEST: Route in VRF is not removed by address delete                 [ OK ]
           Table ID 0
           TEST: Route removed in default VRF when source address deleted      [ OK ]
      
       Tests passed:   9
       Tests failed:   0
      
      Fixes: 5a56a0b3 ("net: Don't delete routes in different VRFs")
      Reported-by: NDonald Sharp <sharpd@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: NDavid Ahern <dsahern@kernel.org>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
      (cherry picked from commit dd2ab3c3)
      93d0912e
    • I
      ipv4: Fix incorrect route flushing when source address is deleted · fcd2cb58
      Ido Schimmel 提交于
      stable inclusion
      from stable-v5.10.159
      commit 5211e5ff9ddc67e2cbd5af78e09b8e7d85ca95f2
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I7NTXH
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=5211e5ff9ddc67e2cbd5af78e09b8e7d85ca95f2
      
      --------------------------------
      
      [ Upstream commit f96a3d74 ]
      
      Cited commit added the table ID to the FIB info structure, but did not
      prevent structures with different table IDs from being consolidated.
      This can lead to routes being flushed from a VRF when an address is
      deleted from a different VRF.
      
      Fix by taking the table ID into account when looking for a matching FIB
      info. This is already done for FIB info structures backed by a nexthop
      object in fib_find_info_nh().
      
      Add test cases that fail before the fix:
      
       # ./fib_tests.sh -t ipv4_del_addr
      
       IPv4 delete address route tests
           Regular FIB info
           TEST: Route removed from VRF when source address deleted            [ OK ]
           TEST: Route in default VRF not removed                              [ OK ]
           TEST: Route removed in default VRF when source address deleted      [ OK ]
           TEST: Route in VRF is not removed by address delete                 [ OK ]
           Identical FIB info with different table ID
           TEST: Route removed from VRF when source address deleted            [FAIL]
           TEST: Route in default VRF not removed                              [ OK ]
       RTNETLINK answers: File exists
           TEST: Route removed in default VRF when source address deleted      [ OK ]
           TEST: Route in VRF is not removed by address delete                 [FAIL]
      
       Tests passed:   6
       Tests failed:   2
      
      And pass after:
      
       # ./fib_tests.sh -t ipv4_del_addr
      
       IPv4 delete address route tests
           Regular FIB info
           TEST: Route removed from VRF when source address deleted            [ OK ]
           TEST: Route in default VRF not removed                              [ OK ]
           TEST: Route removed in default VRF when source address deleted      [ OK ]
           TEST: Route in VRF is not removed by address delete                 [ OK ]
           Identical FIB info with different table ID
           TEST: Route removed from VRF when source address deleted            [ OK ]
           TEST: Route in default VRF not removed                              [ OK ]
           TEST: Route removed in default VRF when source address deleted      [ OK ]
           TEST: Route in VRF is not removed by address delete                 [ OK ]
      
       Tests passed:   8
       Tests failed:   0
      
      Fixes: 5a56a0b3 ("net: Don't delete routes in different VRFs")
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: NDavid Ahern <dsahern@kernel.org>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
      (cherry picked from commit ef22f90f)
      fcd2cb58