1. 10 5月, 2023 2 次提交
  2. 13 2月, 2023 1 次提交
  3. 06 7月, 2022 1 次提交
  4. 26 5月, 2022 1 次提交
    • J
      RDMA/cma: Do not change route.addr.src_addr outside state checks · b8f0f505
      Jason Gunthorpe 提交于
      stable inclusion
      from stable-v5.10.103
      commit 5b1cef5798b4fd6e4fd5522e7b8a26248beeacaa
      bugzilla: https://gitee.com/openeuler/kernel/issues/I56NE7
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=5b1cef5798b4fd6e4fd5522e7b8a26248beeacaa
      
      --------------------------------
      
      commit 22e9f710 upstream.
      
      If the state is not idle then resolve_prepare_src() should immediately
      fail and no change to global state should happen. However, it
      unconditionally overwrites the src_addr trying to build a temporary any
      address.
      
      For instance if the state is already RDMA_CM_LISTEN then this will corrupt
      the src_addr and would cause the test in cma_cancel_operation():
      
                 if (cma_any_addr(cma_src_addr(id_priv)) && !id_priv->cma_dev)
      
      Which would manifest as this trace from syzkaller:
      
        BUG: KASAN: use-after-free in __list_add_valid+0x93/0xa0 lib/list_debug.c:26
        Read of size 8 at addr ffff8881546491e0 by task syz-executor.1/32204
      
        CPU: 1 PID: 32204 Comm: syz-executor.1 Not tainted 5.12.0-rc8-syzkaller #0
        Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
        Call Trace:
         __dump_stack lib/dump_stack.c:79 [inline]
         dump_stack+0x141/0x1d7 lib/dump_stack.c:120
         print_address_description.constprop.0.cold+0x5b/0x2f8 mm/kasan/report.c:232
         __kasan_report mm/kasan/report.c:399 [inline]
         kasan_report.cold+0x7c/0xd8 mm/kasan/report.c:416
         __list_add_valid+0x93/0xa0 lib/list_debug.c:26
         __list_add include/linux/list.h:67 [inline]
         list_add_tail include/linux/list.h:100 [inline]
         cma_listen_on_all drivers/infiniband/core/cma.c:2557 [inline]
         rdma_listen+0x787/0xe00 drivers/infiniband/core/cma.c:3751
         ucma_listen+0x16a/0x210 drivers/infiniband/core/ucma.c:1102
         ucma_write+0x259/0x350 drivers/infiniband/core/ucma.c:1732
         vfs_write+0x28e/0xa30 fs/read_write.c:603
         ksys_write+0x1ee/0x250 fs/read_write.c:658
         do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
         entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      This is indicating that an rdma_id_private was destroyed without doing
      cma_cancel_listens().
      
      Instead of trying to re-use the src_addr memory to indirectly create an
      any address derived from the dst build one explicitly on the stack and
      bind to that as any other normal flow would do. rdma_bind_addr() will copy
      it over the src_addr once it knows the state is valid.
      
      This is similar to commit bc0bdc5a ("RDMA/cma: Do not change
      route.addr.src_addr.ss_family")
      
      Link: https://lore.kernel.org/r/0-v2-e975c8fd9ef2+11e-syz_cma_srcaddr_jgg@nvidia.com
      Cc: stable@vger.kernel.org
      Fixes: 732d41c5 ("RDMA/cma: Make the locking for automatic state transition more clear")
      Reported-by: syzbot+c94a3675a626f6333d74@syzkaller.appspotmail.com
      Reviewed-by: NLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: NJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NYu Liao <liaoyu15@huawei.com>
      Reviewed-by: NWei Li <liwei391@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      b8f0f505
  5. 17 5月, 2022 1 次提交
  6. 27 4月, 2022 1 次提交
  7. 15 11月, 2021 3 次提交
  8. 15 10月, 2021 1 次提交
  9. 13 10月, 2021 3 次提交
  10. 03 6月, 2021 2 次提交
    • S
      RDMA/core: Don't access cm_id after its destruction · 6299c0ed
      Shay Drory 提交于
      stable inclusion
      from stable-5.10.40
      commit bd538f2f136fe5463458351a5ae045ed0a201cae
      bugzilla: 51882
      CVE: NA
      
      --------------------------------
      
      [ Upstream commit 889d916b ]
      
      restrack should only be attached to a cm_id while the ID has a valid
      device pointer. It is set up when the device is first loaded, but not
      cleared when the device is removed. There is also two copies of the device
      pointer, one private and one in the public API, and these were left out of
      sync.
      
      Make everything go to NULL together and manipulate restrack right around
      the device assignments.
      
      Found by syzcaller:
      BUG: KASAN: wild-memory-access in __list_del include/linux/list.h:112 [inline]
      BUG: KASAN: wild-memory-access in __list_del_entry include/linux/list.h:135 [inline]
      BUG: KASAN: wild-memory-access in list_del include/linux/list.h:146 [inline]
      BUG: KASAN: wild-memory-access in cma_cancel_listens drivers/infiniband/core/cma.c:1767 [inline]
      BUG: KASAN: wild-memory-access in cma_cancel_operation drivers/infiniband/core/cma.c:1795 [inline]
      BUG: KASAN: wild-memory-access in cma_cancel_operation+0x1f4/0x4b0 drivers/infiniband/core/cma.c:1783
      Write of size 8 at addr dead000000000108 by task syz-executor716/334
      
      CPU: 0 PID: 334 Comm: syz-executor716 Not tainted 5.11.0+ #271
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
      rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
      Call Trace:
       __dump_stack lib/dump_stack.c:79 [inline]
       dump_stack+0xbe/0xf9 lib/dump_stack.c:120
       __kasan_report mm/kasan/report.c:400 [inline]
       kasan_report.cold+0x5f/0xd5 mm/kasan/report.c:413
       __list_del include/linux/list.h:112 [inline]
       __list_del_entry include/linux/list.h:135 [inline]
       list_del include/linux/list.h:146 [inline]
       cma_cancel_listens drivers/infiniband/core/cma.c:1767 [inline]
       cma_cancel_operation drivers/infiniband/core/cma.c:1795 [inline]
       cma_cancel_operation+0x1f4/0x4b0 drivers/infiniband/core/cma.c:1783
       _destroy_id+0x29/0x460 drivers/infiniband/core/cma.c:1862
       ucma_close_id+0x36/0x50 drivers/infiniband/core/ucma.c:185
       ucma_destroy_private_ctx+0x58d/0x5b0 drivers/infiniband/core/ucma.c:576
       ucma_close+0x91/0xd0 drivers/infiniband/core/ucma.c:1797
       __fput+0x169/0x540 fs/file_table.c:280
       task_work_run+0xb7/0x100 kernel/task_work.c:140
       exit_task_work include/linux/task_work.h:30 [inline]
       do_exit+0x7da/0x17f0 kernel/exit.c:825
       do_group_exit+0x9e/0x190 kernel/exit.c:922
       __do_sys_exit_group kernel/exit.c:933 [inline]
       __se_sys_exit_group kernel/exit.c:931 [inline]
       __x64_sys_exit_group+0x2d/0x30 kernel/exit.c:931
       do_syscall_64+0x2d/0x40 arch/x86/entry/common.c:46
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Fixes: 255d0c14 ("RDMA/cma: rdma_bind_addr() leaks a cma_dev reference count")
      Link: https://lore.kernel.org/r/3352ee288fe34f2b44220457a29bfc0548686363.1620711734.git.leonro@nvidia.comSigned-off-by: NShay Drory <shayd@nvidia.com>
      Signed-off-by: NLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: NJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NChen Jun <chenjun102@huawei.com>
      Acked-by: NWeilong Chen <chenweilong@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      6299c0ed
    • S
      RDMA/core: Add CM to restrack after successful attachment to a device · 8ca86a96
      Shay Drory 提交于
      stable inclusion
      from stable-5.10.37
      commit c5ebaca402f5c5bd61ac8316feb2aa3a0be4d4a8
      bugzilla: 51868
      CVE: NA
      
      --------------------------------
      
      [ Upstream commit cb5cd0ea ]
      
      The device attach triggers addition of CM_ID to the restrack DB.
      However, when error occurs, we releasing this device, but defer CM_ID
      release. This causes to the situation where restrack sees CM_ID that
      is not valid anymore.
      
      As a solution, add the CM_ID to the resource tracking DB only after the
      attachment is finished.
      
      Found by syzcaller:
      infiniband syz0: added syz_tun
      rdma_rxe: ignoring netdev event = 10 for syz_tun
      infiniband syz0: set down
      infiniband syz0: ib_query_port failed (-19)
      restrack: ------------[ cut here    ]------------
      infiniband syz0: BUG: RESTRACK detected leak of resources
      restrack: User CM_ID object allocated by syz-executor716 is not freed
      restrack: ------------[ cut here    ]------------
      
      Fixes: b09c4d70 ("RDMA/restrack: Improve readability in task name management")
      Link: https://lore.kernel.org/r/ab93e56ba831eac65c322b3256796fa1589ec0bb.1618753862.git.leonro@nvidia.comSigned-off-by: NShay Drory <shayd@nvidia.com>
      Signed-off-by: NLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: NJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NChen Jun <chenjun102@huawei.com>
      Acked-by: NWeilong Chen <chenweilong@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      8ca86a96
  11. 09 4月, 2021 1 次提交
    • A
      RDMA/ucma: Fix use-after-free bug in ucma_create_uevent · 415e9017
      Avihai Horon 提交于
      stable inclusion
      from stable-5.10.20
      commit 60d613b39e8d0c9f3b526e9c96445422b4562d76
      bugzilla: 50608
      
      --------------------------------
      
      [ Upstream commit fe454dc3 ]
      
      ucma_process_join() allocates struct ucma_multicast mc and frees it if an
      error occurs during its run.  Specifically, if an error occurs in
      copy_to_user(), a use-after-free might happen in the following scenario:
      
      1. mc struct is allocated.
      2. rdma_join_multicast() is called and succeeds. During its run,
         cma_iboe_join_multicast() enqueues a work that will later use the
         aforementioned mc struct.
      3. copy_to_user() is called and fails.
      4. mc struct is deallocated.
      5. The work that was enqueued by cma_iboe_join_multicast() is run and
         calls ucma_create_uevent() which tries to access mc struct (which is
         freed by now).
      
      Fix this bug by cancelling the work enqueued by cma_iboe_join_multicast().
      Since cma_work_handler() frees struct cma_work, we don't use it in
      cma_iboe_join_multicast() so we can safely cancel the work later.
      
      The following syzkaller report revealed it:
      
         BUG: KASAN: use-after-free in ucma_create_uevent+0x2dd/0x;3f0 drivers/infiniband/core/ucma.c:272
         Read of size 8 at addr ffff88810b3ad110 by task kworker/u8:1/108
      
         CPU: 1 PID: 108 Comm: kworker/u8:1 Not tainted 5.10.0-rc6+ #257
         Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS   rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
         Workqueue: rdma_cm cma_work_handler
         Call Trace:
          __dump_stack lib/dump_stack.c:77 [inline]
          dump_stack+0xbe/0xf9 lib/dump_stack.c:118
          print_address_description.constprop.0+0x3e/0×60 mm/kasan/report.c:385
          __kasan_report mm/kasan/report.c:545 [inline]
          kasan_report.cold+0x1f/0×37 mm/kasan/report.c:562
          ucma_create_uevent+0x2dd/0×3f0 drivers/infiniband/core/ucma.c:272
          ucma_event_handler+0xb7/0×3c0 drivers/infiniband/core/ucma.c:349
          cma_cm_event_handler+0x5d/0×1c0 drivers/infiniband/core/cma.c:1977
          cma_work_handler+0xfa/0×190 drivers/infiniband/core/cma.c:2718
          process_one_work+0x54c/0×930 kernel/workqueue.c:2272
          worker_thread+0x82/0×830 kernel/workqueue.c:2418
          kthread+0x1ca/0×220 kernel/kthread.c:292
          ret_from_fork+0x1f/0×30 arch/x86/entry/entry_64.S:296
      
         Allocated by task 359:
           kasan_save_stack+0x1b/0×40 mm/kasan/common.c:48
           kasan_set_track mm/kasan/common.c:56 [inline]
           __kasan_kmalloc mm/kasan/common.c:461 [inline]
           __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:434
           kmalloc include/linux/slab.h:552 [inline]
           kzalloc include/linux/slab.h:664 [inline]
           ucma_process_join+0x16e/0×3f0 drivers/infiniband/core/ucma.c:1453
           ucma_join_multicast+0xda/0×140 drivers/infiniband/core/ucma.c:1538
           ucma_write+0x1f7/0×280 drivers/infiniband/core/ucma.c:1724
           vfs_write fs/read_write.c:603 [inline]
           vfs_write+0x191/0×4c0 fs/read_write.c:585
           ksys_write+0x1a1/0×1e0 fs/read_write.c:658
           do_syscall_64+0x2d/0×40 arch/x86/entry/common.c:46
           entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
         Freed by task 359:
           kasan_save_stack+0x1b/0×40 mm/kasan/common.c:48
           kasan_set_track+0x1c/0×30 mm/kasan/common.c:56
           kasan_set_free_info+0x1b/0×30 mm/kasan/generic.c:355
           __kasan_slab_free+0x112/0×160 mm/kasan/common.c:422
           slab_free_hook mm/slub.c:1544 [inline]
           slab_free_freelist_hook mm/slub.c:1577 [inline]
           slab_free mm/slub.c:3142 [inline]
           kfree+0xb3/0×3e0 mm/slub.c:4124
           ucma_process_join+0x22d/0×3f0 drivers/infiniband/core/ucma.c:1497
           ucma_join_multicast+0xda/0×140 drivers/infiniband/core/ucma.c:1538
           ucma_write+0x1f7/0×280 drivers/infiniband/core/ucma.c:1724
           vfs_write fs/read_write.c:603 [inline]
           vfs_write+0x191/0×4c0 fs/read_write.c:585
           ksys_write+0x1a1/0×1e0 fs/read_write.c:658
           do_syscall_64+0x2d/0×40 arch/x86/entry/common.c:46
           entry_SYSCALL_64_after_hwframe+0x44/0xa9
           The buggy address belongs to the object at ffff88810b3ad100
           which belongs to the cache kmalloc-192 of size 192
           The buggy address is located 16 bytes inside of
           192-byte region [ffff88810b3ad100, ffff88810b3ad1c0)
      
      Fixes: b5de0c60 ("RDMA/cma: Fix use after free race in roce multicast join")
      Link: https://lore.kernel.org/r/20210211090517.1278415-1-leon@kernel.orgReported-by: NAmit Matityahu <mitm@nvidia.com>
      Signed-off-by: NAvihai Horon <avihaih@nvidia.com>
      Signed-off-by: NLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: NJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NChen Jun <chenjun102@huawei.com>
      Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      415e9017
  12. 12 1月, 2021 3 次提交
    • L
      RDMA/cma: Don't overwrite sgid_attr after device is released · ae4fa3fd
      Leon Romanovsky 提交于
      stable inclusion
      from stable-5.10.4
      commit 04ca5e7fa40d0a82d08d85a282f7b6df975e6989
      bugzilla: 46903
      
      --------------------------------
      
      [ Upstream commit e246b7c0 ]
      
      As part of the cma_dev release, that pointer will be set to NULL.  In case
      it happens in rdma_bind_addr() (part of an error flow), the next call to
      addr_handler() will have a call to cma_acquire_dev_by_src_ip() which will
      overwrite sgid_attr without releasing it.
      
        WARNING: CPU: 2 PID: 108 at drivers/infiniband/core/cma.c:606 cma_bind_sgid_attr drivers/infiniband/core/cma.c:606 [inline]
        WARNING: CPU: 2 PID: 108 at drivers/infiniband/core/cma.c:606 cma_acquire_dev_by_src_ip+0x470/0x4b0 drivers/infiniband/core/cma.c:649
        CPU: 2 PID: 108 Comm: kworker/u8:1 Not tainted 5.10.0-rc6+ #257
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
        Workqueue: ib_addr process_one_req
        RIP: 0010:cma_bind_sgid_attr drivers/infiniband/core/cma.c:606 [inline]
        RIP: 0010:cma_acquire_dev_by_src_ip+0x470/0x4b0 drivers/infiniband/core/cma.c:649
        Code: 66 d9 4a ff 4d 8b 6e 10 49 8d bd 1c 08 00 00 e8 b6 d6 4a ff 45 0f b6 bd 1c 08 00 00 41 83 e7 01 e9 49 fd ff ff e8 90 c5 29 ff <0f> 0b e9 80 fe ff ff e8 84 c5 29 ff 4c 89 f7 e8 2c d9 4a ff 4d 8b
        RSP: 0018:ffff8881047c7b40 EFLAGS: 00010293
        RAX: ffff888104789c80 RBX: 0000000000000001 RCX: ffffffff820b8ef8
        RDX: 0000000000000000 RSI: ffffffff820b9080 RDI: ffff88810cd4c998
        RBP: ffff8881047c7c08 R08: ffff888104789c80 R09: ffffed10209f4036
        R10: ffff888104fa01ab R11: ffffed10209f4035 R12: ffff88810cd4c800
        R13: ffff888105750e28 R14: ffff888108f0a100 R15: ffff88810cd4c998
        FS:  0000000000000000(0000) GS:ffff888119c00000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000000000000000 CR3: 0000000104e60005 CR4: 0000000000370ea0
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        Call Trace:
         addr_handler+0x266/0x350 drivers/infiniband/core/cma.c:3190
         process_one_req+0xa3/0x300 drivers/infiniband/core/addr.c:645
         process_one_work+0x54c/0x930 kernel/workqueue.c:2272
         worker_thread+0x82/0x830 kernel/workqueue.c:2418
         kthread+0x1ca/0x220 kernel/kthread.c:292
         ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296
      
      Fixes: ff11c6cd ("RDMA/cma: Introduce and use cma_acquire_dev_by_src_ip()")
      Link: https://lore.kernel.org/r/20201213132940.345554-5-leon@kernel.orgSigned-off-by: NLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: NJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NChen Jun <chenjun102@huawei.com>
      Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
      ae4fa3fd
    • J
      RDMA/cma: Fix deadlock on &lock in rdma_cma_listen_on_all() error unwind · 36d36840
      Jason Gunthorpe 提交于
      stable inclusion
      from stable-5.10.4
      commit f85d05c0a599ede6f161988ab6eea1a62b1b400f
      bugzilla: 46903
      
      --------------------------------
      
      [ Upstream commit dd37d2f5 ]
      
      rdma_detroy_id() cannot be called under &lock - we must instead keep the
      error'd ID around until &lock can be released, then destroy it.
      
      This is complicated by the usual way listen IDs are destroyed through
      cma_process_remove() which can run at any time and will asynchronously
      destroy the same ID.
      
      Remove the ID from visiblity of cma_process_remove() before going down the
      destroy path outside the locking.
      
      Fixes: c80a0c52 ("RDMA/cma: Add missing error handling of listen_id")
      Link: https://lore.kernel.org/r/20201118133756.GK244516@ziepe.ca
      Reported-by: syzbot+1bc48bf7f78253f664a9@syzkaller.appspotmail.com
      Reviewed-by: NLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: NJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NChen Jun <chenjun102@huawei.com>
      Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
      36d36840
    • L
      RDMA/cma: Add missing error handling of listen_id · 2752d4bb
      Leon Romanovsky 提交于
      stable inclusion
      from stable-5.10.4
      commit 70ba8b1697e35c04ea5f22edb6e401aeb1208d96
      bugzilla: 46903
      
      --------------------------------
      
      [ Upstream commit c80a0c52 ]
      
      Don't silently continue if rdma_listen() fails but destroy previously
      created CM_ID and return an error to the caller.
      
      Fixes: d02d1f53 ("RDMA/cma: Fix deadlock destroying listen requests")
      Link: https://lore.kernel.org/r/20201104144008.3808124-5-leon@kernel.orgSigned-off-by: NLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: NJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NChen Jun <chenjun102@huawei.com>
      Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
      2752d4bb
  13. 28 10月, 2020 1 次提交
  14. 02 10月, 2020 1 次提交
  15. 29 9月, 2020 1 次提交
  16. 23 9月, 2020 4 次提交
  17. 17 9月, 2020 8 次提交
  18. 27 8月, 2020 1 次提交
  19. 24 8月, 2020 1 次提交
  20. 30 7月, 2020 3 次提交