1. 26 3月, 2021 1 次提交
  2. 08 12月, 2020 1 次提交
  3. 13 11月, 2020 2 次提交
  4. 01 10月, 2020 1 次提交
  5. 10 9月, 2020 1 次提交
  6. 31 8月, 2020 1 次提交
  7. 16 7月, 2020 1 次提交
    • L
      RDMA/core: Fix race in rdma_alloc_commit_uobject() · 0d1fd39b
      Leon Romanovsky 提交于
      The FD should not be installed until all of the setup is completed as the
      fd_install() transfers ownership of the kref to the FD table. A thread can
      race a close() and trigger concurrent rdma_alloc_commit_uobject() and
      uverbs_uobject_fd_release() which, at least, triggers a safety WARN_ON:
      
        WARNING: CPU: 4 PID: 6913 at drivers/infiniband/core/rdma_core.c:768 uverbs_uobject_fd_release+0x202/0x230
        Kernel panic - not syncing: panic_on_warn set ...
        CPU: 4 PID: 6913 Comm: syz-executor.3 Not tainted 5.7.0-rc2 #22
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
        [..]
        RIP: 0010:uverbs_uobject_fd_release+0x202/0x230
        Code: fe 4c 89 e7 e8 af 23 fe ff e9 2a ff ff ff e8 c5 fa 61 fe be 03 00 00 00 4c 89 e7 e8 68 eb f5 fe e9 13 ff ff ff e8 ae fa 61 fe <0f> 0b eb ac e8 e5 aa 3c fe e8 50 2b 86 fe e9 6a fe ff ff e8 46 2b
        RSP: 0018:ffffc90008117d88 EFLAGS: 00010293
        RAX: ffff88810e146580 RBX: 1ffff92001022fb1 RCX: ffffffff82d5b902
        RDX: 0000000000000000 RSI: 0000000000000004 RDI: ffff88811951b040
        RBP: ffff88811951b000 R08: ffffed10232a3609 R09: ffffed10232a3609
        R10: ffff88811951b043 R11: 0000000000000001 R12: ffff888100a7c600
        R13: ffff888100a7c650 R14: ffffc90008117da8 R15: ffffffff82d5b700
         ? __uverbs_cleanup_ufile+0x270/0x270
         ? uverbs_uobject_fd_release+0x202/0x230
         ? uverbs_uobject_fd_release+0x202/0x230
         ? __uverbs_cleanup_ufile+0x270/0x270
         ? locks_remove_file+0x282/0x3d0
         ? security_file_free+0xaa/0xd0
         __fput+0x2be/0x770
         task_work_run+0x10e/0x1b0
         exit_to_usermode_loop+0x145/0x170
         do_syscall_64+0x2d0/0x390
         ? prepare_exit_to_usermode+0x17a/0x230
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        RIP: 0033:0x414da7
        Code: 00 00 0f 05 48 3d 00 f0 ff ff 77 3f f3 c3 0f 1f 44 00 00 53 89 fb 48 83 ec 10 e8 f4 fb ff ff 89 df 89 c2 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 2b 89 d7 89 44 24 0c e8 36 fc ff ff 8b 44 24
        RSP: 002b:00007fff39d379d0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
        RAX: 0000000000000000 RBX: 0000000000000003 RCX: 0000000000414da7
        RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000003
        RBP: 00007fff39d37a3c R08: 0000000400000000 R09: 0000000400000000
        R10: 00007fff39d37910 R11: 0000000000000293 R12: 0000000000000001
        R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000003
      
      Reorder so that fd_install() is the last thing done in
      rdma_alloc_commit_uobject().
      
      Fixes: aba94548 ("IB/uverbs: Move the FD uobj type struct file allocation to alloc_commit")
      Link: https://lore.kernel.org/r/20200716102059.1420681-1-leon@kernel.orgSigned-off-by: NLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: NJason Gunthorpe <jgg@nvidia.com>
      0d1fd39b
  8. 18 6月, 2020 1 次提交
    • L
      RDMA/core: Check that type_attrs is not NULL prior access · 4121fb0d
      Leon Romanovsky 提交于
      In disassociate flow, the type_attrs is set to be NULL, which is in an
      implicit way is checked in alloc_uobj() by "if (!attrs->context)".
      
      Change the logic to rely on that check, to be consistent with other
      alloc_uobj() places that will fix the following kernel splat.
      
       BUG: kernel NULL pointer dereference, address: 0000000000000018
       #PF: supervisor read access in kernel mode
       #PF: error_code(0x0000) - not-present page
       PGD 0 P4D 0
       Oops: 0000 [#1] SMP PTI
       CPU: 3 PID: 2743 Comm: python3 Not tainted 5.7.0-rc6-for-upstream-perf-2020-05-23_19-04-38-5 #1
       Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
       RIP: 0010:alloc_begin_fd_uobject+0x18/0xf0 [ib_uverbs]
       Code: 89 43 48 eb 97 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 41 55 49 89 f5 41 54 55 48 89 fd 53 48 83 ec 08 48 8b 1f <48> 8b 43 18 48 8b 80 80 00 00 00 48 3d 20 10 33 a0 74 1c 48 3d 30
       RSP: 0018:ffffc90001127b70 EFLAGS: 00010282
       RAX: ffffffffa0339fe0 RBX: 0000000000000000 RCX: 8000000000000007
       RDX: fffffffffffffffb RSI: ffffc90001127d28 RDI: ffff88843fe1f600
       RBP: ffff88843fe1f600 R08: ffff888461eb06d8 R09: ffff888461eb06f8
       R10: ffff888461eb0700 R11: 0000000000000000 R12: ffff88846a5f6450
       R13: ffffc90001127d28 R14: ffff88845d7d6ea0 R15: ffffc90001127cb8
       FS: 00007f469bff1540(0000) GS:ffff88846f980000(0000) knlGS:0000000000000000
       CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 0000000000000018 CR3: 0000000450018003 CR4: 0000000000760ee0
       DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
       PKRU: 55555554
       Call Trace:
       ? xa_store+0x28/0x40
       rdma_alloc_begin_uobject+0x4f/0x90 [ib_uverbs]
       ib_uverbs_create_comp_channel+0x87/0xf0 [ib_uverbs]
       ib_uverbs_handler_UVERBS_METHOD_INVOKE_WRITE+0xb1/0xf0 [ib_uverbs]
       ib_uverbs_cmd_verbs.isra.8+0x96d/0xae0 [ib_uverbs]
       ? get_page_from_freelist+0x3bb/0xf70
       ? _copy_to_user+0x22/0x30
       ? uverbs_disassociate_api+0xd0/0xd0 [ib_uverbs]
       ? __wake_up_common_lock+0x87/0xc0
       ib_uverbs_ioctl+0xbc/0x130 [ib_uverbs]
       ksys_ioctl+0x83/0xc0
       ? ksys_write+0x55/0xd0
       __x64_sys_ioctl+0x16/0x20
       do_syscall_64+0x48/0x130
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
       RIP: 0033:0x7f469ac43267
      
      Fixes: 849e1490 ("RDMA/core: Do not allow alloc_commit to fail")
      Link: https://lore.kernel.org/r/20200617061826.2625359-1-leon@kernel.orgSigned-off-by: NLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      4121fb0d
  9. 28 5月, 2020 1 次提交
    • J
      RDMA/core: Fix double destruction of uobject · c85f4abe
      Jason Gunthorpe 提交于
      Fix use after free when user user space request uobject concurrently for
      the same object, within the RCU grace period.
      
      In that case, remove_handle_idr_uobject() is called twice and we will have
      an extra put on the uobject which cause use after free.  Fix it by leaving
      the uobject write locked after it was removed from the idr.
      
      Call to rdma_lookup_put_uobject with UVERBS_LOOKUP_DESTROY instead of
      UVERBS_LOOKUP_WRITE will do the work.
      
        refcount_t: underflow; use-after-free.
        WARNING: CPU: 0 PID: 1381 at lib/refcount.c:28 refcount_warn_saturate+0xfe/0x1a0
        Kernel panic - not syncing: panic_on_warn set ...
        CPU: 0 PID: 1381 Comm: syz-executor.0 Not tainted 5.5.0-rc3 #8
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
        Call Trace:
         dump_stack+0x94/0xce
         panic+0x234/0x56f
         __warn+0x1cc/0x1e1
         report_bug+0x200/0x310
         fixup_bug.part.11+0x32/0x80
         do_error_trap+0xd3/0x100
         do_invalid_op+0x31/0x40
         invalid_op+0x1e/0x30
        RIP: 0010:refcount_warn_saturate+0xfe/0x1a0
        Code: 0f 0b eb 9b e8 23 f6 6d ff 80 3d 6c d4 19 03 00 75 8d e8 15 f6 6d ff 48 c7 c7 c0 02 55 bd c6 05 57 d4 19 03 01 e8 a2 58 49 ff <0f> 0b e9 6e ff ff ff e8 f6 f5 6d ff 80 3d 42 d4 19 03 00 0f 85 5c
        RSP: 0018:ffffc90002df7b98 EFLAGS: 00010282
        RAX: 0000000000000000 RBX: ffff88810f6a193c RCX: ffffffffba649009
        RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffff88811b0283cc
        RBP: 0000000000000003 R08: ffffed10236060e3 R09: ffffed10236060e3
        R10: 0000000000000001 R11: ffffed10236060e2 R12: ffff88810f6a193c
        R13: ffffc90002df7d60 R14: 0000000000000000 R15: ffff888116ae6a08
         uverbs_uobject_put+0xfd/0x140
         __uobj_perform_destroy+0x3d/0x60
         ib_uverbs_close_xrcd+0x148/0x170
         ib_uverbs_write+0xaa5/0xdf0
         __vfs_write+0x7c/0x100
         vfs_write+0x168/0x4a0
         ksys_write+0xc8/0x200
         do_syscall_64+0x9c/0x390
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        RIP: 0033:0x465b49
        Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 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 bc ff ff ff f7 d8 64 89 01 48
        RSP: 002b:00007f759d122c58 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
        RAX: ffffffffffffffda RBX: 000000000073bfa8 RCX: 0000000000465b49
        RDX: 000000000000000c RSI: 0000000020000080 RDI: 0000000000000003
        RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000000
        R10: 0000000000000000 R11: 0000000000000246 R12: 00007f759d1236bc
        R13: 00000000004ca27c R14: 000000000070de40 R15: 00000000ffffffff
        Dumping ftrace buffer:
           (ftrace buffer empty)
        Kernel Offset: 0x39400000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
      
      Fixes: 7452a3c7 ("IB/uverbs: Allow RDMA_REMOVE_DESTROY to work concurrently with disassociate")
      Link: https://lore.kernel.org/r/20200527135534.482279-1-leon@kernel.orgSigned-off-by: NMaor Gottlieb <maorg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      c85f4abe
  10. 22 5月, 2020 1 次提交
  11. 13 5月, 2020 1 次提交
  12. 25 4月, 2020 1 次提交
  13. 23 4月, 2020 2 次提交
    • L
      RDMA/core: Fix overwriting of uobj in case of error · 83a26702
      Leon Romanovsky 提交于
      In case of failure to get file, the uobj is overwritten and causes to
      supply bad pointer as an input to uverbs_uobject_put().
      
        BUG: KASAN: null-ptr-deref in atomic_fetch_sub include/asm-generic/atomic-instrumented.h:199 [inline]
        BUG: KASAN: null-ptr-deref in refcount_sub_and_test include/linux/refcount.h:253 [inline]
        BUG: KASAN: null-ptr-deref in refcount_dec_and_test include/linux/refcount.h:281 [inline]
        BUG: KASAN: null-ptr-deref in kref_put include/linux/kref.h:64 [inline]
        BUG: KASAN: null-ptr-deref in uverbs_uobject_put+0x22/0x90 drivers/infiniband/core/rdma_core.c:57
        Write of size 4 at addr 0000000000000030 by task syz-executor.4/1691
      
        CPU: 1 PID: 1691 Comm: syz-executor.4 Not tainted 5.6.0 #17
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
        Call Trace:
         __dump_stack lib/dump_stack.c:77 [inline]
         dump_stack+0x94/0xce lib/dump_stack.c:118
         __kasan_report+0x10c/0x190 mm/kasan/report.c:515
         kasan_report+0x32/0x50 mm/kasan/common.c:625
         check_memory_region_inline mm/kasan/generic.c:187 [inline]
         check_memory_region+0x16d/0x1c0 mm/kasan/generic.c:193
         atomic_fetch_sub include/asm-generic/atomic-instrumented.h:199 [inline]
         refcount_sub_and_test include/linux/refcount.h:253 [inline]
         refcount_dec_and_test include/linux/refcount.h:281 [inline]
         kref_put include/linux/kref.h:64 [inline]
         uverbs_uobject_put+0x22/0x90 drivers/infiniband/core/rdma_core.c:57
         alloc_begin_fd_uobject+0x1d0/0x250 drivers/infiniband/core/rdma_core.c:486
         rdma_alloc_begin_uobject+0xa8/0xf0 drivers/infiniband/core/rdma_core.c:509
         __uobj_alloc include/rdma/uverbs_std_types.h:117 [inline]
         ib_uverbs_create_comp_channel+0x16d/0x230 drivers/infiniband/core/uverbs_cmd.c:982
         ib_uverbs_write+0xaa5/0xdf0 drivers/infiniband/core/uverbs_main.c:665
         __vfs_write+0x7c/0x100 fs/read_write.c:494
         vfs_write+0x168/0x4a0 fs/read_write.c:558
         ksys_write+0xc8/0x200 fs/read_write.c:611
         do_syscall_64+0x9c/0x390 arch/x86/entry/common.c:295
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        RIP: 0033:0x466479
        Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 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 bc ff ff ff f7 d8 64 89 01 48
        RSP: 002b:00007efe9f6a7c48 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
        RAX: ffffffffffffffda RBX: 000000000073bf00 RCX: 0000000000466479
        RDX: 0000000000000018 RSI: 0000000020000040 RDI: 0000000000000003
        RBP: 00007efe9f6a86bc R08: 0000000000000000 R09: 0000000000000000
        R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000005
        R13: 0000000000000bf2 R14: 00000000004cb80a R15: 00000000006fefc0
      
      Fixes: 849e1490 ("RDMA/core: Do not allow alloc_commit to fail")
      Link: https://lore.kernel.org/r/20200421082929.311931-3-leon@kernel.orgSigned-off-by: NLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      83a26702
    • L
      RDMA/core: Prevent mixed use of FDs between shared ufiles · 0fb00941
      Leon Romanovsky 提交于
      FDs can only be used on the ufile that created them, they cannot be mixed
      to other ufiles. We are lacking a check to prevent it.
      
        BUG: KASAN: null-ptr-deref in atomic64_sub_and_test include/asm-generic/atomic-instrumented.h:1547 [inline]
        BUG: KASAN: null-ptr-deref in atomic_long_sub_and_test include/asm-generic/atomic-long.h:460 [inline]
        BUG: KASAN: null-ptr-deref in fput_many+0x1a/0x140 fs/file_table.c:336
        Write of size 8 at addr 0000000000000038 by task syz-executor179/284
      
        CPU: 0 PID: 284 Comm: syz-executor179 Not tainted 5.5.0-rc5+ #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
        Call Trace:
         __dump_stack lib/dump_stack.c:77 [inline]
         dump_stack+0x94/0xce lib/dump_stack.c:118
         __kasan_report+0x18f/0x1b7 mm/kasan/report.c:510
         kasan_report+0xe/0x20 mm/kasan/common.c:639
         check_memory_region_inline mm/kasan/generic.c:185 [inline]
         check_memory_region+0x15d/0x1b0 mm/kasan/generic.c:192
         atomic64_sub_and_test include/asm-generic/atomic-instrumented.h:1547 [inline]
         atomic_long_sub_and_test include/asm-generic/atomic-long.h:460 [inline]
         fput_many+0x1a/0x140 fs/file_table.c:336
         rdma_lookup_put_uobject+0x85/0x130 drivers/infiniband/core/rdma_core.c:692
         uobj_put_read include/rdma/uverbs_std_types.h:96 [inline]
         _ib_uverbs_lookup_comp_file drivers/infiniband/core/uverbs_cmd.c:198 [inline]
         create_cq+0x375/0xba0 drivers/infiniband/core/uverbs_cmd.c:1006
         ib_uverbs_create_cq+0x114/0x140 drivers/infiniband/core/uverbs_cmd.c:1089
         ib_uverbs_write+0xaa5/0xdf0 drivers/infiniband/core/uverbs_main.c:769
         __vfs_write+0x7c/0x100 fs/read_write.c:494
         vfs_write+0x168/0x4a0 fs/read_write.c:558
         ksys_write+0xc8/0x200 fs/read_write.c:611
         do_syscall_64+0x9c/0x390 arch/x86/entry/common.c:294
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        RIP: 0033:0x44ef99
        Code: 00 b8 00 01 00 00 eb e1 e8 74 1c 00 00 0f 1f 40 00 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 c4 ff ff ff f7 d8 64 89 01 48
        RSP: 002b:00007ffc0b74c028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
        RAX: ffffffffffffffda RBX: 00007ffc0b74c030 RCX: 000000000044ef99
        RDX: 0000000000000040 RSI: 0000000020000040 RDI: 0000000000000005
        RBP: 00007ffc0b74c038 R08: 0000000000401830 R09: 0000000000401830
        R10: 00007ffc0b74c038 R11: 0000000000000246 R12: 0000000000000000
        R13: 0000000000000000 R14: 00000000006be018 R15: 0000000000000000
      
      Fixes: cf8966b3 ("IB/core: Add support for fd objects")
      Link: https://lore.kernel.org/r/20200421082929.311931-2-leon@kernel.orgSuggested-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      0fb00941
  14. 17 1月, 2020 1 次提交
  15. 14 1月, 2020 5 次提交
  16. 07 11月, 2019 1 次提交
  17. 25 4月, 2019 1 次提交
  18. 09 4月, 2019 1 次提交
  19. 02 4月, 2019 2 次提交
  20. 23 2月, 2019 1 次提交
  21. 16 2月, 2019 1 次提交
  22. 30 1月, 2019 1 次提交
  23. 12 12月, 2018 1 次提交
  24. 05 12月, 2018 1 次提交
  25. 04 12月, 2018 1 次提交
  26. 27 11月, 2018 2 次提交
  27. 21 9月, 2018 3 次提交
  28. 05 9月, 2018 1 次提交
  29. 13 8月, 2018 1 次提交
  30. 11 8月, 2018 1 次提交
    • J
      IB/uverbs: Use uverbs_api to manage the object type inside the uobject · 6b0d08f4
      Jason Gunthorpe 提交于
      Currently the struct uverbs_obj_type stored in the ib_uobject is part of
      the .rodata segment of the module that defines the object. This is a
      problem if drivers define new uapi objects as we will be left with a
      dangling pointer after device disassociation.
      
      Switch the uverbs_obj_type for struct uverbs_api_object, which is
      allocated memory that is part of the uverbs_api and is guaranteed to
      always exist. Further this moves the 'type_class' into this memory which
      means access to the IDR/FD function pointers is also guaranteed. Drivers
      cannot define new types.
      
      This makes it safe to continue to use all uobjects, including driver
      defined ones, after disassociation.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      6b0d08f4