<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/io_uring, branch v6.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v6.2</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v6.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2023-01-27T13:29:29Z</updated>
<entry>
<title>io_uring: always prep_async for drain requests</title>
<updated>2023-01-27T13:29:29Z</updated>
<author>
<name>Dylan Yudaken</name>
<email>dylany@meta.com</email>
</author>
<published>2023-01-27T10:59:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ef5c600adb1d985513d2b612cc90403a148ff287'/>
<id>urn:sha1:ef5c600adb1d985513d2b612cc90403a148ff287</id>
<content type='text'>
Drain requests all go through io_drain_req, which has a quick exit in case
there is nothing pending (ie the drain is not useful). In that case it can
run the issue the request immediately.

However for safety it queues it through task work.
The problem is that in this case the request is run asynchronously, but
the async work has not been prepared through io_req_prep_async.

This has not been a problem up to now, as the task work always would run
before returning to userspace, and so the user would not have a chance to
race with it.

However - with IORING_SETUP_DEFER_TASKRUN - this is no longer the case and
the work might be defered, giving userspace a chance to change data being
referred to in the request.

Instead _always_ prep_async for drain requests, which is simpler anyway
and removes this issue.

Cc: stable@vger.kernel.org
Fixes: c0e0d6ba25f1 ("io_uring: add IORING_SETUP_DEFER_TASKRUN")
Signed-off-by: Dylan Yudaken &lt;dylany@meta.com&gt;
Link: https://lore.kernel.org/r/20230127105911.2420061-1-dylany@meta.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring/net: cache provided buffer group value for multishot receives</title>
<updated>2023-01-23T14:08:08Z</updated>
<author>
<name>Jens Axboe</name>
<email>axboe@kernel.dk</email>
</author>
<published>2023-01-22T17:02:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b00c51ef8f72ced0965d021a291b98ff822c5337'/>
<id>urn:sha1:b00c51ef8f72ced0965d021a291b98ff822c5337</id>
<content type='text'>
If we're using ring provided buffers with multishot receive, and we end
up doing an io-wq based issue at some points that also needs to select
a buffer, we'll lose the initially assigned buffer group as
io_ring_buffer_select() correctly clears the buffer group list as the
issue isn't serialized by the ctx uring_lock. This is fine for normal
receives as the request puts the buffer and finishes, but for multishot,
we will re-arm and do further receives. On the next trigger for this
multishot receive, the receive will try and pick from a buffer group
whose value is the same as the buffer ID of the las receive. That is
obviously incorrect, and will result in a premature -ENOUFS error for
the receive even if we had available buffers in the correct group.

Cache the buffer group value at prep time, so we can restore it for
future receives. This only needs doing for the above mentioned case, but
just do it by default to keep it easier to read.

Cc: stable@vger.kernel.org
Fixes: b3fdea6ecb55 ("io_uring: multishot recv")
Fixes: 9bb66906f23e ("io_uring: support multishot in recvmsg")
Cc: Dylan Yudaken &lt;dylany@meta.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring/poll: don't reissue in case of poll race on multishot request</title>
<updated>2023-01-20T22:11:54Z</updated>
<author>
<name>Jens Axboe</name>
<email>axboe@kernel.dk</email>
</author>
<published>2023-01-20T22:08:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8caa03f10bf92cb8657408a6ece6a8a73f96ce13'/>
<id>urn:sha1:8caa03f10bf92cb8657408a6ece6a8a73f96ce13</id>
<content type='text'>
A previous commit fixed a poll race that can occur, but it's only
applicable for multishot requests. For a multishot request, we can safely
ignore a spurious wakeup, as we never leave the waitqueue to begin with.

A blunt reissue of a multishot armed request can cause us to leak a
buffer, if they are ring provided. While this seems like a bug in itself,
it's not really defined behavior to reissue a multishot request directly.
It's less efficient to do so as well, and not required to rearm anything
like it is for singleshot poll requests.

