[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130510171054.GA27479@redhat.com>
Date: Fri, 10 May 2013 19:10:54 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Lucas De Marchi <lucas.de.marchi@...il.com>
Cc: lkml <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [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@...hat.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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists