Re: [PATCH 3/3] init/Kconfig: Add option to set modprobe command

From: Lucas De Marchi
Date: Sat May 11 2013 - 16:10:57 EST


On Fri, May 10, 2013 at 2:10 PM, Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> On 05/10, Lucas De Marchi wrote:
>>
>> On Fri, May 10, 2013 at 12:36 PM, Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
>> > Well, personally I think it would be better to use kasprintf(), see the
>> > patch I sent (it is actually wrong, needs kfree(args) before return).
>> >
>> > Or. How about the patch below? It should be split into 2 changes:
>> >
>> > 1. Introduce __argv_split(). It can have more callers, for
>> > example do_coredump() and ftrace_function_filter_re()
>> > can use it to avoid kstrndup() + kfree().
>> >
>> > 2. Change call_modprobe() to use kasprintf() + __argv_split().
>>
>> Seems better. In your previous version I was troubled about
>> duplicating the string twice.
>
> Oh, compared to other things we need to do this is nothing ;)
>
> But to me it just looks better this way.
>
>> Now it's weird freeing a
>> user-allocated-string,
>
> This is fine, the "weird" thing is that it frees the string even if
> fails. But this simplifies the usage.
>
>> but I think it's a good tradeoff and covers other use cases as you
>> pointed out as well.
>
> OK, good.
>
>> Ok. I'll give it a try.
>
> Please wait a bit, I'll send v2. See below.
>
>> > -char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe";
>> > +char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe -q --";
>
> No. This is incompatible change, we shouldn't do this.

But then what option do we have? I don't think any distro writing to
sysctl would stop working without "-q --". And if they are indeed
using this during boot, I think they would be much safer to just
change to set this at compile time like this patch is trying to do.
Otherwise, the options are really ugly:

1) always give "-q --" by putting this on the kasprintf() call:
kasprintf(GFP_KERNEL, "%s -q -- %s", modprobe_command, module_name).
2) provide a proc_dostring_modprobe, which ensures "-q --" is appended
to the provided path

(2) is ugly as (1), but would apply just to not break current setups
and if set in Kconfig it's "-q --"-free.


>
>> > + args = kasprintf(GFP_KERNEL, "%s %s", modprobe_path, module_name);
>
> This should be kasprintf("%s -q -- %s").
>
> And it needs a comment to explain that we are safe even if we race
> with proc_dostring().

ok

Lucas De Marchi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/