Commit 111dbe0c8a21dffa473239861be47ebc87f593b3
Committed by
Linus Torvalds
1 parent
3e26a423e7
Exists in
master
and in
39 other branches
[PATCH] Fix ____call_usermodehelper errors being silently ignored
If ____call_usermodehelper fails, we're not interested in the child process' exit value, but the real error, so let's stop wait_for_helper from overwriting it in that case. Issue discovered by Benedikt Böhm while working on a Linux-VServer usermode helper. Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de> Cc: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 11 additions and 1 deletions Side-by-side Diff
kernel/kmod.c
... | ... | @@ -176,6 +176,8 @@ |
176 | 176 | if (pid < 0) { |
177 | 177 | sub_info->retval = pid; |
178 | 178 | } else { |
179 | + int ret; | |
180 | + | |
179 | 181 | /* |
180 | 182 | * Normally it is bogus to call wait4() from in-kernel because |
181 | 183 | * wait4() wants to write the exit code to a userspace address. |
... | ... | @@ -185,7 +187,15 @@ |
185 | 187 | * |
186 | 188 | * Thus the __user pointer cast is valid here. |
187 | 189 | */ |
188 | - sys_wait4(pid, (int __user *) &sub_info->retval, 0, NULL); | |
190 | + sys_wait4(pid, (int __user *)&ret, 0, NULL); | |
191 | + | |
192 | + /* | |
193 | + * If ret is 0, either ____call_usermodehelper failed and the | |
194 | + * real error code is already in sub_info->retval or | |
195 | + * sub_info->retval is 0 anyway, so don't mess with it then. | |
196 | + */ | |
197 | + if (ret) | |
198 | + sub_info->retval = ret; | |
189 | 199 | } |
190 | 200 | |
191 | 201 | complete(sub_info->complete); |