From: Christian Brauner Date: Fri, 28 Oct 2022 10:45:10 +0000 (+0200) Subject: cifs: check whether acl is valid early X-Git-Tag: v6.6.17~5991^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb2144d66b0b24fd1b880fc72678ba21ca414dab;p=platform%2Fkernel%2Flinux-rpi.git 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: dc1af4c4b472 ("cifs: implement set acl method") Reported-by: Dan Carpenter Signed-off-by: Christian Brauner (Microsoft) --- diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 6a9f03c..c647f0d 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c @@ -1764,6 +1764,10 @@ int cifs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry, rc = PTR_ERR(full_path); goto out; } + + if (!acl) + goto out; + /* return dos attributes as pseudo xattr */ /* return alt name if available as pseudo attr */ @@ -1778,8 +1782,6 @@ int cifs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry, switch (type) { case ACL_TYPE_ACCESS: - if (!acl) - goto out; if (sb->s_flags & SB_POSIXACL) rc = cifs_do_set_acl(xid, pTcon, full_path, acl, ACL_TYPE_ACCESS, @@ -1788,8 +1790,6 @@ int cifs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry, break; case ACL_TYPE_DEFAULT: - if (!acl) - goto out; if (sb->s_flags & SB_POSIXACL) rc = cifs_do_set_acl(xid, pTcon, full_path, acl, ACL_TYPE_DEFAULT,