lkml.org 
[lkml]   [2013]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/3] init/Kconfig: Add option to set modprobe command
On 05/10, Lucas De Marchi wrote:
>
> On Fri, May 10, 2013 at 12:36 PM, Oleg Nesterov <oleg@redhat.com> 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.

> > + 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().

Oleg.



\
 
 \ /
  Last update: 2013-05-10 19:41    [W:0.180 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site