diff options
author | J. Bruce Fields <bfields@redhat.com> | 2014-02-11 11:29:05 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2014-02-11 13:48:11 -0500 |
commit | 09bdc2d70dedd0fc0358da93bca664c7b11ff907 (patch) | |
tree | d345805a52a70a88485037122e577f1edebc9441 /fs/nfsd/nfs4acl.c | |
parent | b28a960c42fcd9cfc987441fa6d1c1a471f0f9ed (diff) |
nfsd4: fix acl buffer overrun
4ac7249ea5a0ceef9f8269f63f33cc873c3fac61 "nfsd: use get_acl and
->set_acl" forgets to set the size in the case get_acl() succeeds, so
_posix_to_nfsv4_one() can then write past the end of its allocation.
Symptoms were slab corruption warnings.
Also, some minor cleanup while we're here. (Among other things, note
that the first few lines guarantee that pacl is non-NULL.)
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4acl.c')
-rw-r--r-- | fs/nfsd/nfs4acl.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/fs/nfsd/nfs4acl.c b/fs/nfsd/nfs4acl.c index d3a587144222..d190e33d0ec2 100644 --- a/fs/nfsd/nfs4acl.c +++ b/fs/nfsd/nfs4acl.c | |||
@@ -151,17 +151,15 @@ nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry, | |||
151 | pacl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL); | 151 | pacl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL); |
152 | if (IS_ERR(pacl)) | 152 | if (IS_ERR(pacl)) |
153 | return PTR_ERR(pacl); | 153 | return PTR_ERR(pacl); |
154 | /* allocate for worst case: one (deny, allow) pair each: */ | ||
155 | size += 2 * pacl->a_count; | ||
156 | } | 154 | } |
155 | /* allocate for worst case: one (deny, allow) pair each: */ | ||
156 | size += 2 * pacl->a_count; | ||
157 | 157 | ||
158 | if (S_ISDIR(inode->i_mode)) { | 158 | if (S_ISDIR(inode->i_mode)) { |
159 | flags = NFS4_ACL_DIR; | 159 | flags = NFS4_ACL_DIR; |
160 | dpacl = get_acl(inode, ACL_TYPE_DEFAULT); | 160 | dpacl = get_acl(inode, ACL_TYPE_DEFAULT); |
161 | if (dpacl) | 161 | if (dpacl) |
162 | size += 2 * dpacl->a_count; | 162 | size += 2 * dpacl->a_count; |
163 | } else { | ||
164 | dpacl = NULL; | ||
165 | } | 163 | } |
166 | 164 | ||
167 | *acl = nfs4_acl_new(size); | 165 | *acl = nfs4_acl_new(size); |
@@ -170,8 +168,7 @@ nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry, | |||
170 | goto out; | 168 | goto out; |
171 | } | 169 | } |
172 | 170 | ||
173 | if (pacl) | 171 | _posix_to_nfsv4_one(pacl, *acl, flags & ~NFS4_ACL_TYPE_DEFAULT); |
174 | _posix_to_nfsv4_one(pacl, *acl, flags & ~NFS4_ACL_TYPE_DEFAULT); | ||
175 | 172 | ||
176 | if (dpacl) | 173 | if (dpacl) |
177 | _posix_to_nfsv4_one(dpacl, *acl, flags | NFS4_ACL_TYPE_DEFAULT); | 174 | _posix_to_nfsv4_one(dpacl, *acl, flags | NFS4_ACL_TYPE_DEFAULT); |