Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 891129 - net-fs/ksmbd-tools-3.4.4 ksmbd init script fails if module is already included in kernel
Summary: net-fs/ksmbd-tools-3.4.4 ksmbd init script fails if module is already include...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Georgy Yakovlev
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-16 15:48 UTC by marius
Modified: 2023-01-19 19:34 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
kernel config (config,117.44 KB, text/plain)
2023-01-19 17:16 UTC, Marius Dinu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description marius 2023-01-16 15:48:22 UTC
net-fs/ksmbd-tools-3.4.4
/etc/init.d/ksmbd contains this:

start_pre() {
        /sbin/modprobe ksmbd || return 1
}

It's wrong. If the module is already in the kernel image, modprobe fails. It probably fails when the module is loaded manually too.
Proposed change:

if [ ! -d /sys/module/ksmbd ]
then /sbin/modprobe ksmbd
fi

Thanks.
Comment 1 Georgy Yakovlev archtester gentoo-dev 2023-01-17 03:03:36 UTC
modprobe should silently exit if module loaded/is in kernel.

 --first-time
           Normally, modprobe will succeed (and do nothing) if told to insert a module which is already present or to
           remove a module which isn't present. This is ideal for simple scripts; however, more complicated scripts often
           want to know whether modprobe really did something: this option makes modprobe fail in the case that it actually
           didn't do anything




# zcat /proc/config.gz | grep EXT4
CONFIG_EXT4_FS=y

^ as you see ext4 is builtin.

# modprobe ext4
# echo $?
0


what's your implementation of modprobe?

mine is:
qfile /sbin/modprobe 
sys-apps/kmod: /sbin/modprobe

so even if ti try modprobing it, it will return 0.

|| exit 1 is to catch situations when it actually failed.

maybe it's actually failing in your case? like same kernel build with it builtin and still a leftover module present from previous build of same version?
Comment 2 Georgy Yakovlev archtester gentoo-dev 2023-01-17 03:05:37 UTC
please also provide output of

modinfo ksmbd


as an example:

modinfo ext4
name:           ext4
filename:       (builtin)
softdep:        pre: crc32c
license:        GPL
file:           fs/ext4/ext4
description:    Fourth Extended Filesystem
author:         Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others
alias:          fs-ext4
alias:          ext3
alias:          fs-ext3
alias:          ext2
alias:          fs-ext2



also it does NOT have directory in /sys/module/ext4, so that check is not correct, at least not for ext4.
Comment 3 Marius Dinu 2023-01-17 07:27:34 UTC
System is Raspberry Pi 3B+, Gentoo arm64 musl openrc.

qfile is not installed

# modprobe -V
kmod version 30
+ZSTD +XZ +ZLIB -LIBCRYPTO -EXPERIMENTAL

# modprobe ksmbd
modprobe: FATAL: Module ksmbd not found in directory /lib/modules/5.15.76_p20221104-raspberrypi-M95D

There is no /lib/modules on my system. I never did "make modules" or "make modules install".
Comment 4 Marius Dinu 2023-01-17 07:29:47 UTC
# which modprobe
/sbin/modprobe

# equery b /sbin/modprobe
 * Searching for /sbin/modprobe ...
sys-apps/kmod-30-r1 (/sbin/modprobe -> ../bin/kmod)
sys-apps/kmod-30-r1 (/bin/kmod)
Comment 5 Georgy Yakovlev archtester gentoo-dev 2023-01-18 21:03:34 UTC
Can you attach kernel config? Is module support enabled at all?
Maybe you can strace modprobe invocation?
I can’t reproduce on kernel where modules are enabled but ksmbd is builtin.
Comment 6 Marius Dinu 2023-01-19 17:16:20 UTC
Created attachment 848835 [details]
kernel config
Comment 7 Marius Dinu 2023-01-19 17:27:29 UTC
No, modules are NOT enabled.

