diff mbox series

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

Message ID 20220211221620.3311195-1-lsahlber@redhat.com (mailing list archive)
State New, archived
Headers show
Series cifs: do not use uninitialized data in the owner/group sid | expand

Commit Message

Ronnie Sahlberg Feb. 11, 2022, 10:16 p.m. UTC
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>
---
 fs/cifs/cifsacl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Steve French Feb. 12, 2022, 6:36 a.m. UTC | #1
tentatively merged into cifs-2.6.git for-next pending testing

On Fri, Feb 11, 2022 at 4:16 PM Ronnie Sahlberg <lsahlber@redhat.com> wrote:
>
> 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>
> ---
>  fs/cifs/cifsacl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
> index ee3aab3dd4ac..5df21d63dd04 100644
> --- a/fs/cifs/cifsacl.c
> +++ b/fs/cifs/cifsacl.c
> @@ -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
>
diff mbox series

Patch

diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index ee3aab3dd4ac..5df21d63dd04 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -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;