Leon Romanovsky
0d1fd39bb2
RDMA/core: Fix race in rdma_alloc_commit_uobject()
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: aba94548c9 ("IB/uverbs: Move the FD uobj type struct file allocation to alloc_commit")
Link: https://lore.kernel.org/r/20200716102059.1420681-1-leon@kernel.org
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
2020-07-16 09:58:53 -03:00
..
2020-06-14 01:57:21 +09:00
2020-07-03 16:15:31 +02:00
2020-06-15 23:08:28 -05:00
2020-06-23 07:54:46 +02:00
2020-06-19 13:09:40 -07:00
2020-06-14 01:57:21 +09:00
2020-06-14 01:57:21 +09:00
2020-06-26 12:32:11 -07:00
2020-07-10 09:55:46 -07:00
2020-06-03 16:27:18 -07:00
2020-06-28 14:41:55 +02:00
2020-06-10 16:05:54 -07:00
2020-07-07 04:25:17 +03:00
2020-06-25 15:04:13 -07:00
2020-07-08 21:57:51 +01:00
2020-06-14 01:57:21 +09:00
2020-06-23 17:24:32 +02:00
2020-06-25 13:52:53 +02:00
2020-06-21 10:01:03 -07:00
2020-06-04 19:06:23 -07:00
2020-05-28 18:02:40 +09:00
2020-06-17 10:57:41 -07:00
2020-06-15 23:08:32 -05:00
2020-06-25 16:05:40 +05:30
2020-06-18 20:25:25 +02:00
2020-06-14 01:57:21 +09:00
2020-05-29 17:36:02 +09:00
2020-06-15 23:08:31 -05:00
2020-07-10 08:42:17 -07:00
2020-06-26 17:26:31 +02:00
2020-06-14 01:57:21 +09:00
2020-06-14 01:57:21 +09:00
2020-06-26 23:53:25 +02:00
2020-07-10 07:02:02 +10:00
2020-06-14 01:57:21 +09:00
2020-06-14 01:57:21 +09:00
2020-06-14 01:57:21 +09:00
2020-06-29 10:30:35 +00:00
2020-07-02 17:43:14 -07:00
2020-06-15 23:08:32 -05:00
2020-07-04 08:20:38 +02:00
2020-06-14 01:57:21 +09:00
2020-06-14 01:57:21 +09:00
2020-07-16 09:58:53 -03:00
2020-06-17 10:57:41 -07:00
2020-06-10 14:04:39 -07:00
2020-06-23 10:08:32 +02:00
2020-06-14 01:57:21 +09:00
2020-07-06 12:48:04 -07:00
2020-06-14 01:57:21 +09:00
2020-06-04 11:03:45 -07:00
2020-06-02 15:29:19 -07:00
2020-06-14 01:57:21 +09:00
2020-06-10 22:43:57 -05:00
2020-07-08 12:50:51 -04:00
2020-06-26 00:27:37 -07:00
2020-05-28 14:18:11 +02:00
2020-06-26 22:51:53 -04:00
2020-06-16 09:32:43 +01:00
2020-06-24 12:35:23 +03:00
2020-07-08 15:30:35 +02:00
2020-07-07 21:04:38 +02:00
2020-07-10 14:33:34 -07:00
2020-06-14 01:57:21 +09:00
2020-06-05 20:02:09 -04:00
2020-07-08 17:08:01 -07:00
2020-07-02 10:38:00 +02:00
2020-05-27 11:09:26 +02:00
2020-06-19 13:39:00 -07:00
2020-06-14 01:57:21 +09:00
2020-06-15 23:08:32 -05:00
2020-06-14 01:57:21 +09:00
2020-06-13 13:29:16 -07:00
2020-06-14 01:57:21 +09:00
2020-06-11 12:53:23 -07:00
2020-06-15 23:08:32 -05:00
2020-06-28 01:08:21 +02:00
2020-06-13 13:29:16 -07:00
2020-06-14 01:57:21 +09:00
2020-06-10 11:28:35 -07:00
2020-06-13 13:29:16 -07:00
2020-06-14 01:57:21 +09:00
2020-06-14 01:57:21 +09:00
2020-06-04 19:09:28 +02:00
2020-06-15 23:08:32 -05:00
2020-06-17 13:01:19 +01:00
2020-06-08 13:01:08 -07:00
2020-06-07 10:59:32 -07:00
2020-06-08 13:01:08 -07:00
2020-06-07 16:11:23 -07:00
2020-07-03 11:41:31 +02:00
2020-06-14 01:57:21 +09:00
2020-07-08 01:16:23 -04:00
2020-06-14 01:57:21 +09:00
2020-06-28 14:57:14 -07:00
2020-06-29 10:10:16 -07:00
2020-06-16 21:25:38 +02:00
2020-06-13 13:29:16 -07:00
2020-06-09 09:39:14 -07:00
2020-06-29 12:15:34 +02:00
2020-06-07 09:42:16 -07:00
2020-06-26 15:40:16 +01:00
2020-06-27 13:12:10 -07:00
2020-06-22 12:34:21 -04:00
2020-06-25 11:04:23 -06:00
2020-06-22 12:34:21 -04:00
2020-06-26 13:49:17 +10:00
2020-06-14 01:57:21 +09:00
2020-06-22 12:34:21 -04:00
2020-06-14 01:57:21 +09:00
2020-06-14 01:57:21 +09:00
2020-06-15 23:08:32 -05:00
2020-06-14 01:57:21 +09:00
2020-07-11 11:16:46 -07:00
2020-06-14 01:57:21 +09:00