Re: [PATCH v1] SUNRPC: Fix READ_PLUS crasher

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Looks like the crash I saw no longer reproduces after that, fwiw.

--b.

On Thu, Jun 30, 2022 at 01:24:20PM -0400, Chuck Lever wrote:
> Looks like there are still cases when "space_left - frag1bytes" can
> legitimately exceed PAGE_SIZE. Ensure that xdr->end always remains
> within the current encode buffer.
> 
> Reported-by: Bruce Fields <bfields@xxxxxxxxxxxx>
> Reported-by: Zorro Lang <zlang@xxxxxxxxxx>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=216151
> Fixes: 6c254bf3b637 ("SUNRPC: Fix the calculation of xdr->end in xdr_get_next_encode_buffer()")
> Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx>
> ---
>  net/sunrpc/xdr.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Hi-
> 
> I had a few minutes yesterday afternoon to look into this one. The
> following one-liner seems to address the issue and passes my smoke
> tests with NFSv4.1/TCP and NFSv3/RDMA. Any thoughts?
> 
> 
> diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
> index f87a2d8f23a7..916659be2774 100644
> --- a/net/sunrpc/xdr.c
> +++ b/net/sunrpc/xdr.c
> @@ -987,7 +987,7 @@ static noinline __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr,
>  	if (space_left - nbytes >= PAGE_SIZE)
>  		xdr->end = p + PAGE_SIZE;
>  	else
> -		xdr->end = p + space_left - frag1bytes;
> +		xdr->end = p + min_t(int, space_left - frag1bytes, PAGE_SIZE);
>  
>  	xdr->buf->page_len += frag2bytes;
>  	xdr->buf->len += nbytes;
> 



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux