Peilin Ye
f482aa9865
audit, io_uring, io-wq: Fix memory leak in io_sq_thread() and io_wqe_worker()
Currently @audit_context is allocated twice for io_uring workers:
1. copy_process() calls audit_alloc();
2. io_sq_thread() or io_wqe_worker() calls audit_alloc_kernel() (which
is effectively audit_alloc()) and overwrites @audit_context,
causing:
BUG: memory leak
unreferenced object 0xffff888144547400 (size 1024):
<...>
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff8135cfc3>] audit_alloc+0x133/0x210
[<ffffffff81239e63>] copy_process+0xcd3/0x2340
[<ffffffff8123b5f3>] create_io_thread+0x63/0x90
[<ffffffff81686604>] create_io_worker+0xb4/0x230
[<ffffffff81686f68>] io_wqe_enqueue+0x248/0x3b0
[<ffffffff8167663a>] io_queue_iowq+0xba/0x200
[<ffffffff816768b3>] io_queue_async+0x113/0x180
[<ffffffff816840df>] io_req_task_submit+0x18f/0x1a0
[<ffffffff816841cd>] io_apoll_task_func+0xdd/0x120
[<ffffffff8167d49f>] tctx_task_work+0x11f/0x570
[<ffffffff81272c4e>] task_work_run+0x7e/0xc0
[<ffffffff8125a688>] get_signal+0xc18/0xf10
[<ffffffff8111645b>] arch_do_signal_or_restart+0x2b/0x730
[<ffffffff812ea44e>] exit_to_user_mode_prepare+0x5e/0x180
[<ffffffff844ae1b2>] syscall_exit_to_user_mode+0x12/0x20
[<ffffffff844a7e80>] do_syscall_64+0x40/0x80
Then,
3. io_sq_thread() or io_wqe_worker() frees @audit_context using
audit_free();
4. do_exit() eventually calls audit_free() again, which is okay
because audit_free() does a NULL check.
As suggested by Paul Moore, fix it by deleting audit_alloc_kernel() and
redundant audit_free() calls.
Fixes: 5bd2182d58 ("audit,io_uring,io-wq: add some basic audit support to io_uring")
Suggested-by: Paul Moore <paul@paul-moore.com>
Cc: stable@vger.kernel.org
Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
Acked-by: Paul Moore <paul@paul-moore.com>
Link: https://lore.kernel.org/r/20220803222343.31673-1-yepeilin.cs@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-08-04 08:33:54 -06:00
..
2022-06-03 11:48:47 -07:00
2022-05-18 00:08:27 +02:00
2022-05-19 22:15:51 +02:00
2022-05-18 21:21:05 +02:00
2022-05-07 22:55:49 +02:00
2022-06-03 11:48:47 -07:00
2022-06-29 14:46:22 +02:00
2022-05-10 16:03:52 +08:00
2022-06-03 11:48:47 -07:00
2022-08-01 12:48:15 -07:00
2022-06-03 11:36:34 -07:00
2022-07-25 09:42:24 +01:00
2022-07-04 11:42:20 +01:00
2022-06-03 10:02:52 -07:00
2022-05-24 14:31:29 -07:00
2022-07-06 10:57:30 +01:00
2022-06-05 10:47:06 -07:00
2022-05-22 20:44:29 +01:00
2022-07-28 00:01:30 +01:00
2022-05-13 14:49:38 +02:00
2022-08-01 11:49:06 -07:00
2022-06-17 15:51:52 +02:00
2022-06-30 13:40:35 +01:00
2022-06-08 12:39:37 -04:00
2022-06-03 11:17:49 -07:00
2022-07-05 20:25:39 +02:00
2022-08-01 12:48:15 -07:00
2022-04-29 14:51:46 +01:00
2022-08-04 08:33:54 -06:00
2022-06-16 10:55:57 +02:00
2022-07-14 12:14:30 -06:00
2022-06-03 06:52:58 -07:00
2022-07-14 12:14:30 -06:00
2022-05-02 14:06:20 -06:00
2022-07-14 12:14:30 -06:00
2022-07-14 12:14:30 -06:00
2022-07-14 12:14:30 -06:00
2022-05-10 17:50:40 -07:00
2022-05-23 14:31:28 -07:00
2022-05-25 12:22:58 -07:00
2022-05-20 15:29:00 -07:00
2022-07-14 12:14:32 -06:00
2022-05-23 17:51:12 -07:00
2022-05-15 18:31:28 -06:00
2022-08-01 11:49:06 -07:00
2022-05-13 07:20:13 -07:00
2022-04-28 23:16:17 -07:00
2022-05-31 14:10:54 -07:00
2022-07-03 11:32:22 -07:00
2022-05-08 01:33:06 -07:00
2022-06-23 18:41:40 +02:00
2022-07-05 13:32:59 -07:00
2022-07-05 13:33:00 -07:00
2022-07-05 13:33:00 -07:00
2022-06-27 10:33:59 +02:00
2022-08-01 12:48:15 -07:00
2022-04-29 14:37:59 -07:00
2022-06-07 10:27:38 +02:00
2022-05-13 16:48:57 -07:00
2022-05-16 13:37:59 -07:00
2022-06-01 15:55:25 -07:00
2022-06-30 05:11:17 +09:00
2022-07-28 17:36:30 -04:00
2022-06-03 11:48:47 -07:00
2022-06-28 10:37:25 -03:00
2022-07-14 12:14:31 -06:00
2022-07-08 10:47:07 -07:00
2022-05-25 16:18:27 -07:00
2022-07-15 19:17:30 +02:00
2022-07-05 13:32:59 -07:00
2022-06-26 18:18:56 +02:00
2022-05-24 16:33:20 +09:00
2022-06-03 11:48:47 -07:00
2022-05-13 17:03:40 +09:00
2022-07-01 14:53:01 +02:00
2022-05-19 14:08:55 -07:00
2022-05-19 14:09:54 +10:00
2022-07-07 10:50:46 +02:00
2022-05-14 18:49:01 -04:00
2022-05-14 18:47:28 -04:00
2022-06-03 06:52:57 -07:00
2022-05-12 10:49:23 +02:00
2022-08-02 13:27:23 -07:00
2022-08-02 19:24:24 -07:00
2022-05-09 16:18:54 -07:00
2022-07-01 14:51:13 +02:00
2022-05-01 16:39:36 -04:00
2022-05-29 10:31:36 -07:00
2022-07-07 10:48:37 +01:00
2022-07-05 13:33:00 -07:00
2022-05-26 12:32:41 -07:00
2022-07-03 15:42:32 -07:00
2022-06-17 17:19:20 +08:00
2022-06-01 11:50:42 +02:00
2022-05-04 11:05:54 +02:00
2022-07-20 10:52:40 +01:00
2022-05-28 11:27:17 -07:00
2022-05-22 11:32:31 -07:00
2022-06-03 11:48:47 -07:00
2022-07-01 15:22:16 +02:00
2022-07-06 12:59:21 +02:00
2022-05-13 15:14:56 +02:00
2022-05-24 11:11:13 -07:00
2022-07-27 08:50:50 -06:00
2022-05-11 07:40:47 -06:00
2022-05-24 19:55:07 -07:00
2022-05-20 12:27:17 +02:00
2022-06-27 06:29:12 -06:00
2022-05-12 10:00:03 -05:00
2022-05-12 10:00:03 -05:00
2022-05-31 11:36:57 +02:00
2022-07-20 15:26:05 +01:00
2022-07-11 10:12:49 +01:00
2022-07-14 12:14:32 -06:00
2022-06-24 09:48:55 +02:00
2022-05-10 14:42:06 -07:00
2022-04-29 14:36:58 -07:00
2022-07-04 09:23:07 +02:00
2022-07-15 12:21:16 -04:00
2022-05-19 14:08:50 -07:00
2022-05-26 21:12:59 -04:00
2022-05-19 14:08:54 -07:00
2022-05-02 14:06:20 -06:00
2022-07-14 08:01:59 -04:00
2022-06-06 09:52:17 +09:00
2022-05-06 15:59:39 +02:00
2022-05-27 11:22:03 -07:00
2022-05-24 08:46:37 +02:00
2022-06-24 09:48:56 +02:00
2022-07-03 14:40:28 -07:00
2022-05-03 16:09:03 -04:00
2022-07-15 18:21:49 +00:00
2022-07-15 18:21:49 +00:00
2022-05-23 14:45:24 -05:00
2022-05-01 17:45:35 +01:00
2022-05-19 14:08:53 -07:00
2022-05-13 16:48:56 -07:00
2022-06-23 18:42:05 -07:00
2022-05-13 07:20:17 -07:00
2022-05-13 07:20:10 -07:00
2022-06-09 16:24:25 -04:00
2022-07-18 15:07:51 -07:00
2022-04-28 23:16:14 -07:00
2022-05-13 07:20:13 -07:00
2022-07-15 22:08:01 +02:00
2022-07-11 17:13:15 -06:00
2022-05-19 23:25:48 -04:00
2022-05-09 16:21:44 -04:00
2022-05-05 18:25:57 -07:00
2022-06-24 16:45:40 -07:00
2022-07-14 10:10:12 +02:00
2022-05-17 13:32:46 -04:00
2022-05-31 17:09:30 -04:00
2022-05-26 12:32:41 -07:00
2022-05-31 17:09:24 -04:00
2022-06-04 14:04:27 -07:00
2022-05-19 19:30:30 +02:00
2022-05-19 20:24:56 -04:00
2022-07-06 19:12:56 +02:00
2022-05-09 15:44:21 +02:00
2022-08-02 19:24:24 -07:00
2022-05-22 15:59:54 +10:00
2022-05-03 16:48:14 +02:00
2022-07-01 15:22:16 +02:00
2022-04-29 09:53:52 +02:00
2022-07-21 10:39:42 +02:00
2022-05-26 12:32:41 -07:00
2022-05-13 07:20:13 -07:00
2022-05-24 19:55:07 -07:00
2022-07-01 16:38:35 -06:00
2022-07-20 17:35:40 +02:00
2022-06-03 11:48:47 -07:00
2022-06-28 09:08:31 +02:00
2022-05-13 07:20:18 -07:00
2022-06-29 20:38:52 -07:00
2022-04-29 14:38:01 -07:00
2022-06-03 11:48:47 -07:00
2022-06-06 08:22:01 +02:00
2022-05-19 20:16:05 +02:00
2022-05-04 15:40:22 +05:30
2022-07-01 21:04:02 +02:00
2022-07-05 20:48:46 +02:00
2022-05-30 11:37:26 -07:00
2022-05-22 11:32:30 -07:00
2022-07-15 22:08:59 +02:00
2022-07-15 22:09:57 +02:00
2022-05-18 15:53:52 +02:00
2022-06-23 19:11:28 +02:00
2022-06-03 11:17:49 -07:00
2022-05-19 16:58:16 -07:00
2022-05-10 09:48:08 +02:00
2022-05-11 14:33:44 -05:00
2022-06-22 15:35:13 +02:00
2022-06-26 18:18:56 +02:00
2022-07-25 13:26:14 +02:00
2022-05-10 10:40:26 -07:00
2022-06-19 23:50:46 +02:00
2022-06-20 09:22:28 -07:00
2022-07-21 17:46:18 -07:00
2022-07-21 17:46:18 -07:00
2022-07-21 17:46:18 -07:00
2022-05-30 11:37:26 -07:00
2022-07-03 11:32:22 -07:00
2022-06-29 18:13:17 +01:00
2022-06-29 15:56:20 +02:00
2022-05-19 14:08:54 -07:00
2022-05-06 09:51:33 +02:00
2022-05-09 15:37:36 +02:00
2022-07-01 08:53:26 +02:00
2022-08-02 19:12:45 -07:00
2022-08-02 11:17:00 -07:00
2022-05-03 14:11:58 -07:00
2022-08-02 15:12:13 -07:00
2022-05-22 21:03:01 +01:00
2022-06-30 17:17:31 +02:00
2022-05-19 18:24:47 +02:00
2022-05-16 11:46:44 -07:00
2022-05-13 07:20:10 -07:00
2022-05-11 14:33:17 -05:00
2022-06-03 10:34:34 -07:00
2022-07-19 14:20:54 -07:00
2022-05-26 12:32:41 -07:00
2022-05-02 10:48:40 +02:00
2022-07-24 18:41:03 -06:00
2022-05-03 10:20:57 -07:00
2022-05-08 01:33:08 -07:00
2022-07-18 11:14:35 +01:00
2022-05-12 15:35:29 +02:00
2022-05-12 10:49:23 +02:00
2022-05-19 14:08:50 -07:00
2022-05-27 09:33:45 -07:00
2022-05-27 09:33:45 -07:00
2022-05-03 10:15:06 +02:00
2022-06-29 09:51:41 +02:00
2022-04-30 08:39:32 -06:00
2022-07-28 17:29:56 +02:00
2022-06-03 11:17:49 -07:00
2022-05-13 23:59:23 +02:00
2022-05-19 23:46:13 +02:00
2022-07-05 13:32:59 -07:00
2022-06-27 06:29:11 -06:00
2022-05-13 07:20:11 -07:00
2022-06-09 00:26:35 -04:00
2022-05-08 01:33:07 -07:00
2022-05-11 13:32:56 -06:00
2022-05-24 08:41:18 -06:00
2022-05-31 12:44:28 -04:00
2022-06-24 02:49:48 -04:00
2022-05-31 12:45:10 -04:00
2022-05-19 14:08:53 -07:00
2022-06-13 09:54:52 -07:00
2022-07-28 12:35:12 +02:00
2022-07-07 13:09:59 -06:00
2022-05-03 08:02:09 -05:00
2022-05-07 22:55:48 +02:00
2022-06-11 14:16:42 -10:00
2022-08-02 13:46:35 -07:00
2022-06-09 16:24:25 -04:00
2022-07-15 22:08:59 +02:00