All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pawel Witek <pawel.ireneusz.witek@gmail.com>
To: Steve French <smfrench@gmail.com>
Cc: linux-cifs@vger.kernel.org
Subject: Re: [PATCH] cifs: fix pcchunk length type in smb2_copychunk_range
Date: Fri, 5 May 2023 21:31:25 +0200	[thread overview]
Message-ID: <824c8a05-4c68-119e-45a9-504ea0aa8583@gmail.com> (raw)
In-Reply-To: <CAH2r5mszw6sayQfJqiYwTjPCqKDB7Dk-Hmtr0-Z3fXf=e3t0aQ@mail.gmail.com>

I've tried to copy a 5 GB file which resulted in -EINVAL (same for larger
files). After wiresharking the protocol I've observed that one packet
requests ioctl with 'Transfer Length: 0', to which the server responded
with an error. Some investigation showed, that this happens when
len=4294967296.

On 5/5/23 18:47, Steve French wrote:
> since pcchunk->Length is a 32 bit field doing cpu_to_le64 seems wrong.
> 
> Perhaps one option is to split this into two lines do the minimum(u64, len, tcon->max_bytes_chunk) on one line and the cpu_to_le32 of the result on the next
> 
> What is "len" in the example you see failing?
> 
> On Fri, May 5, 2023 at 10:15 AM Pawel Witek <pawel.ireneusz.witek@gmail.com <mailto:pawel.ireneusz.witek@gmail.com>> wrote:
> 
>     Change type of pcchunk->Length from u32 to u64 to match
>     smb2_copychunk_range arguments type. Fixes the problem where performing
>     server-side copy with CIFS_IOC_COPYCHUNK_FILE ioctl resulted in incomplete
>     copy of large files while returning -EINVAL.
> 
>     Signed-off-by: Pawel Witek <pawel.ireneusz.witek@gmail.com <mailto:pawel.ireneusz.witek@gmail.com>>
>     ---
>      fs/cifs/smb2ops.c | 2 +-
>      1 file changed, 1 insertion(+), 1 deletion(-)
> 
>     diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
>     index a81758225fcd..35c7c35882c9 100644
>     --- a/fs/cifs/smb2ops.c
>     +++ b/fs/cifs/smb2ops.c
>     @@ -1682,7 +1682,7 @@ smb2_copychunk_range(const unsigned int xid,
>                     pcchunk->SourceOffset = cpu_to_le64(src_off);
>                     pcchunk->TargetOffset = cpu_to_le64(dest_off);
>                     pcchunk->Length =
>     -                       cpu_to_le32(min_t(u32, len, tcon->max_bytes_chunk));
>     +                       cpu_to_le64(min_t(u64, len, tcon->max_bytes_chunk));
> 
>                     /* Request server copy to target from src identified by key */
>                     kfree(retbuf);
>     -- 
>     2.40.1
> 
> 
> 
> 
> -- 
> Thanks,
> 
> Steve

  parent reply	other threads:[~2023-05-05 19:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05 15:14 [PATCH] cifs: fix pcchunk length type in smb2_copychunk_range Pawel Witek
     [not found] ` <CAH2r5mszw6sayQfJqiYwTjPCqKDB7Dk-Hmtr0-Z3fXf=e3t0aQ@mail.gmail.com>
2023-05-05 16:47   ` Fwd: " Steve French
2023-05-05 19:31   ` Pawel Witek [this message]
     [not found]     ` <CAH2r5mvCCY=VT9ZUkjz4c+QGZ0MjR4ggdG56QUa-apZ7eoeo0A@mail.gmail.com>
2023-05-06  4:49       ` Steve French
2023-05-06  4:51         ` Steve French
2023-05-06  8:06           ` Pawel Witek

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=824c8a05-4c68-119e-45a9-504ea0aa8583@gmail.com \
    --to=pawel.ireneusz.witek@gmail.com \
    --cc=linux-cifs@vger.kernel.org \
    --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 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.