Re: Bug#1022172: /lib/modprobe.d/50-nfs.conf causes initramfs-tools to stop including sunrpc module for nfs

2022-11-14 Thread Marco d'Itri
On Nov 14, Michael Prokop  wrote:

> FYI: I reported this one as #1024082, looks like the new
> /lib/modprobe.d/50-nfs.conf file is causing quite some problems.
At this point we have established that for good or for worse kmod is 
behaving as documented, so we are down to one of:

- initramfs-tools learns to parse the install directives
- nfs-kernel-server uses udev rules instead

I recommend the second option, which is much more general and robust.

-- 
ciao,
Marco


signature.asc
Description: PGP signature


Re: Bug#1022172: /lib/modprobe.d/50-nfs.conf causes initramfs-tools to stop including sunrpc module for nfs

2022-11-14 Thread Michael Prokop
* Marco d'Itri [Sun Oct 23, 2022 at 12:05:18AM +0200]:
> On Oct 22, Andras Korn  wrote:

> > nfs-kernel-server, for example, the 'install' command wants to invoke 
> > sysctl --pattern, but the busybox sysctl installed in the initramfs by 
> > default doesn't support --pattern. So the package would need to force 
> > initramfs to include the /sbin/sysctl from procps, and maybe also any 
> > pertinent files from /etc/sysctl.d.

> Looks like this is a different problem.

FYI: I reported this one as #1024082, looks like the new
/lib/modprobe.d/50-nfs.conf file is causing quite some problems.

