public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5.4] cifs/smb3: Fix NULL pointer dereference in smb2_query_info_compound()
@ 2023-04-05 11:42 Pratyush Yadav
  2023-04-05 11:44 ` kernel test robot
  0 siblings, 1 reply; 10+ messages in thread
From: Pratyush Yadav @ 2023-04-05 11:42 UTC (permalink / raw)
  To: stable
  Cc: Pratyush Yadav, Greg Kroah-Hartman, patches, Amir Goldstein,
	Steve French, Sasha Levin

smb2_queryfs() calls smb2_query_info_compound() with cifs_sb set to
NULL. It is then dereferenced by cifs_create_options(). Commit
a6e44cb21534d ("SMB3: Backup intent flag missing from some more ops")
removed the NULL check before dereferencing cifs_sb. Add it back.

This bug was discovered and resolved using Coverity Static Analysis
Security Testing (SAST) by Synopsys, Inc.

Fixes: a6e44cb21534d ("SMB3: Backup intent flag missing from some more ops")
Signed-off-by: Pratyush Yadav <ptyadav@amazon.de>
---

Only compile-tested. I do not know this code very well. This was pointed
out by our static code analysis tool.

 fs/cifs/smb2ops.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 4cb0ebe7330eb..04256edaa4f73 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -2272,7 +2272,10 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon,
 	oparms.tcon = tcon;
 	oparms.desired_access = desired_access;
 	oparms.disposition = FILE_OPEN;
-	oparms.create_options = cifs_create_options(cifs_sb, 0);
+	if (cifs_sb)
+		oparms.create_options = cifs_create_options(cifs_sb, 0);
+	else
+		oparms.create_options = 0;
 	oparms.fid = &fid;
 	oparms.reconnect = false;

--
2.39.2


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

end of thread, other threads:[~2023-04-13  5:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-05 11:42 [PATCH 5.4] cifs/smb3: Fix NULL pointer dereference in smb2_query_info_compound() Pratyush Yadav
2023-04-05 11:44 ` kernel test robot
2023-04-05 11:47   ` Pratyush Yadav
2023-04-05 12:26     ` Greg KH
2023-04-05 12:26       ` Greg KH
2023-04-05 13:33         ` Pratyush Yadav
2023-04-05 14:22           ` Greg KH
2023-04-12  7:47             ` Yujie Liu
2023-04-12 13:21               ` Pratyush Yadav
2023-04-13  5:49                 ` Yujie Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox