All of lore.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Kinglong Mee <kinglongmee@gmail.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH] nfsd: make calculate  reserved space correctly
Date: Thu, 12 Dec 2013 11:24:52 -0500	[thread overview]
Message-ID: <20131212162452.GG11521@fieldses.org> (raw)
In-Reply-To: <52A5AA09.4030409@gmail.com>

On Mon, Dec 09, 2013 at 07:31:21PM +0800, Kinglong Mee wrote:
> rpcsec_gss_oid is defined as below, So, must using XDR_LEN to calculate reserved space.
> When len is not the multiples of 4, client will get bad data.

Looking at the definition of RESERVE_SPACE: first, it doesn't actually
advance any pointers, all it does is an overflow check, so there
shouldn't be data corruption unless we're at the end of a page (which
shouldn't happen here).  Second, RESERVE_SPACE actually rounds up for
is, so we wouldn't hit that problem anyway.

Nevertheless, agreed that it's probably good practice to round up here
as well.

--b.

> 
> struct rpcsec_gss_oid {
>         unsigned int    len;
>         u8              data[GSS_OID_MAX_LEN];
> };
> 
> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
> ---
>  fs/nfsd/nfs4xdr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index b0b886e..a57e67d 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -3233,7 +3233,7 @@ nfsd4_do_encode_secinfo(struct nfsd4_compoundres *resp,
>  
>  		if (rpcauth_get_gssinfo(pf, &info) == 0) {
>  			supported++;
> -			RESERVE_SPACE(4 + 4 + info.oid.len + 4 + 4);
> +			RESERVE_SPACE(4 + 4 + XDR_LEN(info.oid.len) + 4 + 4);
>  			WRITE32(RPC_AUTH_GSS);
>  			WRITE32(info.oid.len);
>  			WRITEMEM(info.oid.data, info.oid.len);
> -- 
> 1.8.4.2

  reply	other threads:[~2013-12-12 16:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-09 11:31 [PATCH] nfsd: make calculate reserved space correctly Kinglong Mee
2013-12-12 16:24 ` J. Bruce Fields [this message]
2013-12-13  1:18   ` Kinglong Mee

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=20131212162452.GG11521@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=kinglongmee@gmail.com \
    --cc=linux-nfs@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 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.