[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7ac936ab-ff4f-457c-a745-56bccaa19a08@kernel.dk>
Date: Wed, 27 Aug 2025 16:23:28 -0600
From: Jens Axboe <axboe@...nel.dk>
To: Keith Busch <kbusch@...nel.org>
Cc: Qingyue Zhang <chunzhennn@...com>, io-uring@...r.kernel.org,
linux-kernel@...r.kernel.org, Suoxing Zhang <aftern00n@...com>
Subject: Re: [PATCH 2/2] io_uring/kbuf: fix infinite loop in
io_kbuf_inc_commit()
On 8/27/25 3:59 PM, Keith Busch wrote:
> On Wed, Aug 27, 2025 at 03:45:28PM -0600, Jens Axboe wrote:
>>> + buf_len = READ_ONCE(buf->len);
>>> + this_len = min_t(int, len, buf_len);
>>> + buf_len -= this_len;
>>> + if (buf_len) {
>>> buf->addr += this_len;
>>> + buf->len = buf_len;
>>> return false;
>>> }
>>> + buf->len = 0;
>
> Purely for symmetry, assigning buf->len ought to be a WRITE_ONCE.
I did think about that, perhaps I should've mentioned it in the commit
message. While the reader side is important for the reasons stated, the
updating of buf->len isn't really as only the serialized kernel side
will do it. Hence the WRITE_ONCE() should not be needed on the write
side, outside of perhaps documenting that this is a shared buffer.
--
Jens Axboe
Powered by blists - more mailing lists