mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
umh: fix memory leak on execve failure
[ Upstream commitdb803036ad] If a UMH process created by fork_usermode_blob() fails to execute, a pair of struct file allocated by umh_pipe_setup() will leak. Under normal conditions, the caller (like bpfilter) needs to manage the lifetime of the UMH and its two pipes. But when fork_usermode_blob() fails, the caller doesn't really have a way to know what needs to be done. It seems better to do the cleanup ourselves in this case. Fixes:449325b52b("umh: introduce fork_usermode_blob() helper") Signed-off-by: Vincent Minet <v.minet@criteo.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
44ee727013
commit
2fffdf4dde
@@ -475,6 +475,12 @@ static void umh_clean_and_save_pid(struct subprocess_info *info)
|
||||
{
|
||||
struct umh_info *umh_info = info->data;
|
||||
|
||||
/* cleanup if umh_pipe_setup() was successful but exec failed */
|
||||
if (info->pid && info->retval) {
|
||||
fput(umh_info->pipe_to_umh);
|
||||
fput(umh_info->pipe_from_umh);
|
||||
}
|
||||
|
||||
argv_free(info->argv);
|
||||
umh_info->pid = info->pid;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user