Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH 1/2] smb: client: fix potential OOB in cifs_dump_detail()
@ 2023-12-16  4:10 Paulo Alcantara
  2023-12-16  4:10 ` [PATCH 2/2] smb: client: fix potential OOB in smb2_dump_detail() Paulo Alcantara
  0 siblings, 1 reply; 5+ messages in thread
From: Paulo Alcantara @ 2023-12-16  4:10 UTC (permalink / raw)
  To: smfrench; +Cc: linux-cifs, Paulo Alcantara

Validate SMB message with ->check_message() before calling
->calc_smb_size().

Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
---
 fs/smb/client/cifs_debug.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/fs/smb/client/cifs_debug.c b/fs/smb/client/cifs_debug.c
index 5596c9f30ccb..60027f5aebe8 100644
--- a/fs/smb/client/cifs_debug.c
+++ b/fs/smb/client/cifs_debug.c
@@ -40,11 +40,13 @@ void cifs_dump_detail(void *buf, struct TCP_Server_Info *server)
 #ifdef CONFIG_CIFS_DEBUG2
 	struct smb_hdr *smb = buf;
 
-	cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d\n",
-		 smb->Command, smb->Status.CifsError,
-		 smb->Flags, smb->Flags2, smb->Mid, smb->Pid);
-	cifs_dbg(VFS, "smb buf %p len %u\n", smb,
-		 server->ops->calc_smb_size(smb));
+	cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d Wct: %d\n",
+		 smb->Command, smb->Status.CifsError, smb->Flags,
+		 smb->Flags2, smb->Mid, smb->Pid, smb->WordCount);
+	if (!server->ops->check_message(buf, server->total_read, server)) {
+		cifs_dbg(VFS, "smb buf %p len %u\n", smb,
+			 server->ops->calc_smb_size(smb));
+	}
 #endif /* CONFIG_CIFS_DEBUG2 */
 }
 
-- 
2.43.0


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

end of thread, other threads:[~2023-12-19 16:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-16  4:10 [PATCH 1/2] smb: client: fix potential OOB in cifs_dump_detail() Paulo Alcantara
2023-12-16  4:10 ` [PATCH 2/2] smb: client: fix potential OOB in smb2_dump_detail() Paulo Alcantara
2023-12-19 14:34   ` Maximilian Heyne
2023-12-19 14:57     ` Paulo Alcantara
2023-12-19 16:10   ` [PATCH v2] " Paulo Alcantara

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