]> git.apps.os.sepia.ceph.com Git - ceph-client.git/commit
io_uring/kbuf: always use READ_ONCE() to read ring provided buffer lengths
authorJens Axboe <axboe@kernel.dk>
Wed, 27 Aug 2025 21:27:30 +0000 (15:27 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 28 Aug 2025 11:48:34 +0000 (05:48 -0600)
commit98b6fa62c84f2e129161e976a5b9b3cb4ccd117b
tree7a4d2a10e89a2c81bcfe9e3d8686bb0e8adbef5a
parentc64eff368ac676e8540344d27a3de47e0ad90d21
io_uring/kbuf: always use READ_ONCE() to read ring provided buffer lengths

Since the buffers are mapped from userspace, it is prudent to use
READ_ONCE() to read the value into a local variable, and use that for
any other actions taken. Having a stable read of the buffer length
avoids worrying about it changing after checking, or being read multiple
times.

Similarly, the buffer may well change in between it being picked and
being committed. Ensure the looping for incremental ring buffer commit
stops if it hits a zero sized buffer, as no further progress can be made
at that point.

Fixes: ae98dbf43d75 ("io_uring/kbuf: add support for incremental buffer consumption")
Link: https://lore.kernel.org/io-uring/tencent_000C02641F6250C856D0C26228DE29A3D30A@qq.com/
Reported-by: Qingyue Zhang <chunzhennn@qq.com>
Reported-by: Suoxing Zhang <aftern00n@qq.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/kbuf.c