New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ksmbd: update to 3.1.3, ksmbd-tools: update to 3.2.1, add smb1 support #11290
Conversation
* ksmbd: update to 3.1.3 * ksmbd-tools: update to 3.2.1 * add new package build option "KSMBD_SMB_INSECURE_SERVER" * enable smb1 support to kmod by default * add new UCI option "allow_legacy_protocols" to section [globals] * ksmbd: release 3.1.3 version * ksmbd: lock SMB2_QUERY_INFO_HE request with read lock * ksmbd: fix potential racy between query_dir and ksmbd_vfs_empty_dir * ksmbd: fix racy issue between deleting file and checking empty directory * ksmbd: don't register interface which are member of bridge * ksmbd: SO_REUSEADDR is no property of tcp_setsockopt * ksmbd: release 3.1.2 version * ksmbd: fix read caching buffer size as max_read_size * ksmbd: fix the infinite loop of handling FSCTL_QUERY_ALLOCATED_RANGES * ksmbd: use compounding for smb2 flush * ksmbd: downgrade error message to debug in get_file_all_info * ksmbd: rename usmbd to ksmbd.mountd in trvis-ci * ksmbd: release 3.1.1 version * ksmbd: does not work if ipv6 module is not loaded or compiled in * ksmbd: capsule ifdef CONFIG_SMB_INSECURE_SERVER with smb1 codes * ksmbd: capsule ifdef CONFIG_SMB_INSECURE_SERVER with smb1 codes * ksmbd: update README file * ksmbd-tools: release 3.2.1 version * ksmbd-tools: revert "remove glib2.0 dependancy" patch * ksmbd-tools: release 3.2.0 version * ksmbd-tools: update how to restart ksmbd in README file * Revert "ksmbd-tools: disable tbuf and rbuf caching by default" * ksmbd-tools: disable tbuf and rbuf caching by default * ksmbd-tools: replace usmbd prefix with ksmbd prefix * ksmbd-tools: update README file * ksmbd-tools: fix warning ignoring return value of 'fread' * ksmbd-tools: downgrade unsupported command print to debug * ksmbd-tools: remove GLIB_LIBS in Makefiles * ksmbd-tools: rename usmbd, smbuseradd, smbshareadd to ksmbd.mountd, ksmbd.adduser and ksmbd.addshare * ksmbd-tools: fix null pointer dereference in _list_remove * ksmbd-tools: fix the sanity check fails depending on the password length * ksmbd-tools: fix build error(not found glib.h) * ksmbd-tools: remove glib-2.0 dependancy * ksmbd-tools: update README to add libglib2.0-dev for Ubuntu preprequisite packages Signed-off-by: Andy Walsh <andy.walsh44+github@gmail.com>
I backported this to 19.07 and I'm getting this error:
Network br-lan is up. Once I commented 'interface =' and 'bind only' from templates, it did start to listen. However, it always crash as soon as I first mounted a share. /sys/kernel/debug/crashlog gave me:
I tested both with and without allow_legacy_protocols. I did need to force deps in order to install kernel modules (and it target 4.14.169 instead of 4.14.167). But I don't think that this is the cause. It crashed while swapper process was running. However, when I disabled swap, it crashed with transmission-daemon. So, something went broke inside kernel space. And I guess 'allow_legacy_protocols' should be in default config, respecting default behavior. |
Worked find for me on 19.07 (mips), but i did a fresh build + flash. |
I'm using #11297, downloading the new userland progs from official repo and rebuilt kmod using SDK (to match my running kernel). Is it a sin? I can mount/umount from a linux machine with no issues when using new protocols. However, when I use my crappy android apps, it crashes (they are good to test implementation tolerance).
And when I added '-g -DDEBUG -Og ' to gcc:
PS: I'm not sure this command makes sense with non-debug build and cross-compiling Linux mount: it used SMB2 to offer dialects 0x0210, 0x0300,0x0302, 0x0311 (by default). Server selected 0x0311 and everything worked as expected. It worked from vers=2.0 (where the client offer only 0x0202) and on, both using FQDN and IP address, both IPv4 and IPv6. With vers=1.0 (and legacy protocols enabled), I get in my linux box these two errors when using ip address or FQDN (which might try IPv6)
And wireshark tells me the SMB is corrupted (while doing NTLMSSP_NEGO). AndSMB (android) using SMB1 (and legacy protocols enabled): it sends SMB trying dialect "NT LM 0.12". Server ACKs the dialect. AndSMB starts a NTLMSSP_NEGO, server answer is marked as malformed by wireshark. It authenticates as anonymous but get STATUS_USER_SESSION_DELETED when client connects to IPC$. AndSMB (android) using SMB2/3 mode: it used SMB2 to offer dialects 0x0202, 0x0210. Server selected 0x0210. It seems server authenticate the user as guest. When it connects to a share, it uses my router FQDN (although I never mentioned it in my settings, Reverse DNS?). When it tries to open the share, I get STATUS_DATA_ERROR. Other apps normally crashes my router before I can capture data (even VLC that worked before). I'll attach my module built with debug options for ath79: |
@luizluca as noted i did test like 5 explorer Android apps on my 7.0 Phone and all worked fine and i could access my shares. I noticed some error's in the logs, but nothing crashed my router. I only noticed that Astro-Explorer sometimes crashed and i had to "force close" and reopen the app. I appreciate all the debug stuff, but this is out of my league and generally such problems belong in a upstream Issue cifsd-team/ksmbd#334. PS: What we have to keep in mind, is that we (openwrt snapshots) never really tested the smb1 codepath, since i never enabled/included it. So its possible there are still serious bugs, since upstream never got error reports on it and upstream generally only validates via smbtorture against x86 targets, So we are the testers for mips/arm and little/big endian stuff. |
@luizluca Could you tell me what mount option you use for smb1 mount ? |
Nothing especial:
|
Because I could not reproduce it on my test. and
It can not be reproduced either... What is the difference ? |
@Andy2244 I will check this as well as AndSMB. |
Sure. I'll try again now with a Malta qemu instead of a real device. |
Exactly the same issue usuing a virtual machine. I'm using malta bigendian 32-bit (the closer I can get to my ath79 and the only one with oficial images). Instead of some random patch contribution, I guess I could help more providing a reproducible test env. I tested using three variations:
Every single one got me the same result: kernel oops. Let me share a script I created to run OpenWrt using qemu. It support multiple archs (malta be/le, arm, x86, x86_64): owrt.gz. It will ask sudo in order to create owrt-br0 where VM LAN is connected. I connected it with my machine ethernet (to allow android clients to use it) with $ owrt -k https://downloads.openwrt.org/snapshots/targets/malta/be/openwrt-malta-be-vmlinux-initramfs.elf
(...)
root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install ksmbd-server
root@OpenWrt:~# cp /etc/ksmbd/ksmbd.config.example /etc/config/ksmbd
root@OpenWrt:~# ip a add 192.168.x.4/24 dev br-lan #I use a different address range
root@OpenWrt:~# /etc/init.d/ksmbd restart That is really every single command I typed since it booted. I really use an oneliner after wan is up:
Now you can test using android clients. Linux mount never crashed ksmbd, only android apps. Most android apps crashes the router as soon as it connects generating:
As it uses initram, I have to start all over again after every crash.
It cannot be "more reproducible" than this. It's a shame they removed the other 3 malta variation (le32, le64, be64) from snapshot builds (although they are in source). It could help uncover a simple endianness issue. However, other targets simply work as expected like arm (little endian). Test this for example:
It never crashes and opens the shares. I'm building malta-le (sorry, very slow machine) and I'll update here if it is an endianness or mips issue. |
It is probably endianness problem, with big endian machines. malta-le does not have the same issue as malta-be. |
@luizluca Thanks for your detail!!
|
Still crashing at the same place. Did you noticed that the last kernel oops (using snapshot image) does provide a nice call stack with symbols?
Maybe the fix is somewhere around it. |
rechecked. Could you check this patch ?
|
It's getting better. VLC access was restored and nothing could crash the system now. However, no apps could read the files (but VLC). I get this strange errors on dmesg:
I'm using this config (generated by init script):
It does not mention share dados (maybe '/' means it). Both paths are readable:
|
I sent a patch to you and list to fix this print([34652.212462] ksmbd: ksmbd_smb1_check_message:258: Invalid word count, 13 not -22. cmd 73) As I remember, smb app in andorid didn't implement reliably smb2 yet. but not sure that it is improved now. |
I applied the patch. No more "Invalid word count".
I still get it.
Nothing at server side dmesg, except for 'no right to enumerate directory' for some android apps. Did you use smbtorture?
Most of base and raw I get NT_STATUS_USER_SESSION_DELETED. Most of smb2 pass. |
Checking.
It seems corrupted compression file ?
Yep, I know, I don't have time to fix smb1 smbtorture failures. SMB1 is deprecated at windows 10. anyone don't recommend to use smb1 anymore. I don't want to invest my time for it which was already die. Although, I will maintain smb1 support as the current Because very few people want it. If there is a detail report like you, I will fix it. and If someone will fix smbtorture issues, welcome! |
Is it related with endian issue ? or This app can browse contents list with samba or window10 ?
Two apps send invalid signed message to ksmbd. This app work fine with le machine ? or be samba or windows... |
I installed samba36 and I'm using a quite similar config:
Now with ksmbd with mips little endian:
Yes, it is still an endian issue. If you do not have a big endian machine to test, you can run a VM. My owrt script makes it quite simple. |
Still checking, don't know where is difference yet.
I sent 3 patches to you and list. As I pointed out, smb2 in Android apps could not connected with samba and le ksmbd. You shoud not think it is connect with smb2/3. when I see patcket, smb2.1 connection failed and fallback to smb1. So it is not smb2 connection. |
I applied those three patches but I did not see an improvement. All apps still fails (and now VLC is also broken). There is now some kernel logs:
VLC broke after applying this one:
Filemanager and AndSMB fails with:
ksmbd answered with a very large response. It included the answer (I can see share names inside the payload) but after that there is a large chunk of zero data. The client closed after receiving about 27 kbytes (It didn't look like the server would stop). I would check the answer size for wrong endian. Update: in fact, most ksmbd answer includes a large chunck of zeros at the end. AndSMB SMBv2 looks simply broken (client bug). All other apps seems to fail here (including VLC):
|
I checked that FIND_FIRST2 is actually subcommand 0x1. So 0x100 is another endiness problem. This might fix the issue:
However, now I get either:
It might be related to the fact I was getting chunks of zeros at the end of ksmbd answers. |
BTW, I'm still using this patch (not sent to ML):
|
This patch is in ksmbd-next branch. |
Hm... this patch is correct. So other apps doesn't face USER_SESSION_DELETE error anymore.
I did totally fix endian issues in smb1 protocol. not sure if there are any missing points.. Thanks! |
Add one more patch in ksmbd-next now! |
@nakarotori , I guess it is better to deal with this issue cifsd-team/ksmbd#334 |
@Andy2244, @neheb, @namjaejeon: I am lost.
= cifsd -> smbd -> ksmbd -> cifsd |
ksmbd == cifsd. cifsd is directory name and project name. and ksmbd is thread(task) and ko's name. |
@namjaejeon: You have not changed the name of the project and the soft recently? And any news to move the repositories:
The goal is to have the perfect code in cifsd-team. For example, Microsoft has not main projects in user accounts. |
Maintainer: me
Compile tested: arm/mips (master)
Run tested: arm/mvebu (master)
Description:
Related PR:
openwrt/luci#3620
NOTE: Allows using smbv1 for older devices or Android tools that only support smb1.