cifsd-team / ksmbd-tools

ksmbd kernel server userspace utilities
GNU General Public License v2.0
94 stars 27 forks source link

windows system compatibility issue #208

Closed Kenny0793 closed 2 years ago

Kenny0793 commented 3 years ago

Hi All,

 We use cifsd to share files. During use, we found that some windows cannot delete files. Right-clicking to delete files has no response. After creating/writing a file, some windows will hang. Some windows are fine. It seems that the system compatibility is not good. Can you encounter this problem? Do you have any good suggestions to solve it? thanks.

BR Kenny

Kenny0793 commented 3 years ago

My config file: root@mygateway:/tmp/log# cat /etc/cifs/smb.conf [global] netbios name = mygateway workgroup = SC-LVG server min protocol = SMB2_02 server string = mygateway Sharing Files [TEAM2] comment = Share TEAM2 directory path = /mnt/sda1 browsable = yes available = yes valid users = admin read only = yes write list = admin I also changed the shared path to a directory on the disk instead of the U disk, the problem is the same.

namjaejeon commented 3 years ago

Can you provide wireshark dump or tcpdump to us ?

Kenny0793 commented 3 years ago

[SMB2_DEUBG_LOGS.zip](https://github.com/cifsd-team/ksmbd-tools/files/7095612/SMB2_DEUBG_LOGS.zip)

Kenny0793 commented 3 years ago

Hi namjaejeon,

  I upload the wireshark dump. I explain my test cases in README.txt. Could you help check and give your suggestion? Thanks.

BR Kenny

Kenny0793 commented 3 years ago

correct one point for case2, delete file ttttt.txt and pc hangs.

namjaejeon commented 3 years ago

Thanks for your help, Let me check it.

namjaejeon commented 3 years ago

Can you share what windows version(10, 10 pro? enterprise?) is used for test ?

Kenny0793 commented 3 years ago

Windows 10 enterprise. We also reproduce it in Windows7

Kenny0793 commented 3 years ago

For the same PC, I access samba(smbd) in linux, all are ok. Do you know why? We used the package is not the newest. If we upgrade to the newest cifsd, Can it fix the issue? thanks.

namjaejeon commented 3 years ago

Okay, What ksmbd(cifsd) version are you using ?

Kenny0793 commented 3 years ago

root@mygateway:~# cifsd -h cifsd-tools version : 2.0.0 Usage: cifsd --p=NUM | --port=NUM TCP port NUM --c=smb.conf | --config=smb.conf config file --u=pwd.db | --users=pwd.db Users DB --n | --nodetach Don't detach --s | --systemd Service mode --uid Set process UID --gid Set process GID

Kenny0793 commented 3 years ago

I can download the newest package cifsd-tools-2019-11-27-06fd4153. The version is 2.0.2. So is it the newest?

namjaejeon commented 3 years ago

Oh.. too old version. Please. Can you check the latest version ?

  1. ksmbd-tools: https://github.com/cifsd-team/ksmbd-tools/releases/tag/3.4.1
  2. ksmbd : https://github.com/cifsd-team/ksmbd/releases/tag/3.4.1

we rename cifsd to ksmbd. so utils name and directory name should be changed to ksmbd.(e.g. /etc/ksmbd/smb.conf) Please check them..

Kenny0793 commented 3 years ago

Hi namjaejeon ,

Kenny0793 commented 3 years ago

I know that ksmbd module was compiled via ksmbd: https://github.com/cifsd-team/ksmbd/releases/tag/3.4.1. But I want to test if it work well in Debian GNU/Linux 10. Do you know how to compile it in Debian? Thanks.

Kenny0793 commented 3 years ago

I also want to install cifsd in Debian, but it failed: g562046@shz-p5620460vl:~$ sudo modprobe kcifsd [sudo] password for g562046: modprobe: FATAL: Module kcifsd not found in directory /lib/modules/4.19.98arg g562046@shz-p5620460vl:~$ g562046@shz-p5620460vl:~$ g562046@shz-p5620460vl:~$ sudo cifsd -n [cifsd-worker/13918]: ERROR: Cannot resolve netlink family

I think that it may be caused by missing kernel module kcifsd, Could you tell me how to install it? thanks in advance.

namjaejeon commented 3 years ago

Have you try a step in REAME of ksmbd ? See: https://github.com/cifsd-team/ksmbd-tools/blob/master/README

If you installed ksmbd well, you should command modprobe ksmbd, not kcifsd. and should run ksmbd.mountd instead of cifsd.

Kenny0793 commented 3 years ago

yes, i am trying the steps in readme. i want to install cifsd and ksmbd in linux host. and compare new tool ksmbd if can fix the issue. my issue is how to compile kernel module kcifsd and ksmbd. in my linux host, no such kernel modules by default. do you a wiki?

namjaejeon commented 3 years ago

How did you install cifsd.ko before ? It is same with before. you can just command "make" and "make install" and modprobe ksmbd.

Kenny0793 commented 3 years ago

i run it in router before. now i want to test in kinux host, need to compile and generate kernel module separately. may be a little difference

namjaejeon commented 3 years ago

Good morning, I loaded the module cifs.ko. g562046@shz-p5620460vl:~$ lsmod |grep cifs

cifs.ko is different with cifisd. you should insmod cifsd.ko or ksmbd.ko to run cifsd -n.

namjaejeon commented 3 years ago

Can you tell me where is the source code for module cifsd.ko?

You can download source code as per old cifsd version. See: https://github.com/cifsd-team/ksmbd/releases

Kenny0793 commented 3 years ago

I got it, thanks very much.

Kenny0793 commented 3 years ago

Hi, I can't compile the module ksmd. Does it need more higher kernel version support? My kernel is 4.19.98 or 4.9.198.

g562046@shz-p5620460vl:/usr/src/linux/fs/ksmbd$ sudo make [sudo] password for g562046: make -C /lib/modules/4.19.98arg/build M=/usr/src/linux-headers-4.19.98arg/fs/ksmbd modules make[1]: Entering directory '/usr/src/linux-headers-4.19.98arg' CC [M] /usr/src/linux-headers-4.19.98arg/fs/ksmbd/auth.o In file included from /usr/src/linux-headers-4.19.98arg/fs/ksmbd/auth.c:28: /usr/src/linux-headers-4.19.98arg/fs/ksmbd/mgmt/user_session.h:57:18: error: field ‘tree_conns’ has incomplete type struct xarray tree_conns; ^~~~~~ /usr/src/linux-headers-4.19.98arg/fs/ksmbd/auth.c: In function ‘smbhash’: /usr/src/linux-headers-4.19.98arg/fs/ksmbd/auth.c:92:17: error: storage size of ‘ctx’ isn’t known struct des_ctx ctx; ^~~ /usr/src/linux-headers-4.19.98arg/fs/ksmbd/auth.c:100:2: error: implicit declaration of function ‘des_expand_key’; did you mean ‘des_ekey’? [-Werror=implicit-function-declaration] des_expand_key(&ctx, key2, DES_KEY_SIZE); ^~~~~~ des_ekey /usr/src/linux-headers-4.19.98arg/fs/ksmbd/auth.c:101:2: error: implicit declaration of function ‘des_encrypt’; did you mean ‘des_ekey’? [-Werror=implicit-function-declaration] des_encrypt(&ctx, out, in); ^~~

Kenny0793 commented 3 years ago

Which ksmbd package can match with my kernel version 4.19.98 or 4.9.198? I can't upgrade my kernel version. Looking forward to you reply. thanks.

Kenny0793 commented 3 years ago

ksmbd: release 3.3.1 version is ok. I will try it.

Kenny0793 commented 3 years ago

Hi namjaejeon, Good morning, I tested the ksmbd-tools 3.3.7, the issue still exist. I uploaded the wireshark dump. Could you help check and give you suggestion? Is it possible to fix it? thanks in advance.

sudo ksmbd.mountd -V

 ksmbd-tools version : 3.3.7

 #lsmod |grep -i ksmb
 ksmbd                 282624  0

 #ps -aux |grep -i ksmbd       
 root     14302  0.0  0.0   8356  2100 ?        Ss   10:10   0:00 ksmbd.mountd
 root     14303  0.0  0.0  18132  3784 ?        S    10:10   0:00 ksmbd.mountd
 root     14304  0.0  0.0      0     0 ?        S    10:10   0:00 [ksmbd-lo]
 root     14305  0.0  0.0      0     0 ?        S    10:10   0:00 [ksmbd-eth0]

 #cat /etc/ksmbd/smb.conf 
 [global]
    netbios name = SMBD

 [TEAM2]
    comment = content server share
    path = /home/g562046
    browsable = yes
    available = yes
    valid users = g562046
    read only = yes
    write list = g562046

BR Kenny

Kenny0793 commented 3 years ago

[PC_NO_RESPONSE.zip](https://github.com/cifsd-team/ksmbd-tools/files/7109111/PC_NO_RESPONSE.zip)

Kenny0793 commented 3 years ago

Change read only = yes to no, issue is the same. If accessing samba only with IP: \192.168.0.4, are all ok. cat /etc/ksmbd/smb.conf [global] netbios name = SMBD

[TEAM2] comment = content server share path = /home/g562046 browsable = yes available = yes valid users = g562046 read only = no write list = g562046

namjaejeon commented 3 years ago

Hm.. strange.. no clue in dump. Can you reproduce it on samba server & win 10 enterprise ? and provide me dump file while reproducing by doing same step. I want to compare dump file between samba and ksmbd.

Kenny0793 commented 3 years ago

[PC2_SAMBA_OK.zip](https://github.com/cifsd-team/ksmbd-tools/files/7109262/PC2_SAMBA_OK.zip)

Kenny0793 commented 3 years ago

I do same steps using samba server & win 10 enterprise, are all ok. Please help check it, thanks.

sudo netstat -tupln |grep 445

[sudo] password for g562046: tcp 0 0 0.0.0.0:445 0.0.0.0: LISTEN 2043/smbd
tcp6 0 0 :::445 :::
LISTEN 2043/smbd

cat /etc/samba/smb.conf (Key part)

[TEAM2] path = /home/g562046 valid users = g562046 available = yes browseable = yes writable = yes public = no

namjaejeon commented 3 years ago

Acutally I don't know what is difference. So I need to request you some test. because I can not reproduce this issue. Can you add "share:fake_fscaps = 0" in [global] section and try to reproduce again ?

[global] share:fake_fscaps = 0

Kenny0793 commented 3 years ago

It seems to be ok. I will do more test. Can you tell me what this option does? Does it have similar options for cifsd (2.0.0.0)? Thanks

namjaejeon commented 3 years ago

This option is set to flags for sparse file. and this option is not in cifsd 2.0.

namjaejeon commented 3 years ago

Conversely, can you set below parameter in Samba's smb.conf and check if there is same problem on samba?

[global] share:fake_fscaps = 64

Kenny0793 commented 3 years ago

Hi namjaejeon,

Sorry, after I changed to another PC (win10 Enterprise), the issue still exist. After rebooting my PC, I also can reproduce it. I don't know why it is ok before, may be I tested SMB server. I upload the packets, could you help check it? If need more test, I will do it now. thanks.

sudo netstat -tupln |grep 445

tcp6 0 0 :::445 ::: LISTEN -
tcp6 0 0 :::445 :::
LISTEN -

cat /etc/ksmbd/smb.conf

[global] netbios name = SMBD share:fake_fscaps = 0

[TEAM2] comment = content server share path = /home/g562046 browsable = yes available = yes valid users = g562046 read only = no write list = g562046

BR Kenny

Kenny0793 commented 3 years ago

[PC_KSMBD_NOK.zip](https://github.com/cifsd-team/ksmbd-tools/files/7109423/PC_KSMBD_NOK.zip)

Kenny0793 commented 3 years ago

Conversely, can you set below parameter in Samba's smb.conf and check if there is same problem on samba? [global] share:fake_fscaps = 64

Yes, I test it on samba, it is ok.

Kenny0793 commented 3 years ago

because I can not reproduce this issue.

I think that it is easy to reproduce with win10 when accessing samba with full path \IP\sharename. if only use \IP, it is ok.

namjaejeon commented 3 years ago

I think that it is easy to reproduce with win10 when accessing samba with full path \IP\sharename. if only use \IP, it is ok.

stranged.. If you use network drive connection ?

namjaejeon commented 3 years ago

I try to reproduce it with \IP\sharename address as you share, It work fine on my setup(can't reproduce). and don't use writable = yes in smb.conf. Please use "read only = no" or "writeable =yes"

Kenny0793 commented 3 years ago

stranged.. If you use network drive connection ?

Sorry, I don't understand it well. When accessing samba, I will open explorer.exe each time and enter \IP\sharename. I don't map it to local network driver. Writable=yes is included in the config file of samba. For /etc/ksmbd/smb.conf, I only use the "read only = no".

Kenny0793 commented 3 years ago

Is it possible to redirect to \IP even if user access with full path \IP\sharename? I checked the packets, when accessing with full path, windows first call NetShareEnumAll, and then all are ok.

namjaejeon commented 3 years ago

not possible. Have you tried to map network drive in windows ?

Kenny0793 commented 3 years ago

No,I did not map network drive in windows. During using, we also do not map it. If not possibile to redirect it. Do you have any good suggestion to fix it?

namjaejeon commented 3 years ago

I really want to fix it. but If I can't reproduce it, there are some limitations to fix it. I suggest two options.

  1. You have directly fixed it if you can easily reproduce it. ksmbd is an opensouce. the code is opened and Open source is a model for everyone to develop together.
  2. You provide me how to reproduce this issue. You told me that you can not reproduce it with some windows, which means there is difference between windows ? If so, you might change smb related options in windows ?
Kenny0793 commented 3 years ago

when accessing samba with full path, all windows we are using, win10 & win7,can reproduce the issue. our user also can reproduce it. okay, i will try to do it.

namjaejeon commented 3 years ago

What is meaning our user ? Can I ask what your product is using ksmbd ?

when accessing samba with full path

samba means ksmbd ? ksmbd is kernel server and samba is userspace smb server. they are different. just curious.

Kenny0793 commented 3 years ago

router