Re: [PATCH] RDMA/rxe: Fix out-of-range unsigned-to-signed conversion for RDMA message in 2GiB size

From: Jason Gunthorpe

Date: Wed Sep 16 2026 - 12:54:01 EST


On Wed, Sep 16, 2026 at 11:23:37AM +0800, Honggang LI wrote:
> On Tue, Sep 15, 2026 at 02:49:14PM +0300, Leon Romanovsky wrote:
> > > After fixed it, the active side of RDMA READ failed with error code
> > > "IB_WC_LOC_PROT_ERR". When RDMA_READ_RESPONSE_FIRST packet recived by
> > > the active side, `do_read` call `copy_data`. dma->resid is u32 0x80000000.
> > >
> > > int resid = dma->resid;
> > >
> > > This conversion set resid to -2147483648. `copy_data` abort as length
> > > greater than resid. Change resid to int64_t fixes this issue.
> >
> > Why not size_t?
>
> First, size_t is u64. dma->resid is u32. If use unsigned type, u32 is enough.
>
> Second, I'm not sure it is right to use unsigned type. In `copy_data`,
> the loop terminate on negative value of `length`.

Please do not use signed values to store must-be-unsized quantities in
rdma land..

> > > - payload = min_t(int, res->read.resid, mtu);
> > > + payload = min_t(u32, res->read.resid, mtu);
> >
> > Why don't we use the proper types from the start to avoid the need for
> > u32 casts?
>
> Again, minimal the changes with u32 casts. We need something like this
> to use u32.

This seems better to me

Jason