Skip to content

Commit

Permalink
usermodehelper: cleanup/fix __orderly_poweroff() && argv_free()
Browse files Browse the repository at this point in the history
__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 6c0c0d4 "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 <[email protected]>
Reported-by: Lucas De Marchi <[email protected]>
Cc: David Howells <[email protected]>
Cc: James Morris <[email protected]>
Cc: hongfeng <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
oleg-nesterov authored and torvalds committed Feb 28, 2013
1 parent e759a79 commit 7ff6764
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions kernel/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -2185,11 +2185,6 @@ SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep,

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;
Expand All @@ -2209,9 +2204,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;
}
Expand Down

0 comments on commit 7ff6764

Please sign in to comment.