All of lore.kernel.org
 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
Subject: [PATCH v2 1/3] cifs: Fix the error length of VALIDATE_NEGOTIATE_INFO message
Date: Wed, 31 Aug 2022 15:52:53 +0800	[thread overview]
Message-ID: <20220831075255.2667077-2-zhangxiaoxu5@huawei.com> (raw)
In-Reply-To: <20220831075255.2667077-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>
---
 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 128e44e57528..37f422eb3876 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -1167,9 +1167,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-08-31  6:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-31  7:52 [PATCH v2 0/3] Fix some bug in FSCTL_VALIDATE_NEGOTIATE_INFO handler Zhang Xiaoxu
2022-08-31  7:52 ` Zhang Xiaoxu [this message]
2022-08-31  7:52 ` [PATCH v2 2/3] ksmbd: Remove the wrong message length check of FSCTL_VALIDATE_NEGOTIATE_INFO Zhang Xiaoxu
2022-08-31  7:52 ` [PATCH v2 3/3] ksmbd: Fix wrong return value in smb2_ioctl() when wrong out_buf_len Zhang Xiaoxu
2022-08-31 14:50 ` [PATCH v2 0/3] Fix some bug in FSCTL_VALIDATE_NEGOTIATE_INFO handler Tom Talpey
2022-09-01  3:23   ` zhangxiaoxu (A)

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=20220831075255.2667077-2-zhangxiaoxu5@huawei.com \
    --to=zhangxiaoxu5@huawei.com \
    --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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.