Skip to content

Commit 19614ef

Browse files
jmberg-intelgregkh
authored andcommitted
um: chan_user: Fix winch_tramp() return value
commit 57ae0b6 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: ccf1236 ("um: fix error return code in winch_tramp()") Reported-and-tested-by: Nathan Chancellor <[email protected]> Signed-off-by: Johannes Berg <[email protected]> Cc: [email protected] Signed-off-by: Richard Weinberger <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6107747 commit 19614ef

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

arch/um/drivers/chan_user.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out,
220220
unsigned long *stack_out)
221221
{
222222
struct winch_data data;
223-
int fds[2], n, err;
223+
int fds[2], n, err, pid;
224224
char c;
225225

226226
err = os_pipe(fds, 1, 1);
@@ -238,8 +238,9 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out,
238238
* problem with /dev/net/tun, which if held open by this
239239
* thread, prevents the TUN/TAP device from being reused.
240240
*/
241-
err = run_helper_thread(winch_thread, &data, CLONE_FILES, stack_out);
242-
if (err < 0) {
241+
pid = run_helper_thread(winch_thread, &data, CLONE_FILES, stack_out);
242+
if (pid < 0) {
243+
err = pid;
243244
printk(UM_KERN_ERR "fork of winch_thread failed - errno = %d\n",
244245
-err);
245246
goto out_close;
@@ -263,7 +264,7 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out,
263264
goto out_close;
264265
}
265266

266-
return err;
267+
return pid;
267268

268269
out_close:
269270
close(fds[1]);

0 commit comments

Comments
 (0)