Hi R. Diez,

You have probably been following the chatter on the upstream mailing list
discussion. I initially thought the patch didn't fix the issue, as when I mount
with wsize=16850, the issue still occurs [1], but it seems that the intent of
the patch is to only correct when the server specifies an incorrect wsize, and
to correct that instead [2].

[1] 
https://lore.kernel.org/linux-cifs/CAKAwkKuJvFDFG7=bcymj0jdmmhytlunygdueaubtoctbnqt...@mail.gmail.com/
[2] 
https://lore.kernel.org/linux-cifs/CAH2r5mt9gPhUSka56yk28+nksw7=LPuS4VAMzGQyJEOfcpOc=g...@mail.gmail.com/

Anyway, I have built you a test kernel that includes the patch, not from today,
but yesterday's corrected one [3] ontop of 6.5.0-15-generic for Jammy HWE.

[3] https://lore.kernel.org/linux-
cifs/cah2r5mvzyxp7vhqvct6iep4nmxdaz2uqtt7g4yrxcvobkv_...@mail.gmail.com/

If you want to try it out on your system before it gets merged upstream, please
do, since your SMB server sends a incorrect wsize.

Please note this package is NOT SUPPORTED by Canonical, and is for TESTING
PURPOSES ONLY. ONLY Install in a dedicated test environment.

Instructions to install (On a Jammy system):
1) sudo add-apt-repository ppa:mruffell/lp2049634-test
2) sudo apt update
3) sudo apt install linux-image-unsigned-6.5.0-15-generic 
linux-modules-6.5.0-15-generic linux-modules-extra-6.5.0-15-generic 
linux-headers-6.5.0-15-generic
4) sudo reboot
5) uname -rv
6.5.0-15-generic #15~22.04.1+TEST2049634v20240208b1-Ubuntu SMP PREEMPT_DYNAMIC 
Th

Perform your smb1 mount but without any wsize set, and then run:

$ sudo dmesg | tail

or just look at the end of dmesg in journalctl, and could you please

1) send the output of the lines with "CIFS:" at the start. I just want to see
if the strings "CIFS: VFS: wsize should be a multiple of 4096 (PAGE_SIZE)" and
"CIFS: VFS: wsize too small, reset to minimum ie PAGE_SIZE, usually 4096" are
there. and:
2) see if the issue is actually fixed by doing a test copy and looking with 
less.

In the meantime I will ask Steve if its worth just setting all wsize to 
multiples
of PAGE_SIZE regardless how it is set, since a partial one on the mount command
line will destroy your data anyway, and thats not useful.

Thanks!
Matthew

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/2049634

Title:
  smb: wsize blocks of bytes followed with binary zeros on copy,
  destroying data

Status in linux package in Ubuntu:
  In Progress
Status in linux source package in Mantic:
  In Progress
Status in linux source package in Noble:
  In Progress

Bug description:
  [Impact]

  Upon installing the 6.5 HWE kernel on Jammy, users with a custom wsize
  set will see data destruction when copying files from their systems
  onto a cifs smb 1.0 mount.

  wsize defaults to 65535 bytes, but when set to smaller values, like
  16850, users will see blocks of 16850 bytes copied over, followed by
  3900 binary zeros, followed by the next block of data followed by more
  binary zeros.

  A workaround is to increase wsize, but this only works for small
  files, as any files larger than wsize will see the bug.

  Most users will want to use the 6.2 HWE kernel until this is fixed.

  [Testcase]

  Start two VMs, one for the server, and the other, the client.

  Server
  ------

  $ sudo apt update
  $ sudo apt upgrade
  $ sudo apt install samba
  $ sudo vim /etc/samba/smb.conf 
  server min protocol = NT1
  [sambashare]
      comment = Samba on Ubuntu
      path = /home/ubuntu/sambashare
      read only = no
      browsable = yes
  $ mkdir ~/sambashare
  $ sudo smbpasswd -a ubuntu

  Client
  ------

  $ sudo apt update
  $ sudo apt install cifs-utils
  $ mkdir ~/share
  $ sudo mount -t cifs -o username=ubuntu,vers=1.0,wsize=16850 
//192.168.122.172/sambashare ~/share
  $ ( set -o pipefail && head --bytes=$(( 55 * 1000 )) /dev/zero | openssl enc 
-aes-128-ctr -nosalt -pass "pass:my-seed" -iter 1 | hexdump --no-squeezing 
--format '40/1 "%02x"' --format '"\n"' >"testdata.txt" )
  $ sha256sum testdata.txt 
  9ec09af020dce3270ea76531141940106f173c7243b7193a553480fb8500b3f2  testdata.txt

  Now copy the file to the share.

  Client
  ------
  $ cp testdata.txt share/

  Server
  ------
  $ sha256sum sambashare/testdata.txt 
  9e573a0aa795f9cd4de4ac684a1c056dbc7d2ba5494d02e71b6225ff5f0fd866  
sambashare/testdata.txt

  The SHA256 hash is different. If you view the file with less, you will
  find a block of wsize=16850 bytes, then 3900 bytes of binary zeros,
  followed by another wsize=16850 bytes, then 3900 bytes of binary
  zeros, etc.

  An example of a broken file is:
  https://launchpadlibrarian.net/712573213/testdata-back-from-server.txt

  [Where problems could occur]

  [Other info]

  Currently bisecting. Introduced in 6.3-rc1. Currently broken on
  mainline 6.8-rc3.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2049634/+subscriptions


-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to     : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to