linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Talpey <ttalpey@microsoft.com>
To: Ronnie Sahlberg <lsahlber@redhat.com>,
	linux-cifs <linux-cifs@vger.kernel.org>
Cc: Steve French <smfrench@gmail.com>
Subject: RE: [PATCH] cifs: fix bi-directional fsctl passthrough calls
Date: Tue, 16 Apr 2019 20:30:48 +0000	[thread overview]
Message-ID: <BN8PR21MB11867D56B51DB9EA88747F68A0240@BN8PR21MB1186.namprd21.prod.outlook.com> (raw)
In-Reply-To: <20190415021352.30854-2-lsahlber@redhat.com>

> -----Original Message-----
> From: linux-cifs-owner@vger.kernel.org <linux-cifs-owner@vger.kernel.org> On
> Behalf Of Ronnie Sahlberg
> Sent: Sunday, April 14, 2019 10:14 PM
> To: linux-cifs <linux-cifs@vger.kernel.org>
> Cc: Steve French <smfrench@gmail.com>; Ronnie Sahlberg
> <lsahlber@redhat.com>
> Subject: [PATCH] cifs: fix bi-directional fsctl passthrough calls
> 
> SMB2 Ioctl responses from servers may respond with both the request blob
> from
> the client followed by the actual reply blob for ioctls that are bi-directional.
> 
> In that case we can not assume that the reply blob comes immediately after
> the
> ioctl response structure.
> 
> This fixes FSCTLs such as SMB2:FSCTL_QUERY_ALLOCATED_RANGES
> 
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
>  fs/cifs/smb2ops.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
> index 0b7e2be2a781..2824b97c5869 100644
> --- a/fs/cifs/smb2ops.c
> +++ b/fs/cifs/smb2ops.c
> @@ -1462,12 +1462,19 @@ smb2_ioctl_query_info(const unsigned int xid,
>  		io_rsp = (struct smb2_ioctl_rsp *)rsp_iov[1].iov_base;
>  		if (le32_to_cpu(io_rsp->OutputCount) <
> qi.input_buffer_length)
>  			qi.input_buffer_length = le32_to_cpu(io_rsp-
> >OutputCount);
> +		if (qi.input_buffer_length > 0 &&
> +		    le32_to_cpu(io_rsp->OutputOffset) + qi.input_buffer_length
> > rsp_iov[1].iov_len) {

I hope this isn't a dumb question, but I can't readily figure it out due to
multiple layers of #include nesting. Is le32_to_cpu() signed or unsigned?
If it's signed, this validation could still be attacked.

And second question, is the fsctl output payload always guaranteed to land
in rsp_iov[1]?

Tom.

> +			rc = -EFAULT;
> +			goto iqinf_exit;
> +		}
>  		if (copy_to_user(&pqi->input_buffer_length,
> &qi.input_buffer_length,
>  				 sizeof(qi.input_buffer_length))) {
>  			rc = -EFAULT;
>  			goto iqinf_exit;
>  		}
> -		if (copy_to_user(pqi + 1, &io_rsp[1], qi.input_buffer_length)) {
> +		if (copy_to_user((char *)pqi + sizeof(struct smb_query_info),
> +				 (char *)io_rsp + le32_to_cpu(io_rsp-
> >OutputOffset),
> +				 qi.input_buffer_length)) {
>  			rc = -EFAULT;
>  			goto iqinf_exit;
>  		}
> --
> 2.13.6


  reply	other threads:[~2019-04-16 20:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-15  2:13 fix bidirectional fsctl passthrough Ronnie Sahlberg
2019-04-15  2:13 ` [PATCH] cifs: fix bi-directional fsctl passthrough calls Ronnie Sahlberg
2019-04-16 20:30   ` Tom Talpey [this message]
2019-04-16 20:41     ` Steve French
2019-04-17  6:36     ` ronnie sahlberg
  -- strict thread matches above, loose matches on Subject: below --
2019-04-16 23:01 Steve French
2019-04-12  3:05 Ronnie Sahlberg
2019-04-12 12:51 ` Tom Talpey
2019-04-12 13:37   ` ronnie sahlberg
2019-04-12 13:53     ` Tom Talpey

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=BN8PR21MB11867D56B51DB9EA88747F68A0240@BN8PR21MB1186.namprd21.prod.outlook.com \
    --to=ttalpey@microsoft.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=lsahlber@redhat.com \
    --cc=smfrench@gmail.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).