Skip to content

Commit

Permalink
ksmbd: fix posix_acls and acls dereferencing possible ERR_PTR()
Browse files Browse the repository at this point in the history
[ Upstream commit 2593357 ]

Dan reported the following error message:

fs/smb/server/smbacl.c:1296 smb_check_perm_dacl()
    error: 'posix_acls' dereferencing possible ERR_PTR()
fs/smb/server/vfs.c:1323 ksmbd_vfs_make_xattr_posix_acl()
    error: 'posix_acls' dereferencing possible ERR_PTR()
fs/smb/server/vfs.c:1830 ksmbd_vfs_inherit_posix_acl()
    error: 'acls' dereferencing possible ERR_PTR()

__get_acl() returns a mix of error pointers and NULL. This change it
with IS_ERR_OR_NULL().

Fixes: e2f3448 ("cifsd: add server-side procedures for SMB3")
Cc: stable@vger.kernel.org
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
namjaejeon authored and gregkh committed Jan 5, 2024
1 parent 1524884 commit 13a5045
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions fs/smb/server/smbacl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,

if (IS_ENABLED(CONFIG_FS_POSIX_ACL)) {
posix_acls = get_acl(d_inode(path->dentry), ACL_TYPE_ACCESS);
if (posix_acls && !found) {
if (!IS_ERR_OR_NULL(posix_acls) && !found) {
unsigned int id = -1;

pa_entry = posix_acls->a_entries;
Expand All @@ -1337,7 +1337,7 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
}
}
}
if (posix_acls)
if (!IS_ERR_OR_NULL(posix_acls))
posix_acl_release(posix_acls);
}

Expand Down
4 changes: 2 additions & 2 deletions fs/smb/server/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(struct user_namespac
return NULL;

posix_acls = get_acl(inode, acl_type);
if (!posix_acls)
if (IS_ERR_OR_NULL(posix_acls))
return NULL;

smb_acl = kzalloc(sizeof(struct xattr_smb_acl) +
Expand Down Expand Up @@ -1830,7 +1830,7 @@ int ksmbd_vfs_inherit_posix_acl(struct user_namespace *user_ns,
return -EOPNOTSUPP;

acls = get_acl(parent_inode, ACL_TYPE_DEFAULT);
if (!acls)
if (IS_ERR_OR_NULL(acls))
return -ENOENT;
pace = acls->a_entries;

Expand Down

0 comments on commit 13a5045

Please sign in to comment.