From: Pavel Begunkov <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>, Anas Iqbal <mohd.abd.6602@gmail.com>
Cc: io-uring@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] io_uring: cast id to u64 before shifting in io_allocate_rbuf_ring()
Date: Mon, 16 Mar 2026 23:22:46 +0000 [thread overview]
Message-ID: <231361d3-dfaa-422d-a246-03f9a51b89f2@gmail.com> (raw)
In-Reply-To: <1f79957a-5b23-4bbd-af8d-9d1c86791645@kernel.dk>
On 3/16/26 19:37, Jens Axboe wrote:
> On 3/16/26 9:06 AM, Anas Iqbal wrote:
>> Smatch warns:
>> io_uring/zcrx.c:393 io_allocate_rbuf_ring() warn: should 'id << 16' be a 64 bit type?
>>
>> The expression 'id << IORING_OFF_PBUF_SHIFT' is evaluated using 32-bit
>> arithmetic because id is a u32. This may overflow before being promoted
>> to the 64-bit mmap_offset.
>>
>> Cast id to u64 before shifting to ensure the shift is performed in
>> 64-bit arithmetic.
>
> I'd be impressed if 'id' could be large enough to cause this to
> overflow. AFAICT, you'd need more than 64K interface queues registered
> to hit this. So I think this should be reframed as a cleanup, to appease
> smatch.
Pretty much so. I'll queue up the patch targeting 7.1, thanks
--
Pavel Begunkov
prev parent reply other threads:[~2026-03-16 23:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 15:06 [PATCH] io_uring: cast id to u64 before shifting in io_allocate_rbuf_ring() Anas Iqbal
2026-03-16 19:37 ` Jens Axboe
2026-03-16 23:22 ` Pavel Begunkov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=231361d3-dfaa-422d-a246-03f9a51b89f2@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mohd.abd.6602@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox