linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][SMB3 client] minor coverity fix for unitialized MBZ ACL fields
@ 2022-10-14 23:57 Steve French
       [not found] ` <CAH2r5mvSNk7WiuvWJ6ZbHvb0F3ze8p=amp0h_BOCy_7S=nhx1w@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Steve French @ 2022-10-14 23:57 UTC (permalink / raw)
  To: CIFS; +Cc: Paulo Alcantara

[-- Attachment #1: Type: text/plain, Size: 238 bytes --]

smb3: must initialize two ACL struct fields to zero

Coverity spotted that we were not initalizing Stbz1 and Stbz2 to
zero in create_sd_buf.

Addresses-Coverity: 1513848 ("Uninitialized scalar variable")

See attached

-- 
Thanks,

Steve

[-- Attachment #2: 0001-smb3-must-initialize-two-ACL-struct-fields-to-zero.patch --]
[-- Type: text/x-patch, Size: 1485 bytes --]

From 4944fc48ad344d76263b9b4394ce0d474b7f5de1 Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Fri, 14 Oct 2022 18:50:20 -0500
Subject: [PATCH] smb3: must initialize two ACL struct fields to zero

Coverity spotted that we were not initalizing Stbz1 and Stbz2 to
zero in create_sd_buf.

Addresses-Coverity: 1513848 ("Uninitialized scalar variable")
Cc: <stable@vger.kernel.org>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/smb2pdu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index e1162217ad1a..f8f89ff96c5d 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -2420,7 +2420,7 @@ create_sd_buf(umode_t mode, bool set_owner, unsigned int *len)
 	unsigned int acelen, acl_size, ace_count;
 	unsigned int owner_offset = 0;
 	unsigned int group_offset = 0;
-	struct smb3_acl acl;
+	struct smb3_acl acl = {};
 
 	*len = round_up(sizeof(struct crt_sd_ctxt) + (sizeof(struct cifs_ace) * 4), 8);
 
@@ -2493,6 +2493,7 @@ create_sd_buf(umode_t mode, bool set_owner, unsigned int *len)
 	acl.AclRevision = ACL_REVISION; /* See 2.4.4.1 of MS-DTYP */
 	acl.AclSize = cpu_to_le16(acl_size);
 	acl.AceCount = cpu_to_le16(ace_count);
+	/* acl.Sbz1 and Sbz2 MBZ so are not set here, but initialized above */
 	memcpy(aclptr, &acl, sizeof(struct smb3_acl));
 
 	buf->ccontext.DataLength = cpu_to_le32(ptr - (__u8 *)&buf->sd);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Fwd: [PATCH][SMB3 client] minor coverity fix for unitialized MBZ ACL fields
       [not found] ` <CAH2r5mvSNk7WiuvWJ6ZbHvb0F3ze8p=amp0h_BOCy_7S=nhx1w@mail.gmail.com>
@ 2022-10-15  0:26   ` Steve French
  2022-10-15  1:10     ` Steve French
  0 siblings, 1 reply; 3+ messages in thread
From: Steve French @ 2022-10-15  0:26 UTC (permalink / raw)
  To: CIFS

