Commit 49398b8c authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] nfsd: make sure getxattr inode op is non-NULL before calling it

Make sure getxattr inode op is non-NULL before calling it.

Also, security hook should probably be called before calling the getxattr op
the first time.
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: default avatarNeil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 1bf63d07
...@@ -448,6 +448,16 @@ _get_posix_acl(struct dentry *dentry, char *key) ...@@ -448,6 +448,16 @@ _get_posix_acl(struct dentry *dentry, char *key)
int buflen, error = 0; int buflen, error = 0;
struct posix_acl *pacl = NULL; struct posix_acl *pacl = NULL;
error = -EOPNOTSUPP;
if (inode->i_op == NULL)
goto out_err;
if (inode->i_op->getxattr == NULL)
goto out_err;
error = security_inode_getxattr(dentry, key);
if (error)
goto out_err;
buflen = inode->i_op->getxattr(dentry, key, NULL, 0); buflen = inode->i_op->getxattr(dentry, key, NULL, 0);
if (buflen <= 0) { if (buflen <= 0) {
error = buflen < 0 ? buflen : -ENODATA; error = buflen < 0 ? buflen : -ENODATA;
...@@ -460,18 +470,10 @@ _get_posix_acl(struct dentry *dentry, char *key) ...@@ -460,18 +470,10 @@ _get_posix_acl(struct dentry *dentry, char *key)
goto out_err; goto out_err;
} }
error = -EOPNOTSUPP;
if (inode->i_op && inode->i_op->getxattr) {
error = security_inode_getxattr(dentry, key);
if (error)
goto out_err;
error = inode->i_op->getxattr(dentry, key, buf, buflen); error = inode->i_op->getxattr(dentry, key, buf, buflen);
}
if (error < 0) if (error < 0)
goto out_err; goto out_err;
error = 0;
pacl = posix_acl_from_xattr(buf, buflen); pacl = posix_acl_from_xattr(buf, buflen);
out: out:
kfree(buf); kfree(buf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment