diff options
| author | Oleg Nesterov <oleg@redhat.com> | 2013-02-27 20:02:52 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:09 -0500 |
| commit | 7ff6764061ecd4a4ef91db7b8b30aacc6a8573c9 (patch) | |
| tree | 4b98078f0919f60c4ae60190c2cf0b6e495fafaf /kernel | |
| parent | e759a798c639c8bde15c1baa35fb8b451856314b (diff) | |
usermodehelper: cleanup/fix __orderly_poweroff() && argv_free()
__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.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reported-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
Cc: David Howells <dhowells@redhat.com>
Cc: James Morris <james.l.morris@oracle.com>
Cc: hongfeng <hongfeng@marvell.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/sys.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index e10566bee399..81f56445fba9 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
| @@ -2185,11 +2185,6 @@ SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep, | |||
| 2185 | 2185 | ||
| 2186 | char poweroff_cmd[POWEROFF_CMD_PATH_LEN] = "/sbin/poweroff"; | 2186 | char poweroff_cmd[POWEROFF_CMD_PATH_LEN] = "/sbin/poweroff"; |
| 2187 | 2187 | ||
| 2188 | static void argv_cleanup(struct subprocess_info *info) | ||
| 2189 | { | ||
| 2190 | argv_free(info->argv); | ||
| 2191 | } | ||
| 2192 | |||
| 2193 | static int __orderly_poweroff(void) | 2188 | static int __orderly_poweroff(void) |
| 2194 | { | 2189 | { |
| 2195 | int argc; | 2190 | int argc; |
| @@ -2209,9 +2204,8 @@ static int __orderly_poweroff(void) | |||
| 2209 | } | 2204 | } |
| 2210 | 2205 | ||
| 2211 | ret = call_usermodehelper_fns(argv[0], argv, envp, UMH_WAIT_EXEC, | 2206 | ret = call_usermodehelper_fns(argv[0], argv, envp, UMH_WAIT_EXEC, |
| 2212 | NULL, argv_cleanup, NULL); | 2207 | NULL, NULL, NULL); |
| 2213 | if (ret == -ENOMEM) | 2208 | argv_free(argv); |
| 2214 | argv_free(argv); | ||
| 2215 | 2209 | ||
| 2216 | return ret; | 2210 | return ret; |
| 2217 | } | 2211 | } |