[-- Attachment #1: Type: text/plain, Size: 996 bytes --]

---------- Forwarded message ---------
From: Steve French <smfrench@gmail.com>
Date: Fri, Oct 14, 2022 at 7:25 PM
Subject: Re: [PATCH][SMB3 client] minor coverity fix for unitialized
MBZ ACL fields
To: CIFS <linux-cifs@vger.kernel.org>
Cc: Paulo Alcantara <pc@cjr.nz>


And one more similar one (although probably more minor)

    cifs: lease key is uninitialized in smb1 paths

    It is cleaner to set lease key to zero in the places where leases are not
    supported (smb1 can not return lease keys so the field was uninitialized).

    Addresses-Coverity: 1513994 ("Uninitialized scalar variable")

See attached.


On Fri, Oct 14, 2022 at 6:57 PM Steve French <smfrench@gmail.com> wrote:
>
> smb3: must initialize two ACL struct fields to zero
>
> Coverity spotted that we were not initalizing Stbz1 and Stbz2 to
> zero in create_sd_buf.
>
> Addresses-Coverity: 1513848 ("Uninitialized scalar variable")
>
> See attached
>
> --
> Thanks,
>
> Steve



-- 
Thanks,

Steve


-- 
Thanks,

Steve

[-- Attachment #2: 0001-cifs-lease-key-is-uninitialized-in-smb1-paths.patch --]
[-- Type: application/x-patch, Size: 1044 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][SMB3 client] minor coverity fix for unitialized MBZ ACL fields
  2022-10-15  0:26   ` Fwd: " Steve French
@ 2022-10-15  1:10     ` Steve French
  0 siblings, 0 replies; 3+ messages in thread
From: Steve French @ 2022-10-15  1:10 UTC (permalink / raw)
  To: CIFS; +Cc: Paulo Alcantara

[-- Attachment #1: Type: text/plain, Size: 1295 bytes --]

Add another two places that coverity pointed out (in cifs_open and
_cifsFileInfo_put) with similar issue. trivial fix.


On Fri, Oct 14, 2022 at 7:26 PM Steve French <smfrench@gmail.com> wrote:
>
> ---------- Forwarded message ---------
> From: Steve French <smfrench@gmail.com>
> Date: Fri, Oct 14, 2022 at 7:25 PM
> Subject: Re: [PATCH][SMB3 client] minor coverity fix for unitialized
> MBZ ACL fields
> To: CIFS <linux-cifs@vger.kernel.org>
> Cc: Paulo Alcantara <pc@cjr.nz>
>
>
> And one more similar one (although probably more minor)
>
>     cifs: lease key is uninitialized in smb1 paths
>
>     It is cleaner to set lease key to zero in the places where leases are not
>     supported (smb1 can not return lease keys so the field was uninitialized).
>
>     Addresses-Coverity: 1513994 ("Uninitialized scalar variable")
>
> See attached.
>
>
> On Fri, Oct 14, 2022 at 6:57 PM Steve French <smfrench@gmail.com> wrote:
> >
> > smb3: must initialize two ACL struct fields to zero
> >
> > Coverity spotted that we were not initalizing Stbz1 and Stbz2 to
> > zero in create_sd_buf.
> >
> > Addresses-Coverity: 1513848 ("Uninitialized scalar variable")
> >
> > See attached
> >
> > --
> > Thanks,
> >
> > Steve
>
>
>
> --
> Thanks,
>
> Steve
>
>
> --
> Thanks,
>
> Steve



-- 
Thanks,

Steve

[-- Attachment #2: 0001-cifs-lease-key-is-uninitialized-in-two-additional-fu.patch --]
[-- Type: text/x-patch, Size: 1522 bytes --]

From 65d51ce29a854c9091649c8e0076d007f269309d Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Fri, 14 Oct 2022 20:00:32 -0500
Subject: [PATCH] cifs: lease key is uninitialized in two additional functions
 when smb1

cifs_open and _cifsFileInfo_put also end up with lease_key uninitialized
in smb1 mounts.  It is cleaner to set lease key to zero in these
places where leases are not supported (smb1 can not return lease keys
so the field was uninitialized).

Addresses-Coverity: 1514207 ("Uninitialized scalar variable")
Addresses-Coverity: 1514331 ("Uninitialized scalar variable")
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index dcec1690312b..f6ffee514c34 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -489,7 +489,7 @@ void _cifsFileInfo_put(struct cifsFileInfo *cifs_file,
 	struct cifsInodeInfo *cifsi = CIFS_I(inode);
 	struct super_block *sb = inode->i_sb;
 	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
-	struct cifs_fid fid;
+	struct cifs_fid fid = {};
 	struct cifs_pending_open open;
 	bool oplock_break_cancelled;
 
@@ -571,7 +571,7 @@ int cifs_open(struct inode *inode, struct file *file)
 	void *page;
 	const char *full_path;
 	bool posix_open_ok = false;
-	struct cifs_fid fid;
+	struct cifs_fid fid = {};
 	struct cifs_pending_open open;
 	struct cifs_open_info_data data = {};
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-15  1:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-14 23:57 [PATCH][SMB3 client] minor coverity fix for unitialized MBZ ACL fields Steve French
     [not found] ` <CAH2r5mvSNk7WiuvWJ6ZbHvb0F3ze8p=amp0h_BOCy_7S=nhx1w@mail.gmail.com>
2022-10-15  0:26   ` Fwd: " Steve French
2022-10-15  1:10     ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).