stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 5.4] smb3: fix problem with null cifs super block with previous patch
@ 2023-04-05 13:57 Pratyush Yadav
  2023-04-05 14:20 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Pratyush Yadav @ 2023-04-05 13:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Steve French, Amir Goldstein, Aurelien Aptel, Pratyush Yadav,
	stable, patches, Sasha Levin

From: Steve French <stfrench@microsoft.com>

[ Upstream commit 87f93d82e0952da18af4d978e7d887b4c5326c0b ]

Add check for null cifs_sb to create_options helper

Signed-off-by: Steve French <stfrench@microsoft.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Pratyush Yadav <ptyadav@amazon.de>
---

Only compile-tested. This was discovered by our static code analysis
tool. I do not use CIFS and do not know how to actually reproduce the
NULL dereference.

Follow up from [0]. Original patch is at [1].

Mandatory text due to licensing terms:

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

[0] https://lore.kernel.org/stable/20230405114220.108739-1-ptyadav@amazon.de/T/#u
[1] https://lore.kernel.org/all/CAH2r5mtu69KEWU94qZK32H_8cvyhVU8GyOKrZqbdjH0ZLd95Zg@mail.gmail.com/

 fs/cifs/cifsproto.h | 2 +-
 fs/cifs/smb2ops.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index a5fab9afd699f..2dde83a969680 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -602,7 +602,7 @@ static inline int get_dfs_path(const unsigned int xid, struct cifs_ses *ses,

 static inline int cifs_create_options(struct cifs_sb_info *cifs_sb, int options)
 {
-	if (backup_cred(cifs_sb))
+	if (cifs_sb && (backup_cred(cifs_sb)))
 		return options | CREATE_OPEN_BACKUP_INTENT;
 	else
 		return options;
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 4cb0ebe7330eb..44a261b9850de 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -2343,7 +2343,7 @@ smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
 				      FS_FULL_SIZE_INFORMATION,
 				      SMB2_O_INFO_FILESYSTEM,
 				      sizeof(struct smb2_fs_full_size_info),
-				      &rsp_iov, &buftype, NULL);
+				      &rsp_iov, &buftype, cifs_sb);
 	if (rc)
 		goto qfs_exit;

--
2.39.2


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

end of thread, other threads:[~2023-04-06  8:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-05 13:57 [PATCH 5.4] smb3: fix problem with null cifs super block with previous patch Pratyush Yadav
2023-04-05 14:20 ` Greg Kroah-Hartman
2023-04-05 14:34   ` Pratyush Yadav
2023-04-05 17:04     ` Greg Kroah-Hartman
2023-04-06  8:48       ` Pratyush Yadav

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).