[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] modutils: support finit_module syscall
From:       Thomas Petazzoni <thomas.petazzoni () free-electrons ! com>
Date:       2017-03-15 13:20:35
Message-ID: 20170315142035.0f3c76a2 () free-electrons ! com
[Download RAW message or body]

Hello,

On Tue, 13 Sep 2016 17:06:00 -0400, Mike Frysinger wrote:

> +	/*
> +	 * First we try finit_module if available.  Some kernels are configured
> +	 * to only allow loading of modules off of secure storage (like a read-
> +	 * only rootfs) which needs the finit_module call.  If it fails, we fall
> +	 * back to normal module loading to support compressed modules.
> +	 */
> +# ifdef __NR_finit_module
> +	{
> +		int fd = open(filename, O_RDONLY | O_CLOEXEC);
> +		if (fd >= 0) {
> +			rc = finit_module(fd, options, 0) != 0;
> +			close(fd);
> +			if (rc == 0)
> +				return rc;
> +		}
> +	}
> +# endif

This change causes a fairly confusing behavior with some kernel
modules. Indeed, I was testing the mtd_nandbiterrs.ko kernel module,
that performs some MTD tests. This module has an init function that
*always* fails, because the init function is the one running the test,
and we want to be able to run the test several times. Having the init
function always failing forces the kernel to cancel the module loading,
so we can load it several times.

With your finit_module() what happens is that:

 - finit_module() is tried. It loads the modules, runs the init
   function, which runs fine, but returns -EIO.

 - Since busybox insmod believes that finit_module() has failed, it
   moves on and falls back to init_module().

Therefore, a single "insmod mtd_nandbiterrs.ko" leads to the module
being loaded twice, and its test being executed twice, which is very
confusing.

I am not entirely sure what condition should be used to determine if
finit_module() failed because the module init function was executed but
failed (in which case we don't want to fall back on init module) from
the cases where finit_module() failed because the module was
compressed, or any other issue not related to the module init function
failing.

Ideas?

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic