]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
cifs: do not use uninitialized data in the owner/group sid
authorRonnie Sahlberg <lsahlber@redhat.com>
Fri, 11 Feb 2022 22:16:20 +0000 (08:16 +1000)
committerPaolo Pisati <paolo.pisati@canonical.com>
Wed, 9 Mar 2022 14:16:01 +0000 (15:16 +0100)
BugLink: https://bugs.launchpad.net/bugs/1964361
[ Upstream commit 26d3dadebbcbddfaf1d9caad42527a28a0ed28d8 ]

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.

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
fs/cifs/cifsacl.c

index ee3aab3dd4ac6f2f748b6c58e47dc423b4edb2f3..5df21d63dd04e8289ca6c329fff79840d16b71bd 100644 (file)
@@ -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;