diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2012-03-02 17:13:50 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-03-20 15:36:15 -0400 |
commit | ab4684d1560f8d77f6ce82bd3f1f82937070d397 (patch) | |
tree | 71da95fc7b956d6c69f9ecf5ef98a76b158c387f /fs/nfsd/nfs4state.c | |
parent | 8f199b8262cb150d055d29ba31faf0128ace4714 (diff) |
NFSD: Fix nfs4_verifier memory alignment
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>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r-- | fs/nfsd/nfs4state.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index cdc406a28eff..e318964d8aca 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -1174,12 +1174,12 @@ static void gen_clid(struct nfs4_client *clp) | |||
1174 | 1174 | ||
1175 | static void gen_confirm(struct nfs4_client *clp) | 1175 | static void gen_confirm(struct nfs4_client *clp) |
1176 | { | 1176 | { |
1177 | __be32 verf[2]; | ||
1177 | static u32 i; | 1178 | static u32 i; |
1178 | u32 *p; | ||
1179 | 1179 | ||
1180 | p = (u32 *)clp->cl_confirm.data; | 1180 | verf[0] = (__be32)get_seconds(); |
1181 | *p++ = get_seconds(); | 1181 | verf[1] = (__be32)i++; |
1182 | *p++ = i++; | 1182 | memcpy(clp->cl_confirm.data, verf, sizeof(clp->cl_confirm.data)); |
1183 | } | 1183 | } |
1184 | 1184 | ||
1185 | static struct nfs4_stid *find_stateid(struct nfs4_client *cl, stateid_t *t) | 1185 | static struct nfs4_stid *find_stateid(struct nfs4_client *cl, stateid_t *t) |