Cc: stable@vger.kernel.org
Fixes: 6e5aedb9324a ("io_uring/poll: attempt request issue after racy poll wakeup")
Reported-and-tested-by: Olivier Langlois &lt;olivier@trillion01.com&gt;
Link: https://github.com/axboe/liburing/issues/778
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring/msg_ring: fix remote queue to disabled ring</title>
<updated>2023-01-20T16:49:34Z</updated>
<author>
<name>Pavel Begunkov</name>
<email>asml.silence@gmail.com</email>
</author>
<published>2023-01-20T16:38:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8579538c89e33ce78be2feb41e07489c8cbf8f31'/>
<id>urn:sha1:8579538c89e33ce78be2feb41e07489c8cbf8f31</id>
<content type='text'>
IORING_SETUP_R_DISABLED rings don't have the submitter task set, so
it's not always safe to use -&gt;submitter_task. Disallow posting msg_ring
messaged to disabled rings. Also add task NULL check for loosy sync
around testing for IORING_SETUP_R_DISABLED.

Cc: stable@vger.kernel.org
Fixes: 6d043ee1164ca ("io_uring: do msg_ring in target task via tw")
Signed-off-by: Pavel Begunkov &lt;asml.silence@gmail.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring/msg_ring: fix flagging remote execution</title>
<updated>2023-01-20T16:49:29Z</updated>
<author>
<name>Pavel Begunkov</name>
<email>asml.silence@gmail.com</email>
</author>
<published>2023-01-20T16:38:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=56d8e3180c065c9b78ed77afcd0cf99677a4e22f'/>
<id>urn:sha1:56d8e3180c065c9b78ed77afcd0cf99677a4e22f</id>
<content type='text'>
There is a couple of problems with queueing a tw in io_msg_ring_data()
for remote execution. First, once we queue it the target ring can
go away and so setting IORING_SQ_TASKRUN there is not safe. Secondly,
the userspace might not expect IORING_SQ_TASKRUN.

Extract a helper and uniformly use TWA_SIGNAL without TWA_SIGNAL_NO_IPI
tricks for now, just as it was done in the original patch.

Cc: stable@vger.kernel.org
Fixes: 6d043ee1164ca ("io_uring: do msg_ring in target task via tw")
Signed-off-by: Pavel Begunkov &lt;asml.silence@gmail.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring/msg_ring: fix missing lock on overflow for IOPOLL</title>
<updated>2023-01-19T17:43:59Z</updated>
<author>
<name>Jens Axboe</name>
<email>axboe@kernel.dk</email>
</author>
<published>2023-01-19T16:04:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e12d7a46f65ae4b7d58a5e0c1cbfa825cf8d830d'/>
<id>urn:sha1:e12d7a46f65ae4b7d58a5e0c1cbfa825cf8d830d</id>
<content type='text'>
If the target ring is configured with IOPOLL, then we always need to hold
the target ring uring_lock before posting CQEs. We could just grab it
unconditionally, but since we don't expect many target rings to be of this
type, make grabbing the uring_lock conditional on the ring type.

Link: https://lore.kernel.org/io-uring/Y8krlYa52%2F0YGqkg@ip-172-31-85-199.ec2.internal/
Reported-by: Xingyuan Mo &lt;hdthky0@gmail.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring/msg_ring: move double lock/unlock helpers higher up</title>
<updated>2023-01-19T16:01:27Z</updated>
<author>
<name>Jens Axboe</name>
<email>axboe@kernel.dk</email>
</author>
<published>2023-01-19T16:01:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=423d5081d0451faa59a707e57373801da5b40141'/>
<id>urn:sha1:423d5081d0451faa59a707e57373801da5b40141</id>
<content type='text'>
In preparation for needing them somewhere else, move them and get rid of
the unused 'issue_flags' for the unlock side.

