<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/io_uring/sqpoll.c, branch v6.0</title>
<subtitle>Linux kernel source tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/'/>
<entry>
<title>audit, io_uring, io-wq: Fix memory leak in io_sq_thread() and io_wqe_worker()</title>
<updated>2022-08-04T14:33:54+00:00</updated>
<author>
<name>Peilin Ye</name>
<email>peilin.ye@bytedance.com</email>
</author>
<published>2022-08-03T22:23:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=f482aa98652795846cc55da98ebe331eb74f3d0b'/>
<id>f482aa98652795846cc55da98ebe331eb74f3d0b</id>
<content type='text'>
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):
&lt;...&gt;
    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:
      [&lt;ffffffff8135cfc3&gt;] audit_alloc+0x133/0x210
      [&lt;ffffffff81239e63&gt;] copy_process+0xcd3/0x2340
      [&lt;ffffffff8123b5f3&gt;] create_io_thread+0x63/0x90
      [&lt;ffffffff81686604&gt;] create_io_worker+0xb4/0x230
      [&lt;ffffffff81686f68&gt;] io_wqe_enqueue+0x248/0x3b0
      [&lt;ffffffff8167663a&gt;] io_queue_iowq+0xba/0x200
      [&lt;ffffffff816768b3&gt;] io_queue_async+0x113/0x180
      [&lt;ffffffff816840df&gt;] io_req_task_submit+0x18f/0x1a0
      [&lt;ffffffff816841cd&gt;] io_apoll_task_func+0xdd/0x120
      [&lt;ffffffff8167d49f&gt;] tctx_task_work+0x11f/0x570
      [&lt;ffffffff81272c4e&gt;] task_work_run+0x7e/0xc0
      [&lt;ffffffff8125a688&gt;] get_signal+0xc18/0xf10
      [&lt;ffffffff8111645b&gt;] arch_do_signal_or_restart+0x2b/0x730
      [&lt;ffffffff812ea44e&gt;] exit_to_user_mode_prepare+0x5e/0x180
      [&lt;ffffffff844ae1b2&gt;] syscall_exit_to_user_mode+0x12/0x20
      [&lt;ffffffff844a7e80&gt;] 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: 5bd2182d58e9 ("audit,io_uring,io-wq: add some basic audit support to io_uring")
Suggested-by: Paul Moore &lt;paul@paul-moore.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Peilin Ye &lt;peilin.ye@bytedance.com&gt;
Acked-by: Paul Moore &lt;paul@paul-moore.com&gt;
Link: https://lore.kernel.org/r/20220803222343.31673-1-yepeilin.cs@gmail.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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):
&lt;...&gt;
    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:
      [&lt;ffffffff8135cfc3&gt;] audit_alloc+0x133/0x210
      [&lt;ffffffff81239e63&gt;] copy_process+0xcd3/0x2340
      [&lt;ffffffff8123b5f3&gt;] create_io_thread+0x63/0x90
      [&lt;ffffffff81686604&gt;] create_io_worker+0xb4/0x230
      [&lt;ffffffff81686f68&gt;] io_wqe_enqueue+0x248/0x3b0
      [&lt;ffffffff8167663a&gt;] io_queue_iowq+0xba/0x200
      [&lt;ffffffff816768b3&gt;] io_queue_async+0x113/0x180
      [&lt;ffffffff816840df&gt;] io_req_task_submit+0x18f/0x1a0
      [&lt;ffffffff816841cd&gt;] io_apoll_task_func+0xdd/0x120
      [&lt;ffffffff8167d49f&gt;] tctx_task_work+0x11f/0x570
      [&lt;ffffffff81272c4e&gt;] task_work_run+0x7e/0xc0
      [&lt;ffffffff8125a688&gt;] get_signal+0xc18/0xf10
      [&lt;ffffffff8111645b&gt;] arch_do_signal_or_restart+0x2b/0x730
      [&lt;ffffffff812ea44e&gt;] exit_to_user_mode_prepare+0x5e/0x180
      [&lt;ffffffff844ae1b2&gt;] syscall_exit_to_user_mode+0x12/0x20
      [&lt;ffffffff844a7e80&gt;] 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: 5bd2182d58e9 ("audit,io_uring,io-wq: add some basic audit support to io_uring")
Suggested-by: Paul Moore &lt;paul@paul-moore.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Peilin Ye &lt;peilin.ye@bytedance.com&gt;
Acked-by: Paul Moore &lt;paul@paul-moore.com&gt;
Link: https://lore.kernel.org/r/20220803222343.31673-1-yepeilin.cs@gmail.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>io_uring: kill extra io_uring_types.h includes</title>
<updated>2022-07-25T00:39:14+00:00</updated>
<author>
<name>Pavel Begunkov</name>
<email>asml.silence@gmail.com</email>
</author>
<published>2022-06-16T12:57:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=27a9d66fec77cff0e32d2ecd5d0ac7ef878a7bb0'/>
<id>27a9d66fec77cff0e32d2ecd5d0ac7ef878a7bb0</id>
<content type='text'>
io_uring/io_uring.h already includes io_uring_types.h, no need to
include it every time. Kill it in a bunch of places, it prepares us for
following patches.

Signed-off-by: Pavel Begunkov &lt;asml.silence@gmail.com&gt;
Link: https://lore.kernel.org/r/94d8c943fbe0ef949981c508ddcee7fc1c18850f.1655384063.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
io_uring/io_uring.h already includes io_uring_types.h, no need to
include it every time. Kill it in a bunch of places, it prepares us for
following patches.

Signed-off-by: Pavel Begunkov &lt;asml.silence@gmail.com&gt;
Link: https://lore.kernel.org/r/94d8c943fbe0ef949981c508ddcee7fc1c18850f.1655384063.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>io_uring: move SQPOLL related handling into its own file</title>
<updated>2022-07-25T00:39:12+00:00</updated>
<author>
<name>Jens Axboe</name>
<email>axboe@kernel.dk</email>
</author>
<published>2022-05-25T15:13:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=17437f311490d873a5157f65a84317d16270fd38'/>
<id>17437f311490d873a5157f65a84317d16270fd38</id>
<content type='text'>
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</pre>
</div>
</content>
</entry>
</feed>
