Skip to contentSkip to conversation

cifs: do not use uninitialized data in the owner/group sid

PATCH In review Ronnie Sahlberg 2 participants 2 messages Feb 11, 2022 – Feb 12, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: do not use uninitialized data in the owner/group sid

When idsfromsid is used we create a special SID for owner/group. This structure must be initialized or else the first 5 bytes of the Authority field of the SID will contain uninitialized data and thus not be a valid SID.

---
 fs/cifs/cifsacl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/cifs/cifsacl.c +2 -2
index ee3aab3dd4ac..5df21d63dd04 100644
@@ -1297,7 +1297,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
 
 		if (uid_valid(uid)) { /* chown */
 			uid_t id;
-			nowner_sid_ptr = kmalloc(sizeof(struct cifs_sid),
+			nowner_sid_ptr = kzalloc(sizeof(struct cifs_sid),
 								GFP_KERNEL);
 			if (!nowner_sid_ptr) {
 				rc = -ENOMEM;
@@ -1326,7 +1326,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
 		}
 		if (gid_valid(gid)) { /* chgrp */
 			gid_t id;
-			ngroup_sid_ptr = kmalloc(sizeof(struct cifs_sid),
+			ngroup_sid_ptr = kzalloc(sizeof(struct cifs_sid),
 								GFP_KERNEL);
 			if (!ngroup_sid_ptr) {
 				rc = -ENOMEM;
Signature · 1 line
2.30.2
#1 lore raw

tentatively merged into cifs-2.6.git for-next pending testing

Quoted 36 lines · Ronnie Sahlberg

When idsfromsid is used we create a special SID for owner/group. This structure must be initialized or else the first 5 bytes of the Authority field of the SID will contain uninitialized data and thus not be a valid SID.

---
 fs/cifs/cifsacl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/cifs/cifsacl.c +2 -3
index ee3aab3dd4ac..5df21d63dd04 100644
@@ -1297,7 +1297,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
 
                if (uid_valid(uid)) { /* chown */
                        uid_t id;
-                       nowner_sid_ptr = kmalloc(sizeof(struct cifs_sid),
+                       nowner_sid_ptr = kzalloc(sizeof(struct cifs_sid),
                                                                GFP_KERNEL);
                        if (!nowner_sid_ptr) {
                                rc = -ENOMEM;
@@ -1326,7 +1326,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
                }
                if (gid_valid(gid)) { /* chgrp */
                        gid_t id;
-                       ngroup_sid_ptr = kmalloc(sizeof(struct cifs_sid),
+                       ngroup_sid_ptr = kzalloc(sizeof(struct cifs_sid),
                                                                GFP_KERNEL);
                        if (!ngroup_sid_ptr) {
                                rc = -ENOMEM;
--

2.30.2

Signature · 3 lines
Thanks,

Steve