Yang Yingliang
362a9e6528
io_uring: fix memleak in io_init_wq_offload()
...
I got memory leak report when doing fuzz test:
BUG: memory leak
unreferenced object 0xffff888107310a80 (size 96):
comm "syz-executor.6", pid 4610, jiffies 4295140240 (age 20.135s)
hex dump (first 32 bytes):
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00 .....N..........
backtrace:
[<000000001974933b>] kmalloc include/linux/slab.h:591 [inline]
[<000000001974933b>] kzalloc include/linux/slab.h:721 [inline]
[<000000001974933b>] io_init_wq_offload fs/io_uring.c:7920 [inline]
[<000000001974933b>] io_uring_alloc_task_context+0x466/0x640 fs/io_uring.c:7955
[<0000000039d0800d>] __io_uring_add_tctx_node+0x256/0x360 fs/io_uring.c:9016
[<000000008482e78c>] io_uring_add_tctx_node fs/io_uring.c:9052 [inline]
[<000000008482e78c>] __do_sys_io_uring_enter fs/io_uring.c:9354 [inline]
[<000000008482e78c>] __se_sys_io_uring_enter fs/io_uring.c:9301 [inline]
[<000000008482e78c>] __x64_sys_io_uring_enter+0xabc/0xc20 fs/io_uring.c:9301
[<00000000b875f18f>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<00000000b875f18f>] do_syscall_64+0x3b/0x90 arch/x86/entry/common.c:80
[<000000006b0a8484>] entry_SYSCALL_64_after_hwframe+0x44/0xae
CPU0 CPU1
io_uring_enter io_uring_enter
io_uring_add_tctx_node io_uring_add_tctx_node
__io_uring_add_tctx_node __io_uring_add_tctx_node
io_uring_alloc_task_context io_uring_alloc_task_context
io_init_wq_offload io_init_wq_offload
hash = kzalloc hash = kzalloc
ctx->hash_map = hash ctx->hash_map = hash <- one of the hash is leaked
When calling io_uring_enter() in parallel, the 'hash_map' will be leaked,
add uring_lock to protect 'hash_map'.
Fixes: e941894eae31 ("io-wq: make buffered file write hashed work map per-ctx")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/20210720083805.3030730-1-yangyingliang@huawei.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-07-20 07:51:47 -06:00
..
2021-05-07 11:18:52 -07:00
2021-06-29 10:53:48 -07:00
2021-06-29 10:53:48 -07:00
2021-06-25 09:41:29 -07:00
2021-03-24 14:14:27 -04:00
2021-03-30 16:54:49 -07:00
2021-06-29 10:53:48 -07:00
2021-07-03 11:30:04 -07:00
2021-04-23 10:14:32 +01:00
2021-06-29 00:15:52 +02:00
2021-07-09 13:03:36 -05:00
2021-04-23 14:42:39 -07:00
2021-07-02 14:13:21 -07:00
2021-01-05 23:02:47 -05:00
2021-06-05 00:52:52 -07:00
2021-06-14 09:07:45 +02:00
2021-06-11 12:44:47 -05:00
2021-06-29 10:53:48 -07:00
2021-04-12 15:04:29 +02:00
2021-06-08 00:41:24 +08:00
2021-07-06 11:06:04 -07:00
2020-12-09 09:39:38 -05:00
2021-06-29 10:53:48 -07:00
2021-07-09 09:57:27 -07:00
2021-07-06 22:05:06 -07:00
2021-06-29 10:53:48 -07:00
2021-04-23 10:14:32 +01:00
2021-07-06 11:17:41 -07:00
2021-06-29 20:23:08 -07:00
2021-06-29 10:53:48 -07:00
2021-07-01 11:06:06 -07:00
2021-05-02 09:14:01 -07:00
2021-06-29 10:53:48 -07:00
2021-06-28 20:39:26 -07:00
2021-07-03 11:30:04 -07:00
2021-06-17 17:11:42 +02:00
2021-07-08 08:37:31 -04:00
2021-05-04 18:08:40 -07:00
2021-07-02 14:25:17 -07:00
2021-07-05 13:51:41 -07:00
2021-07-06 20:14:44 -04:00
2021-06-29 10:53:48 -07:00
2021-06-21 21:24:07 +01:00
2021-07-09 09:43:57 -07:00
2021-07-06 20:14:41 -04:00
2021-07-09 12:05:33 -07:00
2021-07-02 12:08:10 -07:00
2021-06-14 12:16:37 +02:00
2021-07-03 11:30:04 -07:00
2021-06-30 19:37:39 -07:00
2021-06-29 10:53:48 -07:00
2021-03-12 22:15:22 -05:00
2021-06-28 08:40:08 -04:00
2021-04-30 15:17:08 -07:00
2021-07-03 11:41:14 -07:00
2021-06-30 12:21:16 -07:00
2021-06-22 10:40:52 +02:00
2021-06-29 10:53:48 -07:00
2021-07-01 12:06:39 -07:00
2021-06-29 10:53:46 -07:00
2021-01-12 14:26:31 +01:00
2021-06-29 10:53:48 -07:00
2021-03-23 14:08:18 -04:00
2021-06-22 09:21:39 +02:00
2021-07-01 12:06:39 -07:00
2021-06-29 10:53:48 -07:00
2021-05-02 00:43:35 +09:00
2021-03-12 22:15:00 -05:00
2021-04-22 17:31:32 +10:00
2021-07-02 14:30:27 -07:00
2021-06-29 10:53:48 -07:00
2021-04-30 11:20:39 -07:00
2021-01-15 12:17:25 -05:00
2021-01-24 14:27:20 +01:00
2021-01-24 14:27:20 +01:00
2021-06-29 10:53:50 -07:00
2021-06-29 17:29:11 -07:00
2021-06-29 17:29:11 -07:00
2021-06-29 10:53:50 -07:00
2021-03-13 11:27:30 -08:00
2021-07-05 13:42:16 -07:00
2021-06-29 10:53:48 -07:00
2021-01-06 08:42:51 -05:00
2021-07-03 11:41:14 -07:00
2021-05-18 20:15:58 -04:00
2021-06-29 10:53:47 -07:00
2021-04-15 22:36:45 -04:00
2021-04-09 14:54:23 -07:00
2021-05-06 19:24:13 -07:00
2021-07-02 12:08:10 -07:00
2021-02-23 13:39:45 -08:00
2021-04-07 13:56:43 -04:00
2021-05-03 11:05:28 -07:00
2021-04-30 11:20:35 -07:00
2021-07-01 12:06:39 -07:00
2021-01-24 14:27:19 +01:00
2021-05-05 11:27:20 -07:00
2021-04-07 13:56:43 -04:00
2021-07-20 07:51:47 -06:00
2021-06-18 09:22:02 -06:00
2021-06-18 09:22:02 -06:00
2021-04-12 15:04:23 +02:00
2021-06-30 20:47:26 -07:00
2021-04-19 09:56:37 +10:00
2021-04-07 13:56:43 -04:00
2021-06-29 10:53:48 -07:00
2021-05-05 13:44:19 -07:00
2021-04-23 10:14:32 +01:00
2021-01-24 14:29:34 +01:00
2021-03-11 07:47:48 -07:00
2021-07-03 11:41:14 -07:00
2021-06-01 12:09:27 +02:00
2021-07-03 11:41:14 -07:00
2021-02-24 13:38:26 -08:00
2021-03-08 15:18:43 +01:00
2021-01-24 14:27:20 +01:00
2021-01-24 14:43:45 +01:00
2021-01-25 23:29:36 -05:00
2021-04-17 11:39:49 -07:00
2021-01-24 14:27:19 +01:00
2021-03-16 22:13:10 +01:00
2021-07-01 11:06:05 -07:00
2021-05-18 16:20:54 -05:00
2021-02-21 11:02:48 -08:00
2021-04-17 23:03:50 -04:00
2021-02-13 17:17:53 +01:00
2021-06-01 07:44:32 -06:00
2021-07-02 12:08:10 -07:00
2021-01-24 14:27:18 +01:00
2021-03-23 11:20:26 +01:00