All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: bfields@fieldses.org (J. Bruce Fields)
To: schumaker.anna@gmail.com
Cc: Trond.Myklebust@hammerspace.com, linux-nfs@vger.kernel.org,
	Anna.Schumaker@Netapp.com
Subject: Re: [PATCH] sunrpc: Avoid a KASAN slab-out-of-bounds bug in xdr_set_page_base()
Date: Mon, 14 Jun 2021 19:14:40 -0400	[thread overview]
Message-ID: <20210614231440.GD16500@fieldses.org> (raw)
In-Reply-To: <20210609210729.254578-1-Anna.Schumaker@Netapp.com>

On Wed, Jun 09, 2021 at 05:07:29PM -0400, schumaker.anna@gmail.com wrote:
> From: Anna Schumaker <Anna.Schumaker@Netapp.com>
> 
> This seems to happen fairly easily during READ_PLUS testing on NFS v4.2.

Yep, I hit a KASAN warning here every time, and this fixes it,
thanks.--b.

> I found that we could end up accessing xdr->buf->pages[pgnr] with a pgnr
> greater than the number of pages in the array. So let's just return
> early if we're setting base to a point at the end of the page data and
> let xdr_set_tail_base() handle setting up the buffer pointers instead.
> 
> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
> ---
>  net/sunrpc/xdr.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
> index 3964ff74ee51..ca10ba2626f2 100644
> --- a/net/sunrpc/xdr.c
> +++ b/net/sunrpc/xdr.c
> @@ -1230,10 +1230,9 @@ static unsigned int xdr_set_page_base(struct xdr_stream *xdr,
>  	void *kaddr;
>  
>  	maxlen = xdr->buf->page_len;
> -	if (base >= maxlen) {
> -		base = maxlen;
> -		maxlen = 0;
> -	} else
> +	if (base >= maxlen)
> +		return 0;
> +	else
>  		maxlen -= base;
>  	if (len > maxlen)
>  		len = maxlen;
> -- 
> 2.32.0

  reply	other threads:[~2021-06-14 23:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09 21:07 [PATCH] sunrpc: Avoid a KASAN slab-out-of-bounds bug in xdr_set_page_base() schumaker.anna
2021-06-14 23:14 ` J. Bruce Fields [this message]
2021-08-12 20:32   ` J. Bruce Fields
2021-08-26 19:44     ` Anna Schumaker
2021-08-26 20:42       ` J. Bruce Fields
2021-08-26 20:51         ` J. Bruce Fields

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=20210614231440.GD16500@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=Anna.Schumaker@Netapp.com \
    --cc=Trond.Myklebust@hammerspace.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=schumaker.anna@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.