linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
To: linux-cifs@vger.kernel.org, zhangxiaoxu5@huawei.com,
	sfrench@samba.org, pc@cjr.nz, lsahlber@redhat.com,
	sprasad@microsoft.com, rohiths@microsoft.com, smfrench@gmail.com,
	tom@talpey.com, linkinjeon@kernel.org, hyc.lee@gmail.com
Subject: [PATCH v5 1/5] cifs: Fix the error length of VALIDATE_NEGOTIATE_INFO message
Date: Tue, 13 Sep 2022 18:40:55 +0800	[thread overview]
Message-ID: <20220913104059.2545304-2-zhangxiaoxu5@huawei.com> (raw)
In-Reply-To: <20220913104059.2545304-1-zhangxiaoxu5@huawei.com>

Commit d5c7076b772a ("smb3: add smb3.1.1 to default dialect list")
extend the dialects from 3 to 4, but forget to decrease the extended
length when specific the dialect, then the message length is larger
than expected.

This maybe leak some info through network because not initialize the
message body.

After apply this patch, the VALIDATE_NEGOTIATE_INFO message length is
reduced from 28 bytes to 26 bytes.

Fixes: d5c7076b772a ("smb3: add smb3.1.1 to default dialect list")
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Cc: <stable@vger.kernel.org>
Reviewed-by: Tom Talpey <tom@talpey.com>
---
 fs/cifs/smb2pdu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 6352ab32c7e7..223056097b54 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -1169,9 +1169,9 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
 		pneg_inbuf->Dialects[0] =
 			cpu_to_le16(server->vals->protocol_id);
 		pneg_inbuf->DialectCount = cpu_to_le16(1);
-		/* structure is big enough for 3 dialects, sending only 1 */
+		/* structure is big enough for 4 dialects, sending only 1 */
 		inbuflen = sizeof(*pneg_inbuf) -
-				sizeof(pneg_inbuf->Dialects[0]) * 2;
+				sizeof(pneg_inbuf->Dialects[0]) * 3;
 	}
 
 	rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
-- 
2.31.1


  reply	other threads:[~2022-09-13  9:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13 10:40 [PATCH v5 0/5] Fix some bug in FSCTL_VALIDATE_NEGOTIATE_INFO handler Zhang Xiaoxu
2022-09-13 10:40 ` Zhang Xiaoxu [this message]
2022-09-13 10:40 ` [PATCH v5 2/5] ksmbd: Fix wrong return value in smb2_ioctl() Zhang Xiaoxu
2022-09-13 10:40 ` [PATCH v5 3/5] ksmbd: Fix FSCTL_VALIDATE_NEGOTIATE_INFO message length check " Zhang Xiaoxu
2022-09-13 10:40 ` [PATCH v5 4/5] cifs: Add neg dialects info to smb version values Zhang Xiaoxu
2022-09-13 10:40 ` [PATCH v5 5/5] cifs: Refactor dialects in validate_negotiate_info_req to variable array Zhang Xiaoxu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220913104059.2545304-2-zhangxiaoxu5@huawei.com \
    --to=zhangxiaoxu5@huawei.com \
    --cc=hyc.lee@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=lsahlber@redhat.com \
    --cc=pc@cjr.nz \
    --cc=rohiths@microsoft.com \
    --cc=sfrench@samba.org \
    --cc=smfrench@gmail.com \
    --cc=sprasad@microsoft.com \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).