cifsd-team / ksmbd

ksmbd kernel server(SMB/CIFS server)
154 stars 23 forks source link

files disappear after being copied from macOS #612

Open putnam opened 4 months ago

putnam commented 4 months ago

If I copy a file to a folder from my Mac, the file will seemingly copy and then vanish. I can observe it appearing on the filesystem briefly on the server side, and then something deletes it.

I am on Linux kernel 6.7 on Debian trixie/testing, which seems to be running ksmbd 3.4.2. (Why so old?)

ksmbd.conf:

[global]
        ; global parameters
        guest account = nobody
        map to guest = never
        netbios name = MYHOST

        ; the docs currently say data may get corrupted under race conditions -- TODO look into this
        server multi channel support = no
        server signing = disabled
        server string = MyHost

        ; default share parameters
        create mask = 0664
        directory mask = 0775
        hide dot files = no
        veto files = /._*/.DS_Store/.LSOverride/
        vfs objects = streams_xattr

[Scratch]
  path = /scratch
  comment = Scratch
  writable = yes
  valid users = putnam

I have tried disabling the streams_xattr vfs object and also the veto files directive. The behavior is the same either way. My user account owns the folder being written to. My username on the server is "putnam" and matches the user created with ksmbd.adduser.

I've looked at the Console log on the Mac and haven't seen anything interesting besides it trying to apply some xattr's to the file after it's already gone, which of course raises an error.

The debug output of a session is attached:

ksmbd-macos-copy.txt

namjaejeon commented 4 months ago

I am on Linux kernel 6.7 on Debian trixie/testing, which seems to be running ksmbd 3.4.2. (Why so old?)

I didn't update ksmbd version in linux mainline. because there is version number of linux kernel. and I have remove versioning on 6.9 kernel. This issue is coming with only MacOS client ? No reproducible with windows client and linux clients ?

putnam commented 4 months ago

It seems to work fine on the Windows client.

I did also notice that the test file, when finally written (it seems to sometimes work after several tries which is confusing) is in a strange mode where I cannot read it. Both Mac and Windows tell me I do not have permission. The file is owned properly, can be accessed OK on the host (Linux) and has permissions set OK (664).

namjaejeon commented 4 months ago

Can you test it after installing github ksmbd ?

git clone https://github.com/cifsd-team/ksmbd

Thanks.

namjaejeon commented 4 months ago

because 6.7.12 kernel doesn't have this patch. It is related with MacOS client.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/fs/smb/server?h=v6.9&id=5ed11af19e56f0434ce0959376d136005745a936

namjaejeon commented 4 months ago

I did also notice that the test file, when finally written (it seems to sometimes work after several tries which is confusing) is in a strange mode where I cannot read it. Both Mac and Windows tell me I do not have permission.

If you give me wireshark(or tcpdump) file that captured packets on problem situation to me, I will find the clue.