Closed xdarklight closed 3 years ago
segfault happen in ksmbd.mountd, Could you please find segfault line using gdb ?
how do I run the ksmbd.mount command manually (how to find the right arguments)? or do I need to attach to the running process
normally command running ksmbd.mountd without options like this. sudo ksmbd.mountd
It doesn't work ? @Andy2244 Could you help us run ksmbd.mountd manually on openWRT ?
# id
uid=0(root) gid=0(root)
# ksmbd.mountd
#
and then in the system log I get:
ksmbd: [ksmbd-manager/19963]: INFO: File '/tmp/ksmbd.lock' belongs to pid 4581
ksmbd: [ksmbd-manager/19963]: ERROR: Failed to create lock file: File exists
ksmbd: [ksmbd-manager/19963]: INFO: Exiting. Bye!
# id uid=0(root) gid=0(root) # ksmbd.mountd #
and then in the system log I get:
ksmbd: [ksmbd-manager/19963]: INFO: File '/tmp/ksmbd.lock' belongs to pid 4581 ksmbd: [ksmbd-manager/19963]: ERROR: Failed to create lock file: File exists ksmbd: [ksmbd-manager/19963]: INFO: Exiting. Bye!
There might already be running ksmbd.mountd. You need to kill it with "kill -INT 4581"
There might already be running ksmbd.mountd. You need to kill it with "kill -INT 4581"
@hclee Right! Need to kill ksmbd.mountd that already is running first.
thanks for the hints @hclee and @namjaejeon
in general I am following: https://openwrt.org/docs/guide-developer/gdb
I had to upload ksmbd.mountd to /tmp/ with debugging info:
# gdbserver :9000 /tmp/ksmbd.mountd -n
Process /tmp/ksmbd.mountd created; pid = 5103
Listening on port 9000
Remote debugging from host 192.168.1.100, port 60122
Detaching from process 5149
[ksmbd-worker/5149]: ERROR: Can't open `/etc/ksmbd/ksmbdpwd.db': No such file or directory
[ksmbd-worker/5149]: ERROR: User database file does not exist. Only guest sessions (if permitted) will work.
[ksmbd-worker/5149]: INFO: Drop non-existing user `hts'
[ksmbd-manager/5103]: ERROR: WARNING: child process exited abnormally: 5149
Detaching from process 5161
[ksmbd-worker/5161]: ERROR: Can't open `/etc/ksmbd/ksmbdpwd.db': No such file or directory
[ksmbd-worker/5161]: ERROR: User database file does not exist. Only guest sessions (if permitted) will work.
[ksmbd-worker/5161]: INFO: Drop non-existing user `hts'
[ksmbd-worker/5161]: ERROR: RPC: unknown pipe ID: 0
then on my PC:
$ ./scripts/remote-gdb 192.168.1.1:9000 ./build_dir/target-mips_24kc_musl/ksmbd-tools-3.3.0/mountd/ksmbd.mountd
Using target mips_24kc (musl, )
GNU gdb (GDB) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu --target=mips-openwrt-linux-musl".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./build_dir/target-mips_24kc_musl/ksmbd-tools-3.3.0/mountd/ksmbd.mountd...
0x77f5e690 in _dlstart () from /mnt/devel/lede/stable/scripts/../staging_dir/target-mips_24kc_musl/root-lantiq/lib/ld-musl-mips-sf.so.1
(gdb) c
Continuing.
[Detaching after fork from child process 5149]
[Detaching after fork from child process 5161]
in other words: it doesn't pause in gdb when crashing... I will investigate further tonight. any hints are appreciated though
in gdb I had to use:
set follow-fork-mode child
now I get:
Thread 4.2 "pool" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 7797.7811]
strlen (s=0x0) at src/string/strlen.c:17
17 for (w = (const void *)s; !HASZERO(*w); w++);
(gdb) bt full
#0 strlen (s=0x0) at src/string/strlen.c:17
a = 0x0
w = 0x0
#1 0x0040dc3b in __share_entry_data_ctr1 (dce=0x77f11f30, entry=<optimized out>) at rpc_srvsvc.c:110
share = <optimized out>
ret = 0
len = <optimized out>
#2 0x00409163 in __ndr_write_array_of_structs (pipe=0x77f113c0, max_entry_nr=<optimized out>) at rpc.c:564
entry = <optimized out>
dce = 0x77f11f30
i = 0
#3 0x0040e26d in ndr_write_array_of_structs (pipe=0x77f113c0) at rpc.c:628
dce = 0x77f11f30
max_entry_nr = 3
ret = 0
dce = <optimized out>
max_entry_nr = <optimized out>
ret = <optimized out>
#4 srvsvc_share_enum_all_return (pipe=0x77f113c0) at rpc_srvsvc.c:220
dce = 0x77f11f30
status = 0
dce = <optimized out>
status = <optimized out>
#5 srvsvc_share_info_return (pipe=0x77f113c0) at rpc_srvsvc.c:373
dce = 0x77f11f30
status = <optimized out>
dce = <optimized out>
status = <optimized out>
#6 srvsvc_return (max_resp_sz=<optimized out>, resp=<optimized out>, pipe=0x77f113c0) at rpc_srvsvc.c:423
dce = 0x77f11f30
ret = <optimized out>
...
On (20/11/30 04:14), Martin Blumenstingl wrote:
0 strlen (s=0x0) at src/string/strlen.c:17
a = 0x0 w = 0x0
1 0x0040dc3b in __share_entry_data_ctr1 (dce=0x77f11f30, entry=
) at rpc_srvsvc.c:110 share = <optimized out> ret = 0 len = <optimized out>
2 0x00409163 in __ndr_write_array_of_structs (pipe=0x77f113c0, max_entry_nr=
) at rpc.c:564 entry = <optimized out> dce = 0x77f11f30 i = 0
3 0x0040e26d in ndr_write_array_of_structs (pipe=0x77f113c0) at rpc.c:628
dce = 0x77f11f30 max_entry_nr = 3 ret = 0 dce = <optimized out> max_entry_nr = <optimized out> ret = <optimized out>
4 srvsvc_share_enum_all_return (pipe=0x77f113c0) at rpc_srvsvc.c:220
dce = 0x77f11f30 status = 0 dce = <optimized out> status = <optimized out>
5 srvsvc_share_info_return (pipe=0x77f113c0) at rpc_srvsvc.c:373
dce = 0x77f11f30 status = <optimized out> dce = <optimized out> status = <optimized out>
6 srvsvc_return (max_resp_sz=
, resp= , pipe=0x77f113c0) at rpc_srvsvc.c:423 dce = 0x77f11f30 ret = <optimized out>
That's a NULL string in strlen(). Can we see your smb.conf?
-ss
@sergey-senozhatsky it's related to the comment
field.
my smb.conf is already shown above (in this GH issue).
I came up with a patch in cifsd-team/ksmbd-tools#159 -> this fixes the problem for me
On (20/11/30 04:14), Martin Blumenstingl wrote:
in gdb I had to use: set follow-fork-mode child
now I get:
Thread 4.2 "pool" received signal SIGSEGV, Segmentation fault. [Switching to Thread 7797.7811] strlen (s=0x0) at src/string/strlen.c:17 17 for (w = (const void )s; !HASZERO(w); w++); (gdb) bt full
0 strlen (s=0x0) at src/string/strlen.c:17
a = 0x0 w = 0x0
1 0x0040dc3b in __share_entry_data_ctr1 (dce=0x77f11f30, entry=
) at rpc_srvsvc.c:110 share = <optimized out> ret = 0 len = <optimized out>
2 0x00409163 in __ndr_write_array_of_structs (pipe=0x77f113c0, max_entry_nr=
) at rpc.c:564 entry = <optimized out> dce = 0x77f11f30 i = 0
3 0x0040e26d in ndr_write_array_of_structs (pipe=0x77f113c0) at rpc.c:628
dce = 0x77f11f30 max_entry_nr = 3 ret = 0 dce = <optimized out> max_entry_nr = <optimized out> ret = <optimized out>
Does something like this fix it for you?
diff --git a/mountd/rpc_srvsvc.c b/mountd/rpc_srvsvc.c index 6492e9a..f174fb4 100644 --- a/mountd/rpc_srvsvc.c +++ b/mountd/rpc_srvsvc.c @@ -57,9 +57,14 @@ static int __share_entry_size_ctr1(struct ksmbd_dcerpc dce, gpointer entry) struct ksmbd_share share = entry; int sz = 0;
sz = strlen(share->name) * 2;
sz += strlen(share->comment) * 2;
sz += 9 * sizeof(__u32); return sz;
@sergey-senozhatsky it's related to the
comment
field. my smb.conf is already shown above (in this GH issue).I came up with a patch in cifsd-team/ksmbd-tools#159 -> this fixes the problem for me
Oh, I see... but does this actually work for container level 1? Don't we need to have the comment string in the output? I'm not sure that we can just skip it. It might be the case that we need to write empty vstring.
@xdarklight let's fix it like this?
diff --git a/lib/management/share.c b/lib/management/share.c
index b73a9be..ec19963 100644
--- a/lib/management/share.c
+++ b/lib/management/share.c
@@ -576,6 +576,12 @@ static void process_group_kv(gpointer _k, gpointer _v, gpointer user_data)
}
}
+static void fixup_missing_fields(struct ksmbd_share *share)
+{
+ if (!share->comment)
+ share->comment = stdup("");
+}
+
static void init_share_from_group(struct ksmbd_share *share,
struct smbconf_group *group)
{
@@ -599,6 +605,8 @@ static void init_share_from_group(struct ksmbd_share *share,
set_share_flag(share, KSMBD_SHARE_FLAG_PIPE);
g_hash_table_foreach(group->kv, process_group_kv, share);
+
+ fixup_missing_fields(share);
}
int shm_add_new_share(struct smbconf_group *group)
diff --git a/mountd/rpc_srvsvc.c b/mountd/rpc_srvsvc.c
index 6492e9a..08cbca8 100644
--- a/mountd/rpc_srvsvc.c
+++ b/mountd/rpc_srvsvc.c
@@ -58,9 +58,7 @@ static int __share_entry_size_ctr1(struct ksmbd_dcerpc *dce, gpointer entry)
int sz = 0;
sz = strlen(share->name) * 2;
- if (share->comment)
- sz += strlen(share->comment) * 2;
-
+ sz += strlen(share->comment) * 2;
sz += 9 * sizeof(__u32);
return sz;
}
@xdarklight let's fix it like this?
diff --git a/lib/management/share.c b/lib/management/share.c index b73a9be..ec19963 100644 --- a/lib/management/share.c +++ b/lib/management/share.c @@ -576,6 +576,12 @@ static void process_group_kv(gpointer _k, gpointer _v, gpointer user_data) } } +static void fixup_missing_fields(struct ksmbd_share *share) +{ + if (!share->comment) + share->comment = stdup("");
my compiler reports:
:(.text.groups_callback+0x84): undefined reference to `stdup'
if I replace "stdup" with "strdup" then it compiles and works fine for me
with that fixed, feel free to add my: Fixes: 8ec5ca70e8bb87 ("ksmbd-tools: add max_len and actual_len arguments in ndr_write_vstring()") Tested-by: Martin Blumenstingl \martin.blumenstingl@googlemail.com\
Oops, Thanks for fixing a bug... @sergey-senozhatsky Can you send the patch to list ? I will appy it. Thanks!
@xdarklight Thanks very much Martin for your work!
@xdarklight One more help, Could you please check acls work on openWRT ?
Thanks!
On (20/11/30 12:12), Martin Blumenstingl wrote:
[1]@xdarklight let's fix it like this?
diff --git a/lib/management/share.c b/lib/management/share.c index b73a9be..ec19963 100644 --- a/lib/management/share.c +++ b/lib/management/share.c @@ -576,6 +576,12 @@ static void process_group_kv(gpointer _k, gpointer _v, gpointer user_data) } }
+static void fixup_missing_fields(struct ksmbd_share *share) +{
- if (!share->comment)
share->comment = stdup("");
my compiler reports:
:(.text.groups_callback+0x84): undefined reference to `stdup' if I replace "stdup" with "strdup" then it compiles and works fine for me
LOL oops I don't compile test the patches, that would have been no fun.
Since you already took a look at the issue and sent a PR, I don't mind it if you'll pickup these changes (fixup_missing_fields()) and re-spin your patch. Let me know.
-ss
"ksmbd-tools: add max_len and actual_len arguments in ndr_write_vstring()" is rollback by this patch(https://github.com/cifsd-team/ksmbd-tools/commit/fb5e99e0fa735ac3b9b843b9d13d01381b47ee66), So I think that this issue will be clear if you use ksmbd-tools-next.
@xdarklight Martin, if you confirm it, I will release ksmbd/ksmbd-tools 3.3.1 version.
@namjaejeon sorry for the late reply. with ksmbd and ksmbd-tools both in version 3.3.1 "it works again". thanks to everyone who helped!
@xdarklight No problem:) Thanks for your help and work!
Hi @namjaejeon
I am having trouble making 3.3.0 work on OpenWrt (lantiq xrx200, big endian). My steps are:
on the ksmbd server I now get:
the same with "all" debugging enabled:
smb.conf in case it's relevant:
as well as:
any suggestions how to debug this?
Best regards, Martin