core_pattern: fix up a few miscelaneous bugs
Subsystems (2)
PATCH 3/3 core_pattern: fix up a few miscelaneous bugs
Hey
This patch fixes up a few bugs I found while testing my other work.
Specifically:
1) Fixes call_usermodehelper_pipe to not wait for program exit on the user mode helper process. Since this context fill the pipe. The user mode helper, if it reads stdin, will block waiting for the pipe to have data on it, and we will wait forever for the usermodehelper to exit. Changed this to wait only for a successful exec.
2) Fixes do_coredump to detect a crash in the user mode helper process and abort the attempt to recursively dump core to another copy of the helper process, potentially ad-infinitum.
Thanks & Regards
Neil
fs/exec.c | 14 +++++++++++++- kernel/kmod.c | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-)
fs/exec.c +13 -1
@@ -1791,12 +1791,24 @@ goto fail_unlock;if (ispipe) { - core_limit =RLIM_INFINITY ; helper_argv =argv_split (GFP_KERNEL , corename+1 , &helper_argc);/* Terminate the string before the first option */ delimit =strchr (corename,' ' );if (delimit) *delimit ='\0' ; + delimit =strrchr (helper_argv[0 ],'/' ); +if (delimit) + delimit++; +else + delimit = helper_argv[0 ]; +if (!strcmp (delimit, current->comm)) + { +printk (KERN_NOTICE "Recursive core dump detected, Aborting\n" ); + goto fail_unlock; + } + + core_limit =RLIM_INFINITY ; +/* SIGPIPE can happen, but it's just never processed */ if (call_usermodehelper_pipe (corename+1 , helper_argv,NULL , &file)) { printk(KERN_INFO "Core dump to %s pipe failed\n",
kernel/kmod.c +1 -1
@@ -505,7 +505,7 @@if (ret <0 ) goto out; -return call_usermodehelper_exec (sub_info,1 ); +return call_usermodehelper_exec (sub_info,UMH_WAIT_EXEC ); out:call_usermodehelper_freeinfo (sub_info);
Signature · 8 lines
/*************************************************** *Neil Horman *Software Engineer *Red Hat, Inc. *[email protected] *gpg keyid: 1024D / 0x92A74FA1 *http://pgp.mit.edu ***************************************************/
Neil Horman wrote:
[...]
fs/exec.c line 1800
Quoted 2 lines
fs/exec.c +2
-0+ delimit =strrchr (helper_argv[0 ],'/' ); +if (delimit)
Trailing space.
fs/exec.c line 1805
Quoted 5 lines
fs/exec.c +5
-0+ delimit++; + else + delimit = helper_argv[0 ]; +if (!strcmp (delimit, current->comm)) + {
Trailing space, and '{' should be after '...comm))'.
Eugene