strace -f modprobe ksmbd
execve("/sbin/modprobe", ["modprobe", "ksmbd"], 0x3ffc6937ff0 /* 39 vars */) = 0
set_tid_address(0x3ff91cbce38)          = 22855
brk(NULL)                               = 0x2aaf8110000
brk(0x2aaf8130000)                      = 0x2aaf8130000
mmap(0x2aaf8110000, 65536, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x2aaf8110000
openat(AT_FDCWD, "/etc/ld-musl-aarch64.path", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=75, ...}) = 0
read(3, "/usr/lib/gcc/aarch64-gentoo-linu"..., 75) = 75
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/gcc/aarch64-gentoo-linux-musl/12.2.0/libzstd.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/libzstd.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=633856, ...}) = 0
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 960) = 960
mmap(NULL, 720896, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x3ff91b20000
mmap(0x3ff91bc0000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x90000) = 0x3ff91bc0000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/gcc/aarch64-gentoo-linux-musl/12.2.0/liblzma.so.5", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/liblzma.so.5", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=198912, ...}) = 0
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 960) = 960
mmap(NULL, 327680, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x3ff91ad0000
mmap(0x3ff91b00000, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x20000) = 0x3ff91b00000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/gcc/aarch64-gentoo-linux-musl/12.2.0/libz.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/libz.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=84072, ...}) = 0
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 960) = 960
mmap(NULL, 196608, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x3ff91aa0000
mmap(0x3ff91ac0000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x10000) = 0x3ff91ac0000
close(3)                                = 0
mprotect(0x3ff91b00000, 65536, PROT_READ) = 0
mprotect(0x2aac2380000, 65536, PROT_READ) = 0
uname({sysname="Linux", nodename="RPi3", ...}) = 0
newfstatat(AT_FDCWD, "/etc/modprobe.d", {st_mode=S_IFDIR|0755, st_size=18, ...}, 0) = 0
openat(AT_FDCWD, "/etc/modprobe.d", O_RDONLY|O_LARGEFILE|O_CLOEXEC|O_DIRECTORY) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
getdents64(3, 0x3ff91cbcf08 /* 3 entries */, 2048) = 80
newfstatat(3, "zram.conf", {st_mode=S_IFREG|0644, st_size=27, ...}, 0) = 0
getdents64(3, 0x3ff91cbcf08 /* 0 entries */, 2048) = 0
close(3)                                = 0
newfstatat(AT_FDCWD, "/run/modprobe.d", 0x3ffcc162650, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/local/lib/modprobe.d", 0x3ffcc162650, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/lib/modprobe.d", {st_mode=S_IFDIR|0755, st_size=90, ...}, 0) = 0
openat(AT_FDCWD, "/lib/modprobe.d", O_RDONLY|O_LARGEFILE|O_CLOEXEC|O_DIRECTORY) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
getdents64(3, 0x3ff91b1c338 /* 5 entries */, 2048) = 160
newfstatat(3, "aliases.conf", {st_mode=S_IFREG|0644, st_size=1186, ...}, 0) = 0
newfstatat(3, "i386.conf", {st_mode=S_IFREG|0644, st_size=122, ...}, 0) = 0
newfstatat(3, "usb-load-ehci-first.conf", {st_mode=S_IFREG|0644, st_size=62, ...}, 0) = 0
getdents64(3, 0x3ff91b1c338 /* 0 entries */, 2048) = 0
close(3)                                = 0
openat(AT_FDCWD, "/lib/modprobe.d/aliases.conf", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
read(3, "# Aliases to tell insmod/modprob"..., 1024) = 1024
read(3, "mars6\nalias cipher-11\t\trc62\nalia"..., 1024) = 162
read(3, "", 1024)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "/lib/modprobe.d/i386.conf", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
read(3, "alias parport_lowlevel parport_p"..., 1024) = 122
read(3, "", 1024)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "/lib/modules/5.15.76_p20221104-raspberrypi-M95D/modules.softdep", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/modprobe.d/usb-load-ehci-first.conf", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
read(3, "softdep uhci_hcd pre: ehci_hcd\ns"..., 1024) = 62
read(3, "", 1024)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "/etc/modprobe.d/zram.conf", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
read(3, "options zram num_devices=3\n", 1024) = 27
read(3, "", 1024)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "/proc/cmdline", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
read(3, "coherent_pool=1M 8250.nr_uarts=1"..., 4095) = 234
read(3, "", 3861)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "/lib/modules/5.15.76_p20221104-raspberrypi-M95D/modules.dep.bin", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/modules/5.15.76_p20221104-raspberrypi-M95D/modules.dep.bin", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/modules/5.15.76_p20221104-raspberrypi-M95D/modules.alias.bin", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/modules/5.15.76_p20221104-raspberrypi-M95D/modules.builtin.bin", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/modules/5.15.76_p20221104-raspberrypi-M95D/modules.builtin.alias.bin", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
writev(2, [{iov_base="modprobe: FATAL: ", iov_len=17}, {iov_base="Module ksmbd not found in direct"..., iov_len=84}], 2) = 101
modprobe: FATAL: Module ksmbd not found in directory /lib/modules/5.15.76_p20221104-raspberrypi-M95D
writev(2, [{iov_base="", iov_len=0}, {iov_base=NULL, iov_len=0}], 2) = 0
exit_group(1)                           = ?
+++ exited with 1 +++
Comment 8 Larry the Git Cow gentoo-dev 2023-01-19 17:55:49 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=17932f0fd7e8dc001c6fc26c084f1a2ea6672a16

commit 17932f0fd7e8dc001c6fc26c084f1a2ea6672a16
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2023-01-19 17:51:46 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2023-01-19 17:55:32 +0000

    net-fs/ksmbd-tools: revbump 3.4.6, improve openrc startup/reload
    
    * don't check for modprobe errors, some systems may have specific
     configuration where modprobe returns errors #891129
    * add reload() openrc subcommand to initscript.
    * allow passing arbitrary KSMBD_OPTS for ksmbd.mountd(8)
    * remove incorrect mountd opts.
    
    Thanks-to: Pedro de Oliveira <falsovsky@gmail.com>
    Closes: https://bugs.gentoo.org/891129
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 net-fs/ksmbd-tools/files/ksmbd.confd                      |  3 +++
 net-fs/ksmbd-tools/files/ksmbd.initd                      | 15 ++++++++++++---
 ...mbd-tools-3.4.6.ebuild => ksmbd-tools-3.4.6-r1.ebuild} |  0
 3 files changed, 15 insertions(+), 3 deletions(-)
Comment 9 Georgy Yakovlev archtester gentoo-dev 2023-01-19 18:10:23 UTC
thanks.
after thinking about it I opted to ignore return codes by running 'modprobe -q ksmbd || return 0'

there's little value of checking for error here tbh.
Comment 10 Marius Dinu 2023-01-19 19:34:15 UTC
OK. Thanks.