public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Lucas De Marchi <lucas.de.marchi@gmail.com>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 3/3] init/Kconfig: Add option to set modprobe command
Date: Fri, 10 May 2013 19:10:54 +0200	[thread overview]
Message-ID: <20130510171054.GA27479@redhat.com> (raw)
In-Reply-To: <CAKi4VAJPXgiik9CGrVyk7cCvz-1913p1KL8tn5FvxH4w0r27bg@mail.gmail.com>

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.


  reply	other threads:[~2013-05-10 17:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-10  4:15 [PATCH 1/3] argv_split(): Allow extra params Lucas De Marchi
2013-05-10  4:15 ` [PATCH 2/3] kmod: Use argv_split(), passing module as extra param Lucas De Marchi
2013-05-10  4:15 ` [PATCH 3/3] init/Kconfig: Add option to set modprobe command Lucas De Marchi
2013-05-10 12:58   ` Oleg Nesterov
2013-05-10 13:12     ` Oleg Nesterov
2013-05-10 13:15     ` Lucas De Marchi
2013-05-10 15:36       ` Oleg Nesterov
2013-05-10 16:03         ` Lucas De Marchi
2013-05-10 17:10           ` Oleg Nesterov [this message]
2013-05-10 17:35             ` Oleg Nesterov
2013-05-10 17:44               ` Lucas De Marchi
2013-05-13 13:59                 ` Oleg Nesterov
2013-05-11 20:10             ` Lucas De Marchi
2013-05-13 14:16               ` Oleg Nesterov
2013-05-13 14:35                 ` [RFC] teach argv_split() to ignore the spaces surrounded by \e Oleg Nesterov
2013-05-13 16:06                   ` Colin Walters
2013-05-13 17:13                     ` Oleg Nesterov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130510171054.GA27479@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucas.de.marchi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox