Skip to content

Commit 09bdc2d

Browse files
author
J. Bruce Fields
committed
nfsd4: fix acl buffer overrun
4ac7249 "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>
1 parent b28a960 commit 09bdc2d

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

fs/nfsd/nfs4acl.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,15 @@ nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry,
151151
pacl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
152152
if (IS_ERR(pacl))
153153
return PTR_ERR(pacl);
154-
/* allocate for worst case: one (deny, allow) pair each: */
155-
size += 2 * pacl->a_count;
156154
}
155+
/* allocate for worst case: one (deny, allow) pair each: */
156+
size += 2 * pacl->a_count;
157157

158158
if (S_ISDIR(inode->i_mode)) {
159159
flags = NFS4_ACL_DIR;
160160
dpacl = get_acl(inode, ACL_TYPE_DEFAULT);
161161
if (dpacl)
162162
size += 2 * dpacl->a_count;
163-
} else {
164-
dpacl = NULL;
165163
}
166164

167165
*acl = nfs4_acl_new(size);
@@ -170,8 +168,7 @@ nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry,
170168
goto out;
171169
}
172170

173-
if (pacl)
174-
_posix_to_nfsv4_one(pacl, *acl, flags & ~NFS4_ACL_TYPE_DEFAULT);
171+
_posix_to_nfsv4_one(pacl, *acl, flags & ~NFS4_ACL_TYPE_DEFAULT);
175172

176173
if (dpacl)
177174
_posix_to_nfsv4_one(dpacl, *acl, flags | NFS4_ACL_TYPE_DEFAULT);

0 commit comments

Comments
 (0)