Re: [PATCH rdma-next] RDMA/siw: Fix overflow in inline SGE length check

From: Bernard Metzler

Date: Fri Dec 04 2026 - 08:29:39 EST


On 02.12.2026 20:48, Andrew Stellman wrote:
On Wed, Dec 02, 2026 at 07:18:50PM +0100, Bernard Metzler wrote:
The bug is that 'bytes' is declared signed while 'core_sge->length'
is unsigned. Just make it unsigned as well.

Thanks, Bernard. I tried that. With 'bytes' as unsigned int, the same
test (inline SGE lengths 16 and 0xfffffff8) still posted and KASAN still
reported the out-of-bounds write, because the sum wraps to 8. With
'bytes' as u64 it returned -EINVAL and KASAN was quiet, the same as v1.
Would you rather have the u64 version, or keep v1's check before the
addition?

Andrew
You are right. The overflow may occure when a huge second
SGE comes in. This is all very theoretical for trusted
kernel clients. It cannot happen at all for user land clients,
since inline WR representation is restricted to just one SGE
at the send queue.

I'd prefer to make bytes an unsigned 64. It just looks more
clean to me than substracting and testing before addition.

Thanks,
Bernard.