Skip to content

Commit 0d15ae2

Browse files
committedFeb 17, 2025
ksmbd: fix
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 parent 2c38730 commit 0d15ae2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed
 

‎smbacl.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -942,11 +942,6 @@ int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd,
942942
le32_to_cpu(pntsd->gsidoffset),
943943
le32_to_cpu(pntsd->sacloffset), dacloffset);
944944

945-
if (le32_to_cpu(pntsd->osidoffset) < sizeof(struct smb_ntsd) ||
946-
le32_to_cpu(pntsd->gsidoffset) < sizeof(struct smb_ntsd) ||
947-
dacloffset < sizeof(struct smb_ntsd))
948-
return -EINVAL;
949-
950945
pntsd_type = le16_to_cpu(pntsd->type);
951946
if (!(pntsd_type & DACL_PRESENT)) {
952947
ksmbd_debug(SMB, "DACL_PRESENT in DACL type is not set\n");
@@ -956,6 +951,9 @@ int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd,
956951
pntsd->type = cpu_to_le16(DACL_PRESENT);
957952

958953
if (pntsd->osidoffset) {
954+
if (le32_to_cpu(pntsd->osidoffset) < sizeof(struct smb_ntsd))
955+
return -EINVAL;
956+
959957
rc = parse_sid(owner_sid_ptr, end_of_acl);
960958
if (rc) {
961959
pr_err("%s: Error %d parsing Owner SID\n", __func__, rc);
@@ -975,6 +973,9 @@ int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd,
975973
}
976974

977975
if (pntsd->gsidoffset) {
976+
if (le32_to_cpu(pntsd->gsidoffset) < sizeof(struct smb_ntsd))
977+
return -EINVAL;
978+
978979
rc = parse_sid(group_sid_ptr, end_of_acl);
979980
if (rc) {
980981
pr_err("%s: Error %d mapping Owner SID to gid\n",
@@ -1000,6 +1001,9 @@ int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd,
10001001
pntsd->type |= cpu_to_le16(DACL_PROTECTED);
10011002

10021003
if (dacloffset) {
1004+
if (dacloffset < sizeof(struct smb_ntsd))
1005+
return -EINVAL;
1006+
10031007
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
10041008
parse_dacl(idmap, dacl_ptr, end_of_acl,
10051009
#else

0 commit comments

Comments
 (0)