Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Leif Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-cifs <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Steve French <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req
Date: Thu, 16 Nov 2017 20:44:15 -0500 (EST)	[thread overview]
Message-ID: <1978629070.27950035.1510883055312.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <CAKywueRFOZroCmp9nhr22PGE0R31peFr6j8A2mGVQSEP07bqLQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>



----- Original Message -----
From: "Pavel Shilovsky" <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: "Ronnie Sahlberg" <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: "linux-cifs" <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>, "Steve French" <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Sent: Friday, 17 November, 2017 12:24:59 PM
Subject: Re: [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req

2017-11-08 17:14 GMT-08:00 Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>:
> Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
>  fs/cifs/smb2pdu.c | 26 +++++++++++---------------
>  fs/cifs/smb2pdu.h |  2 +-
>  2 files changed, 12 insertions(+), 16 deletions(-)
>
> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> index 5331631386a2..f5cf9953955c 100644
> --- a/fs/cifs/smb2pdu.c
> +++ b/fs/cifs/smb2pdu.c
> @@ -398,8 +398,8 @@ small_smb2_init(__le16 smb2_command, struct cifs_tcon *tcon,
>  }
>
>  #ifdef CONFIG_CIFS_SMB311
> -/* offset is sizeof smb2_negotiate_req - 4 but rounded up to 8 bytes */
> -#define OFFSET_OF_NEG_CONTEXT 0x68  /* sizeof(struct smb2_negotiate_req) - 4 */
> +/* offset is sizeof smb2_negotiate_req but rounded up to 8 bytes */
> +#define OFFSET_OF_NEG_CONTEXT 0x68  /* sizeof(struct smb2_negotiate_req) */
>
>
>  #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES    cpu_to_le16(1)
> @@ -429,9 +429,7 @@ build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt)
>  static void
>  assemble_neg_contexts(struct smb2_negotiate_req *req)
>  {
> -
> -       /* +4 is to account for the RFC1001 len field */
> -       char *pneg_ctxt = (char *)req + OFFSET_OF_NEG_CONTEXT + 4;
> +       char *pneg_ctxt = (char *)req + OFFSET_OF_NEG_CONTEXT;
>
>         build_preauth_ctxt((struct smb2_preauth_neg_context *)pneg_ctxt);
>         /* Add 2 to size to round to 8 byte boundary */
> @@ -439,8 +437,6 @@ assemble_neg_contexts(struct smb2_negotiate_req *req)
>         build_encrypt_ctxt((struct smb2_encryption_neg_context *)pneg_ctxt);
>         req->NegotiateContextOffset = cpu_to_le32(OFFSET_OF_NEG_CONTEXT);
>         req->NegotiateContextCount = cpu_to_le16(2);
> -       inc_rfc1001_len(req, 4 + sizeof(struct smb2_preauth_neg_context)
> -                       + sizeof(struct smb2_encryption_neg_context)); /* calculate hash */

> Why do we need to remove this?

Because req no longer contains a rfc1002 length field any more.

We now compute the rfc1002 length during smb2_send_recv() and thus we don't need to
modify it using inc_rfc1001_len() any more.


>  }
>  #else
>  static void assemble_neg_contexts(struct smb2_negotiate_req *req)
> @@ -477,6 +473,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
>         int blob_offset, blob_length;
>         char *security_blob;
>         int flags = CIFS_NEG_OP;
> +       unsigned int total_len;
>
>         cifs_dbg(FYI, "Negotiate protocol\n");
>
> @@ -485,30 +482,30 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
>                 return -EIO;
>         }
>
> -       rc = small_smb2_init(SMB2_NEGOTIATE, NULL, (void **) &req);
> +       rc = smb2_plain_req_init(SMB2_NEGOTIATE, NULL, (void **) &req, &total_len);
>         if (rc)
>                 return rc;
>
> -       req->hdr.sync_hdr.SessionId = 0;
> +       req->sync_hdr.SessionId = 0;
>
>         if (strcmp(ses->server->vals->version_string,
>                    SMB3ANY_VERSION_STRING) == 0) {
>                 req->Dialects[0] = cpu_to_le16(SMB30_PROT_ID);
>                 req->Dialects[1] = cpu_to_le16(SMB302_PROT_ID);
>                 req->DialectCount = cpu_to_le16(2);
> -               inc_rfc1001_len(req, 4);
> +               total_len += 4;
>         } else if (strcmp(ses->server->vals->version_string,
>                    SMBDEFAULT_VERSION_STRING) == 0) {
>                 req->Dialects[0] = cpu_to_le16(SMB21_PROT_ID);
>                 req->Dialects[1] = cpu_to_le16(SMB30_PROT_ID);
>                 req->Dialects[2] = cpu_to_le16(SMB302_PROT_ID);
>                 req->DialectCount = cpu_to_le16(3);
> -               inc_rfc1001_len(req, 6);
> +               total_len += 6;
>         } else {
>                 /* otherwise send specific dialect */
>                 req->Dialects[0] = cpu_to_le16(ses->server->vals->protocol_id);
>                 req->DialectCount = cpu_to_le16(1);
> -               inc_rfc1001_len(req, 2);
> +               total_len += 2;
>         }
>
>         /* only one of SMB2 signing flags may be set in SMB2 request */
> @@ -531,10 +528,9 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
>                         assemble_neg_contexts(req);
>         }
>         iov[0].iov_base = (char *)req;
> -       /* 4 for rfc1002 length field */
> -       iov[0].iov_len = get_rfc1002_length(req) + 4;
> +       iov[0].iov_len = total_len;
>
> -       rc = SendReceive2(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov);
> +       rc = smb2_send_recv(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov);
>         cifs_small_buf_release(req);
>         rsp = (struct smb2_negotiate_rsp *)rsp_iov.iov_base;
>         /*
> diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h
> index c2ec934be968..0fe2382597ad 100644
> --- a/fs/cifs/smb2pdu.h
> +++ b/fs/cifs/smb2pdu.h
> @@ -195,7 +195,7 @@ struct smb2_symlink_err_rsp {
>  #define SMB2_CLIENT_GUID_SIZE 16
>
>  struct smb2_negotiate_req {
> -       struct smb2_hdr hdr;
> +       struct smb2_sync_hdr sync_hdr;
>         __le16 StructureSize; /* Must be 36 */
>         __le16 DialectCount;
>         __le16 SecurityMode;
> --
> 2.13.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-11-17  1:44 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-09  1:14 [PATCH 00/19] Remove rfc1002 header from smb2 request structs Ronnie Sahlberg
     [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09  1:14   ` [PATCH 01/19] cifs: Add smb2_send_recv Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-2-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:09       ` Aurélien Aptel
2017-11-17 18:05       ` Steve French
     [not found]         ` <CAH2r5mvLvAfO3eU2f73ebk2XSJiQvzamWi9FxDqNCU67=Pm8bQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-17 18:11           ` Steve French
2017-11-09  1:14   ` [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-3-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:10       ` Aurélien Aptel
2017-11-17  1:24       ` Pavel Shilovsky
     [not found]         ` <CAKywueRFOZroCmp9nhr22PGE0R31peFr6j8A2mGVQSEP07bqLQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-17  1:44           ` Leif Sahlberg [this message]
     [not found]             ` <1978629070.27950035.1510883055312.JavaMail.zimbra-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-17  1:47               ` Pavel Shilovsky
2017-11-17 19:02       ` Pavel Shilovsky
2017-11-09  1:14   ` [PATCH 03/19] cifs: remove rfc1002 header from smb2_logoff_req Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-4-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:10       ` Aurélien Aptel
2017-11-09  1:14   ` [PATCH 04/19] cifs: remove rfc1002 header from smb2_tree_disconnect_req Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-5-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:10       ` Aurélien Aptel
2017-11-09  1:14   ` [PATCH 05/19] cifs: remove rfc1002 header from smb2_close_req Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-6-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:10       ` Aurélien Aptel
2017-11-09  1:14   ` [PATCH 06/19] cifs: remove rfc1002 header from smb2_ioctl_req Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-7-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:10       ` Aurélien Aptel
2017-11-09  1:14   ` [PATCH 07/19] cifs: remove rfc1002 header from smb2_echo_req Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-8-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:10       ` Aurélien Aptel
2017-11-09  1:14   ` [PATCH 08/19] cifs: remove rfc1002 header from smb2_sess_setup_req Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-9-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:10       ` Aurélien Aptel
2017-11-09  1:14   ` [PATCH 09/19] cifs: remove rfc1002 header from smb2_tree_connect_req Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-10-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:10       ` Aurélien Aptel
2017-11-09  1:14   ` [PATCH 10/19] cifs: remove rfc1002 header from smb2_create_req Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-11-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:10       ` Aurélien Aptel
2017-11-09  1:14   ` [PATCH 11/19] cifs: remove rfc1002 header from smb2_flush_req Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-12-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:11       ` Aurélien Aptel
2017-11-09  1:14   ` [PATCH 12/19] cifs: remove rfc1002 header from smb2_lock_req Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-13-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:11       ` Aurélien Aptel
2017-11-09  1:14   ` [PATCH 13/19] cifs: remove rfc1002 header from smb2 read/write requests Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-14-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:11       ` Aurélien Aptel
2017-11-17  1:42       ` Pavel Shilovsky
     [not found]         ` <CAKywueRU_HM44i04yv_gKza=tgsuxwfF4h-XfstbXTZe3AZQeg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-17  1:45           ` Leif Sahlberg
     [not found]             ` <546793899.27950063.1510883138100.JavaMail.zimbra-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-17  1:48               ` Pavel Shilovsky
2017-11-09  1:14   ` [PATCH 14/19] cifs: remove rfc1002 header from smb2_lease_ack Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-15-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:11       ` Aurélien Aptel
2017-11-17 22:56       ` Pavel Shilovsky
2017-11-09  1:14   ` [PATCH 15/19] cifs: remove rfc1002 header from smb2_oplock_break we get from server Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-16-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:11       ` Aurélien Aptel
2017-11-09  1:14   ` [PATCH 16/19] cifs: remove rfc1002 header from smb2_set_info_req Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-17-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:11       ` Aurélien Aptel
2017-11-09  1:14   ` [PATCH 17/19] cifs: remove rfc1002 header from smb2_query_directory_req Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-18-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:11       ` Aurélien Aptel
2017-11-09  1:14   ` [PATCH 18/19] cifs: remove rfc1002 header from smb2_query_info_req Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-19-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:11       ` Aurélien Aptel
2017-11-09  1:14   ` [PATCH 19/19] cifs: remove small_smb2_init Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-20-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:11       ` Aurélien Aptel
  -- strict thread matches above, loose matches on Subject: below --
2017-11-21  0:04 [PATCH 00/19 Version 4] cifs: remove rfc1002 from smb2 requests Ronnie Sahlberg
     [not found] ` <20171121000442.24888-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-21  0:04   ` [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req Ronnie Sahlberg
2017-11-20  0:24 [PATCH 00/10] cifs: Remove rfc1002 header from smb2 request structs Ronnie Sahlberg
     [not found] ` <20171120002447.32322-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-20  0:24   ` [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req Ronnie Sahlberg
2017-11-02  7:02 [PATCH 00/19] cifs: remove rfc1002 header from all smb2 requests Ronnie Sahlberg
     [not found] ` <20171102070312.18903-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-02  7:02   ` [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req Ronnie Sahlberg

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=1978629070.27950035.1510883055312.JavaMail.zimbra@redhat.com \
    --to=lsahlber-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=piastryyy-Re5JQEeQqe8AvxtiuMwx3w@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