linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@redhat.com>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH] NFSD: Fix nfs4_verifier memory alignment
Date: Mon, 12 Mar 2012 11:04:08 -0400	[thread overview]
Message-ID: <20120312150408.GA17153@pad.fieldses.org> (raw)
In-Reply-To: <2418988F-A737-42F6-8AA0-99E85B9B8C66@oracle.com>

On Mon, Mar 12, 2012 at 10:57:32AM -0400, Chuck Lever wrote:
> 
> On Mar 12, 2012, at 10:20 AM, J. Bruce Fields wrote:
> 
> > On Fri, Mar 02, 2012 at 05:13:50PM -0500, Chuck Lever wrote:
> >> Clean up due to code review.
> >> 
> >> The nfs4_verifier's data field is not guaranteed to be u32-aligned.
> >> Casting an array of chars to a u32 * is considered generally
> >> hazardous.
> >> 
> >> We can fix most of this by using a __be32 array to generate the
> >> verifier's contents and then byte-copying it into the verifier field.
> >> 
> >> However, there is one spot where there is a backwards compatibility
> >> constraint: the do_nfsd_create() call expects a verifier which is
> >> 32-bit aligned.  Fix this spot by forcing the alignment of the create
> >> verifier in the nfsd4_open args structure.
> >> 
> >> Also, sizeof(nfs4_verifer) is the size of the in-core verifier data
> >> structure, but NFS4_VERIFIER_SIZE is the number of octets in an XDR'd
> >> verifier.  The two are not interchangeable, even if they happen to
> >> have the same value.
> >> 
> >> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> >> ---
> >> 
> >> Hi Bruce-
> >> 
> >> Compile-tested only.  Does this look reasonable?
> > 
> > Looks fine, but the setclientid verifier stuff belongs in a separate
> > patch.
> 
> Thanks for the review.  I'm not clear on exactly which hunks you would like split.

This:

> >> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> >> index c5cddd6..9f0e139 100644
> >> --- a/fs/nfsd/nfs4state.c
> >> +++ b/fs/nfsd/nfs4state.c
> >> @@ -1138,12 +1138,12 @@ static void gen_clid(struct nfs4_client *clp)
> >> 
> >> static void gen_confirm(struct nfs4_client *clp)
> >> {
> >> +	__be32 verf[2];
> >> 	static u32 i;
> >> -	u32 *p;
> >> 
> >> -	p = (u32 *)clp->cl_confirm.data;
> >> -	*p++ = get_seconds();
> >> -	*p++ = i++;
> >> +	verf[0] = (__be32)get_seconds();
> >> +	verf[1] = (__be32)i++;
> >> +	memcpy(clp->cl_confirm.data, verf, sizeof(clp->cl_confirm.data));

This cl_confirm verifier really has nothing to do with the write
verifier (though maybe it has a similar problem).

--b.

  reply	other threads:[~2012-03-12 15:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-02 22:13 [PATCH] NFSD: Fix nfs4_verifier memory alignment Chuck Lever
2012-03-12 14:20 ` J. Bruce Fields
2012-03-12 14:57   ` Chuck Lever
2012-03-12 15:04     ` J. Bruce Fields [this message]
2012-03-12 15:24       ` Chuck Lever
2012-03-20 19:40         ` 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=20120312150408.GA17153@pad.fieldses.org \
    --to=bfields@redhat.com \
    --cc=bfields@fieldses.org \
    --cc=chuck.lever@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).