Skip to content

Commit 2593357

Browse files
namjaejeonSteve French
authored andcommitted
ksmbd: fix posix_acls and acls dereferencing possible ERR_PTR()
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>
1 parent fc6c6a3 commit 2593357

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

fs/smb/server/smbacl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
12901290

12911291
if (IS_ENABLED(CONFIG_FS_POSIX_ACL)) {
12921292
posix_acls = get_inode_acl(d_inode(path->dentry), ACL_TYPE_ACCESS);
1293-
if (posix_acls && !found) {
1293+
if (!IS_ERR_OR_NULL(posix_acls) && !found) {
12941294
unsigned int id = -1;
12951295

12961296
pa_entry = posix_acls->a_entries;
@@ -1314,7 +1314,7 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
13141314
}
13151315
}
13161316
}
1317-
if (posix_acls)
1317+
if (!IS_ERR_OR_NULL(posix_acls))
13181318
posix_acl_release(posix_acls);
13191319
}
13201320

fs/smb/server/vfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(struct mnt_idmap *id
13211321
return NULL;
13221322

13231323
posix_acls = get_inode_acl(inode, acl_type);
1324-
if (!posix_acls)
1324+
if (IS_ERR_OR_NULL(posix_acls))
13251325
return NULL;
13261326

13271327
smb_acl = kzalloc(sizeof(struct xattr_smb_acl) +
@@ -1830,7 +1830,7 @@ int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap,
18301830
return -EOPNOTSUPP;
18311831

18321832
acls = get_inode_acl(parent_inode, ACL_TYPE_DEFAULT);
1833-
if (!acls)
1833+
if (IS_ERR_OR_NULL(acls))
18341834
return -ENOENT;
18351835
pace = acls->a_entries;
18361836

0 commit comments

Comments
 (0)