No functional changes in this patch.

Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring: lock overflowing for IOPOLL</title>
<updated>2023-01-13T14:32:46Z</updated>
<author>
<name>Pavel Begunkov</name>
<email>asml.silence@gmail.com</email>
</author>
<published>2023-01-12T13:08:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=544d163d659d45a206d8929370d5a2984e546cb7'/>
<id>urn:sha1:544d163d659d45a206d8929370d5a2984e546cb7</id>
<content type='text'>
syzbot reports an issue with overflow filling for IOPOLL:

WARNING: CPU: 0 PID: 28 at io_uring/io_uring.c:734 io_cqring_event_overflow+0x1c0/0x230 io_uring/io_uring.c:734
CPU: 0 PID: 28 Comm: kworker/u4:1 Not tainted 6.2.0-rc3-syzkaller-16369-g358a161a6a9e #0
Workqueue: events_unbound io_ring_exit_work
Call trace:
 io_cqring_event_overflow+0x1c0/0x230 io_uring/io_uring.c:734
 io_req_cqe_overflow+0x5c/0x70 io_uring/io_uring.c:773
 io_fill_cqe_req io_uring/io_uring.h:168 [inline]
 io_do_iopoll+0x474/0x62c io_uring/rw.c:1065
 io_iopoll_try_reap_events+0x6c/0x108 io_uring/io_uring.c:1513
 io_uring_try_cancel_requests+0x13c/0x258 io_uring/io_uring.c:3056
 io_ring_exit_work+0xec/0x390 io_uring/io_uring.c:2869
 process_one_work+0x2d8/0x504 kernel/workqueue.c:2289
 worker_thread+0x340/0x610 kernel/workqueue.c:2436
 kthread+0x12c/0x158 kernel/kthread.c:376
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:863

There is no real problem for normal IOPOLL as flush is also called with
uring_lock taken, but it's getting more complicated for IOPOLL|SQPOLL,
for which __io_cqring_overflow_flush() happens from the CQ waiting path.

Reported-and-tested-by: syzbot+6805087452d72929404e@syzkaller.appspotmail.com
Cc: stable@vger.kernel.org # 5.10+
Signed-off-by: Pavel Begunkov &lt;asml.silence@gmail.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring/poll: attempt request issue after racy poll wakeup</title>
<updated>2023-01-12T17:35:51Z</updated>
<author>
<name>Jens Axboe</name>
<email>axboe@kernel.dk</email>
</author>
<published>2023-01-10T17:44:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6e5aedb9324aab1c14a23fae3d8eeb64a679c20e'/>
<id>urn:sha1:6e5aedb9324aab1c14a23fae3d8eeb64a679c20e</id>
<content type='text'>
If we have multiple requests waiting on the same target poll waitqueue,
then it's quite possible to get a request triggered and get disappointed
in not being able to make any progress with it. If we race in doing so,
we'll potentially leave the poll request on the internal tables, but
removed from the waitqueue. That means that any subsequent trigger of
the poll waitqueue will not kick that request into action, causing an
application to potentially wait for completion of a request that will
never happen.

Fix this by adding a new poll return state, IOU_POLL_REISSUE. Rather
than have complicated logic for how to re-arm a given type of request,
just punt it for a reissue.

While in there, move the 'ret' variable to the only section where it
gets used. This avoids confusion the scope of it.

Cc: stable@vger.kernel.org
Fixes: eb0089d629ba ("io_uring: single shot poll removal optimisation")
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring/fdinfo: include locked hash table in fdinfo output</title>
<updated>2023-01-10T17:24:52Z</updated>
<author>
<name>Jens Axboe</name>
<email>axboe@kernel.dk</email>
</author>
<published>2023-01-10T17:24:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ea97cbebaf861d99c3e892275147e6fca6d2c1ca'/>
<id>urn:sha1:ea97cbebaf861d99c3e892275147e6fca6d2c1ca</id>
<content type='text'>
A previous commit split the hash table for polled requests into two
parts, but didn't get the fdinfo output updated. This means that it's
less useful for debugging, as we may think a given request is not pending
poll.

Fix this up by dumping the locked hash table contents too.

Fixes: 9ca9fb24d5fe ("io_uring: mutex locked poll hashing")
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
</feed>
