Commit cb2144d6 authored by Christian Brauner's avatar Christian Brauner Committed by Christian Brauner (Microsoft)

cifs: check whether acl is valid early

Dan reported that acl is dereferenced before being checked and this is a
valid problem. Fix it be erroring out early instead of doing it later after
we've already relied on acl to be a valid pointer.

Fixes: dc1af4c4 ("cifs: implement set acl method")
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
parent a351b1f4
...@@ -1764,6 +1764,10 @@ int cifs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry, ...@@ -1764,6 +1764,10 @@ int cifs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
rc = PTR_ERR(full_path); rc = PTR_ERR(full_path);
goto out; goto out;
} }
if (!acl)
goto out;
/* return dos attributes as pseudo xattr */ /* return dos attributes as pseudo xattr */
/* return alt name if available as pseudo attr */ /* return alt name if available as pseudo attr */
...@@ -1778,8 +1782,6 @@ int cifs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry, ...@@ -1778,8 +1782,6 @@ int cifs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
switch (type) { switch (type) {
case ACL_TYPE_ACCESS: case ACL_TYPE_ACCESS:
if (!acl)
goto out;
if (sb->s_flags & SB_POSIXACL) if (sb->s_flags & SB_POSIXACL)
rc = cifs_do_set_acl(xid, pTcon, full_path, acl, rc = cifs_do_set_acl(xid, pTcon, full_path, acl,
ACL_TYPE_ACCESS, ACL_TYPE_ACCESS,
...@@ -1788,8 +1790,6 @@ int cifs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry, ...@@ -1788,8 +1790,6 @@ int cifs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
break; break;
case ACL_TYPE_DEFAULT: case ACL_TYPE_DEFAULT:
if (!acl)
goto out;
if (sb->s_flags & SB_POSIXACL) if (sb->s_flags & SB_POSIXACL)
rc = cifs_do_set_acl(xid, pTcon, full_path, acl, rc = cifs_do_set_acl(xid, pTcon, full_path, acl,
ACL_TYPE_DEFAULT, ACL_TYPE_DEFAULT,
......
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