(FTR, this showed up at the Grml live system, see e.g.
https://github.com/grml/grml/issues/193 )

regards
-mika-


signature.asc
Description: PGP signature


Re: Bug#1022172: /lib/modprobe.d/50-nfs.conf causes initramfs-tools to stop including sunrpc module for nfs

2022-10-22 Thread Marco d'Itri
On Oct 22, Andras Korn  wrote:

> Unfortunately the current output can't, as I see it, be parsed to 
> obtain a list of dependencies, because the 'install' commands can be 
> arbitrary command lines with arbitrary side effects, any of which 
> might be loading a module that isn't even named in the command line.
It can be parsed like I suggested, but not reliably.
Still, this would be better than nothing.

> 1. packages that obfuscate module dependencies by supplying 'install' 
> commands for modules that other modules may depend on should be 
> required to include initramfs (and dracut?) hooks that install all 
> dependencies in the initramfs if a depending module is installed in 
> it. This is arguably the correct solution; in the case of 
Yes, but users can legitimately use the install directive themselves.

> nfs-kernel-server, for example, the 'install' command wants to invoke 
> sysctl --pattern, but the busybox sysctl installed in the initramfs by 
> default doesn't support --pattern. So the package would need to force 
> initramfs to include the /sbin/sysctl from procps, and maybe also any 
> pertinent files from /etc/sysctl.d.
Looks like this is a different problem.

> 2. in addition to looking at modprobe output, mkinitramfs should also 
> look at the depends: line in modinfo(8) output to find dependencies, 
> and transitively close the set of modules it includes. This seems like 
> a relatively easy workaround but it's not correct in that it won't 
> cause /sbin/sysctl to be included even if an 'install' command calls 
> it (or whatever other binary and configuration may be needed).
This may be the correct workaround for the modprobe issue, but 
nfs-kernel-server should still have an hook to add /sbin/sysctl to the 
initramfs.

> 3. Debian could forbid including 'install' commands for modules that 
> other modules depend on and that may (frequently?) need to be included 
> in an initramfs (requiring, for example, the kind of udev rule Marco 
> proposed).
I still suspect that the udev rule would be more elegant than the 
modprobe.d install directive, but this would still not solve the case of 
users using the install directive.
So maybe initramfs-tools should still be changed to use modinfo.

-- 
ciao,
Marco


signature.asc
Description: PGP signature


Re: Bug#1022172: /lib/modprobe.d/50-nfs.conf causes initramfs-tools to stop including sunrpc module for nfs

2022-10-22 Thread Andras Korn
On Fri, Oct 21, 2022 at 03:11:27PM +0200, Marco d'Itri wrote:

Hi,

> > I thought --ignore-install was completely broken, but no, because without 
> > it, the output contains *more* "install" lines:
> What you are actually seeing is that --ignore-install is applied only to 
> the nfs module (the one which you have requested to load) but not to its 
> own dependencies:

Yes, and this is in fact in agreement with the documentation:

 -i, --ignore-install, --ignore-remove
This option causes modprobe to ignore install and remove commands in the 
configuration file (if any) *for the module specified on the command line (any 
dependent modules are still subject to commands set for them in the 
configuration file)*.

This doesn't look like useful behaviour to me, but I don't pretend to be aware 
of all use-cases (the only one I *am* aware of is the one in mkinitramfs, which 
this behaviour breaks).

Unfortunately the current output can't, as I see it, be parsed to obtain a list 
of dependencies, because the 'install' commands can be arbitrary command lines 
with arbitrary side effects, any of which might be loading a module that isn't 
even named in the command line.

> No matter what happens to --ignore-install I suggest that  nfs-kernel-server 
> will replace the modprobe configuration with some udev  rules like this one 
> (untested):
> 
> ACTION=="add", SUBSYSTEM=="module", KERNEL=="sunrpc", RUN+="/sbin/sysctl -q 
> --pattern sunrpc --system"

I see several ways forward:

1. packages that obfuscate module dependencies by supplying 'install' commands 
for modules that other modules may depend on should be required to include 
initramfs (and dracut?) hooks that install all dependencies in the initramfs if 
a depending module is installed in it. This is arguably the correct solution; 
in the case of nfs-kernel-server, for example, the 'install' command wants to 
invoke sysctl --pattern, but the busybox sysctl installed in the initramfs by 
default doesn't support --pattern. So the package would need to force initramfs 
to include the /sbin/sysctl from procps, and maybe also any pertinent files 
from /etc/sysctl.d.

2. in addition to looking at modprobe output, mkinitramfs should also look at 
the depends: line in modinfo(8) output to find dependencies, and transitively 
close the set of modules it includes. This seems like a relatively easy 
workaround but it's not correct in that it won't cause /sbin/sysctl to be 
included even if an 'install' command calls it (or whatever other binary and 
configuration may be needed).

3. Debian could forbid including 'install' commands for modules that other 
modules depend on and that may (frequently?) need to be included in an 
initramfs (requiring, for example, the kind of udev rule Marco proposed).

AndrĂ¡s

-- 
 The bride got a new name and a dress.



Re: Bug#1022172: /lib/modprobe.d/50-nfs.conf causes initramfs-tools to stop including sunrpc module for nfs

2022-10-21 Thread Marco d'Itri
On Oct 21, Andras Korn  wrote:

> I thought --ignore-install was completely broken, but no, because without it, 
> the output contains *more* "install" lines:
What you are actually seeing is that --ignore-install is applied only to 
the nfs module (the one which you have requested to load) but not to its 
own dependencies:

diff -U 0 <(modprobe --all --set-version="6.0.0-1-amd64" --ignore-install 
--quiet --show-depends nfs) <(modprobe --all --set-version="6.0.0-1-amd64" 
--quiet --show-depends nfs)

I am not sure if this is a bug or a feature, so this should be discussed 
with the upstream maintainer.

So the possible solutions are:
- the semantics of --ignore-install are changed upstream (this may take 
  some time)
- initramfs-tools learns to parse the install directives
- nfs-kernel-server uses a different design

No matter what happens to --ignore-install I suggest that 
nfs-kernel-server will replace the modprobe configuration with some udev 
rules like this one (untested):

ACTION=="add", SUBSYSTEM=="module", KERNEL=="sunrpc", \
  RUN+="/sbin/sysctl -q --pattern sunrpc --system"

-- 
ciao,
Marco


signature.asc
Description: PGP signature