From: Oleg Nesterov <oleg@redhat.com>
To: Lucas De Marchi <lucas.demarchi@profusion.mobi>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, David Howells <dhowells@redhat.com>,
James Morris <james.l.morris@oracle.com>,
hongfeng <hongfeng@marvell.com>
Subject: [PATCH 1/1] usermodehelper: cleanup/fix __orderly_poweroff() && argv_free()
Date: Mon, 25 Feb 2013 18:11:14 +0100 [thread overview]
Message-ID: <20130225171114.GC1024@redhat.com> (raw)
In-Reply-To: <20130225171014.GB1024@redhat.com>
__orderly_poweroff() does argv_free() if call_usermodehelper_fns()
returns -ENOMEM. As Lucas pointed out, this can be wrong if -ENOMEM
was not triggered by the failing call_usermodehelper_setup(), in this
case both __orderly_poweroff() and argv_cleanup() can do kfree().
Kill argv_cleanup() and change __orderly_poweroff() to call argv_free()
unconditionally like do_coredump() does. This info->cleanup() is not
needed (and wrong) since 6c0c0d4d "fix bug in orderly_poweroff() which
did the UMH_NO_WAIT => UMH_WAIT_EXEC change, we can rely on the fact
that CLONE_VFORK can't return until do_execve() succeeds/fails.
Reported-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
--- x/kernel/sys.c
+++ x/kernel/sys.c
@@ -2184,11 +2184,6 @@ SYSCALL_DEFINE3(getcpu, unsigned __user
char poweroff_cmd[POWEROFF_CMD_PATH_LEN] = "/sbin/poweroff";
-static void argv_cleanup(struct subprocess_info *info)
-{
- argv_free(info->argv);
-}
-
static int __orderly_poweroff(void)
{
int argc;
@@ -2208,9 +2203,8 @@ static int __orderly_poweroff(void)
}
ret = call_usermodehelper_fns(argv[0], argv, envp, UMH_WAIT_EXEC,
- NULL, argv_cleanup, NULL);
- if (ret == -ENOMEM)
- argv_free(argv);
+ NULL, NULL, NULL);
+ argv_free(argv);
return ret;
}
prev parent reply other threads:[~2013-02-25 17:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-25 14:25 [PATCH] usermodehelper: Fix -ENOMEM return logic Lucas De Marchi
2013-02-25 15:05 ` David Howells
2013-02-25 16:51 ` Oleg Nesterov
2013-02-25 16:06 ` Oleg Nesterov
2013-02-25 17:38 ` Lucas De Marchi
2013-02-25 18:08 ` Oleg Nesterov
2013-03-07 2:05 ` Lucas De Marchi
2013-03-07 19:37 ` Oleg Nesterov
2013-03-07 19:47 ` Lucas De Marchi
2013-03-07 20:07 ` Oleg Nesterov
2013-03-07 21:35 ` Lucas De Marchi
2013-02-25 17:10 ` [PATCH 0/1] usermodehelper: cleanup/fix __orderly_poweroff() && argv_free() Oleg Nesterov
2013-02-25 17:11 ` Oleg Nesterov [this message]
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=20130225171114.GC1024@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=hongfeng@marvell.com \
--cc=james.l.morris@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lucas.demarchi@profusion.mobi \
/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