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: aba94548c9e4 ("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-05-12 21:32:52 -03:00
2018-12-19 16:28:03 -07:00
2020-05-12 11:47:48 -03:00
2019-06-05 17:36:37 +02:00
2020-01-25 15:11:37 -04:00
2020-06-18 09:34:42 -03:00
2020-05-22 15:37:19 -03:00
2020-05-27 16:05:05 -03:00
2020-01-07 16:10:53 -04:00
2020-06-02 20:32:54 -03:00
2020-06-18 09:48:54 -03:00
2020-05-29 16:09:02 -03:00
2020-06-22 14:36:56 -03:00
2020-05-29 16:09:02 -03:00
2020-06-02 20:32:54 -03:00
2020-01-25 14:48:33 -04:00
2020-03-04 14:28:25 -04:00
2016-08-02 13:15:18 -04:00
2019-08-27 13:09:23 -03:00
2019-08-27 13:09:23 -03:00
2019-10-22 14:45:31 -03:00
2020-05-06 16:51:43 -03:00
2020-02-20 13:33:51 -04:00
2018-12-19 16:28:03 -07:00
2020-06-22 14:57:44 -03:00
2020-06-02 20:32:53 -03:00
2019-06-28 21:18:23 -03:00
2020-05-06 11:57:33 -03:00
2019-10-24 20:49:37 -03:00
2020-05-12 11:47:48 -03:00
2018-12-12 07:40:16 -07:00
2020-07-16 09:58:53 -03:00
2020-05-21 20:39:36 -03:00
2019-10-23 15:58:31 -03:00
2019-10-23 15:58:31 -03:00
2019-06-02 18:06:26 -07:00
2020-04-15 11:34:49 -03:00
2020-07-02 16:05:12 -03:00
2018-10-16 13:34:01 -04:00
2020-03-24 19:53:25 -03:00
2018-12-12 07:40:16 -07:00
2020-05-29 15:35:49 -03:00
2020-01-07 16:10:53 -04:00
2020-05-27 16:05:05 -03:00
2020-05-27 13:46:05 -03:00
2020-06-09 09:39:14 -07:00
2020-02-13 13:38:02 -04:00
2020-05-06 11:57:33 -03:00
2020-06-02 20:32:54 -03:00
2020-05-27 13:46:05 -03:00
2020-06-09 09:39:14 -07:00
2018-06-25 14:19:57 -06:00
2020-05-12 17:02:25 -03:00
2019-04-08 13:05:25 -03:00
2020-05-21 20:34:53 -03:00
2020-01-16 15:55:46 -04:00
2019-04-08 13:05:25 -03:00
2019-04-08 13:05:25 -03:00
2020-05-21 20:10:46 -03:00
2020-05-21 20:39:36 -03:00
2020-05-21 20:39:35 -03:00
2020-05-21 20:39:35 -03:00
2020-05-21 20:39:36 -03:00
2020-05-21 20:39:36 -03:00
2020-05-21 20:34:53 -03:00
2020-06-02 20:32:54 -03:00