Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org>
To: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org>
Subject: [PATCH] CIFS: do not send invalid input buffer on QUERY_INFO requests
Date: Tue, 17 Oct 2017 14:47:17 +0200	[thread overview]
Message-ID: <20171017124717.25955-1-aaptel@suse.com> (raw)
In-Reply-To: <mpsa80ruowd.fsf-zpEvHKhluMwYitT5tn2FcQ@public.gmane.org>

query_info() doesn't use the InputBuffer field of the QUERY_INFO
request, therefore according to [MS-SMB2] it must:

a) set the InputBufferOffset to 0
b) send a zero-length InputBuffer

Doing a) is trivial but b) is a bit more tricky.

The packet is allocated according to it's StructureSize, which takes
into account an extra 1 byte buffer which we don't need
here. StructureSize fields must have constant values no matter the
actual length of the whole packet so we can't just edit that constant.

Both the NetBIOS-over-TCP message length ("rfc1002 length") L and the
iovec length L' have to be updated. Since L' is computed from L we
just update L by decrementing it by one.

Signed-off-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org>
---
 fs/cifs/smb2pdu.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 6f0e6343c15e..b927e131f997 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -2191,9 +2191,13 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
 	req->PersistentFileId = persistent_fid;
 	req->VolatileFileId = volatile_fid;
 	req->AdditionalInformation = cpu_to_le32(additional_info);
-	/* 4 for rfc1002 length field and 1 for Buffer */
-	req->InputBufferOffset =
-		cpu_to_le16(sizeof(struct smb2_query_info_req) - 1 - 4);
+
+	/*
+	 * We do not use the input buffer (do not send extra byte)
+	 */
+	req->InputBufferOffset = 0;
+	inc_rfc1001_len(req, -1);
+
 	req->OutputBufferLength = cpu_to_le32(output_len);
 
 	iov[0].iov_base = (char *)req;
-- 
2.12.3

  parent reply	other threads:[~2017-10-17 12:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-16  7:59 Share mounts in SMBv1 mode, but fails to mount in SMBv2 mode Hadrien Grasland
     [not found] ` <144390dd-e0fc-ae98-a645-5972f11d635d-dJj/bURytuEtnUBFBimtzg@public.gmane.org>
2017-10-16 10:11   ` Aurélien Aptel
     [not found]     ` <mpsd15nv1up.fsf-zpEvHKhluMwYitT5tn2FcQ@public.gmane.org>
2017-10-16 11:35       ` Hadrien Grasland
     [not found]         ` <0b17f092-5c81-3b2e-5e48-b2a4c5b4145a-dJj/bURytuEtnUBFBimtzg@public.gmane.org>
2017-10-16 14:51           ` Aurélien Aptel
     [not found]             ` <mpsa80ruowd.fsf-zpEvHKhluMwYitT5tn2FcQ@public.gmane.org>
2017-10-16 16:05               ` Hadrien Grasland
     [not found]                 ` <9e6bb290-6375-2dfe-8d5b-2128fcc9538d-dJj/bURytuEtnUBFBimtzg@public.gmane.org>
2017-10-16 16:37                   ` Steve French
     [not found]                     ` <CAH2r5mt+pRqKa+drXNUEZwhK4bJBH9AYyu048QpSkBnqd_XXgw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-10-17  9:28                       ` Aurélien Aptel
2017-10-17  9:44                   ` Aurélien Aptel
2017-10-17 12:47               ` Aurelien Aptel [this message]
     [not found]                 ` <20171017124717.25955-1-aaptel-IBi9RG/b67k@public.gmane.org>
2017-10-17 13:41                   ` [PATCH] CIFS: do not send invalid input buffer on QUERY_INFO requests Hadrien Grasland
     [not found]                     ` <f87e7391-b2f0-feaf-3489-686d0368fe64-dJj/bURytuEtnUBFBimtzg@public.gmane.org>
2017-10-18 14:50                       ` Aurélien Aptel
     [not found]                         ` <mpspo9ktsr5.fsf-zpEvHKhluMwYitT5tn2FcQ@public.gmane.org>
2017-10-18 20:20                           ` Hadrien Grasland
2017-10-18 16:53                   ` Steve French
2017-11-21  1:10                   ` Pavel Shilovsky

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=20171017124717.25955-1-aaptel@suse.com \
    --to=aaptel-ibi9rg/b67k@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /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