On Tue, Aug 8, 2017 at 5:09 PM, Luis R. Rodriguez <mcgrof@kernel.org> wrote:> On Wed, Aug 02, 2017 at 02:12:00AM +0200, Luis R. Rodriguez wrote:>> On Fri, Jul 21, 2017 at 03:05:20PM +0100, Matt Redfearn wrote:>> > diff --git a/fs/exec.c b/fs/exec.c>> > index 62175cbcc801..004bb50a01fe 100644>> > --- a/fs/exec.c>> > +++ b/fs/exec.c>> > @@ -1644,6 +1644,9 @@ int search_binary_handler(struct linux_binprm *bprm)>> > if (printable(bprm->buf[0]) && printable(bprm->buf[1]) &&>> > printable(bprm->buf[2]) && printable(bprm->buf[3]))>> > return retval;>> > + /* Game over if we need to load a module to execute modprobe */>> > + if (strcmp(bprm->filename, modprobe_path) == 0)>> > + return retval;>>>> Wouldn't this just break having a binfmt used for modprobe always?>> The place where you put the check is when a system has CONFIG_MODULES> and a first search for built-in handlers yielded no results so it would> not break that for built-in.>> Thinking about this a little further, having an binfmd handler not built-in> seems to really be the issue in this particular case and indeed having one as> modular really just makes no sense as modprobe would be needed.>> Although the alternative patch I suggested still makes sense for a *generic> loop detection complaint/error fix, putting this check in place and bailing> still makes sense as well, but this sort of thing seems to be the type of> system build error userspace could try to pick up on pro-actively, ie you> should not get to the point you boot into this, the build system should somehow> complain about it.>> Cc'ing linux-modules folks to see if perhaps kmod could do something about this> more proactively.

Tracking at runtime with modprobe/libkmod would be really difficult asa module can be loadedfrom different sources. I don't see a reliable way to do that. Onething often forgottenis that due to install rules the user can even add anything as adependency with kmod noteven knowing about (softdep is related, but at least kmod knows whatthe user is trying to doand use it to handle dependencies).

For this particular case, not going through the modprobe helper wouldbe a way to accomplish that sinceyou wouldn't need the corresponding binfmt module to run modprobe.Udev handles moduleloading via libkmod , but the only way to trigger it is via the rulesrather than via a request from kernel.