Skip to contentSkip to conversation

cifs: bound invalid NTLMSSP signature diagnostic

PATCH RESEND Applied Yifan Zhang 2 participants 2 messages Nov 3 – Nov 7

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 cifs: bound invalid NTLMSSP signature diagnostic

The NTLMSSP Signature field is an eight-byte binary value and need not be NUL-terminated. decode_ntlmssp_challenge() prints it with %s on the signature-mismatch path, so the diagnostic can continue beyond the received blob until it encounters a zero byte.

KASAN reports:

  BUG: KASAN: slab-out-of-bounds in string
  Read of size 1
  string
  vsnprintf
  _printk
  decode_ntlmssp_challenge

Print the fixed-width field with the bounded hexadecimal format.

The patched kernel reaches the invalid-signature path and returns -EINVAL without a KASAN report.

Fixes 0b3cc858003b ("[CIFS] NTLMSSP reenabled after move from connect.c to sess.c")
---
 fs/smb/client/sess.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/sess.c +1 -1
index c1fc90726e2d1..00c9c99c6701a 100644
@@ -666,7 +666,7 @@ int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len,
 	}
 
 	if (memcmp(pblob->Signature, "NTLMSSP", 8)) {
-		cifs_dbg(VFS, "blob signature incorrect %s\n",
+		cifs_dbg(VFS, "blob signature incorrect %8phN\n",
 			 pblob->Signature);
 		return -EINVAL;
 	}
Signature · 1 line
2.39.5 (Apple Git-154)
maintainer Applied
#1 lore raw
Quoted 14 lines · Yifan Zhang

The NTLMSSP Signature field is an eight-byte binary value and need not be NUL-terminated. decode_ntlmssp_challenge() prints it with %s on the signature-mismatch path, so the diagnostic can continue beyond the received blob until it encounters a zero byte.

KASAN reports:

  BUG: KASAN: slab-out-of-bounds in string
  Read of size 1
  string
  vsnprintf
  _printk
  decode_ntlmssp_challenge
Quoted 2 lines

Print the fixed-width field with the bounded hexadecimal format.
...

Applied.