提交 bae6e48f 编写于 作者: J Johannes Berg 提交者: Zheng Zengkai

um: chan_user: Fix winch_tramp() return value

stable inclusion
from stable-v5.10.121
commit 7f8fd5dd43cd7306bb8fc519c13bcf1df7de3783
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6CQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=7f8fd5dd43cd7306bb8fc519c13bcf1df7de3783

--------------------------------

commit 57ae0b67 upstream.

The previous fix here was only partially correct, it did
result in returning a proper error value in case of error,
but it also clobbered the pid that we need to return from
this function (not just zero for success).

As a result, it returned 0 here, but later this is treated
as a pid and used to kill the process, but since it's now
0 we kill(0, SIGKILL), which makes UML kill itself rather
than just the helper thread.

Fix that and make it more obvious by using a separate
variable for the pid.

Fixes: ccf1236e ("um: fix error return code in winch_tramp()")
Reported-and-tested-by: NNathan Chancellor <nathan@kernel.org>
Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: NRichard Weinberger <richard@nod.at>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 77c87f18
...@@ -220,7 +220,7 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out, ...@@ -220,7 +220,7 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out,
unsigned long *stack_out) unsigned long *stack_out)
{ {
struct winch_data data; struct winch_data data;
int fds[2], n, err; int fds[2], n, err, pid;
char c; char c;
err = os_pipe(fds, 1, 1); err = os_pipe(fds, 1, 1);
...@@ -238,8 +238,9 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out, ...@@ -238,8 +238,9 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out,
* problem with /dev/net/tun, which if held open by this * problem with /dev/net/tun, which if held open by this
* thread, prevents the TUN/TAP device from being reused. * thread, prevents the TUN/TAP device from being reused.
*/ */
err = run_helper_thread(winch_thread, &data, CLONE_FILES, stack_out); pid = run_helper_thread(winch_thread, &data, CLONE_FILES, stack_out);
if (err < 0) { if (pid < 0) {
err = pid;
printk(UM_KERN_ERR "fork of winch_thread failed - errno = %d\n", printk(UM_KERN_ERR "fork of winch_thread failed - errno = %d\n",
-err); -err);
goto out_close; goto out_close;
...@@ -263,7 +264,7 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out, ...@@ -263,7 +264,7 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out,
goto out_close; goto out_close;
} }
return err; return pid;
out_close: out_close:
close(fds[1]); close(fds[1]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册