@@ -942,11 +942,6 @@ int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd,
942
942
le32_to_cpu (pntsd -> gsidoffset ),
943
943
le32_to_cpu (pntsd -> sacloffset ), dacloffset );
944
944
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
-
950
945
pntsd_type = le16_to_cpu (pntsd -> type );
951
946
if (!(pntsd_type & DACL_PRESENT )) {
952
947
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,
956
951
pntsd -> type = cpu_to_le16 (DACL_PRESENT );
957
952
958
953
if (pntsd -> osidoffset ) {
954
+ if (le32_to_cpu (pntsd -> osidoffset ) < sizeof (struct smb_ntsd ))
955
+ return - EINVAL ;
956
+
959
957
rc = parse_sid (owner_sid_ptr , end_of_acl );
960
958
if (rc ) {
961
959
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,
975
973
}
976
974
977
975
if (pntsd -> gsidoffset ) {
976
+ if (le32_to_cpu (pntsd -> gsidoffset ) < sizeof (struct smb_ntsd ))
977
+ return - EINVAL ;
978
+
978
979
rc = parse_sid (group_sid_ptr , end_of_acl );
979
980
if (rc ) {
980
981
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,
1000
1001
pntsd -> type |= cpu_to_le16 (DACL_PROTECTED );
1001
1002
1002
1003
if (dacloffset ) {
1004
+ if (dacloffset < sizeof (struct smb_ntsd ))
1005
+ return - EINVAL ;
1006
+
1003
1007
#if LINUX_VERSION_CODE >= KERNEL_VERSION (6 , 3 , 0 )
1004
1008
parse_dacl (idmap , dacl_ptr , end_of_acl ,
1005
1009
#else
0 commit comments