Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp445284iog; Mon, 13 Jun 2022 06:08:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyX6KdrO5fd1l1NHd2K3SchAbQ1jiNWcAg33YpKdhG80Tdii+XpRGqmC2VRzWs/WhrqLVgJ X-Received: by 2002:a05:6402:11d1:b0:433:4a09:3f49 with SMTP id j17-20020a05640211d100b004334a093f49mr20093438edw.357.1655125599934; Mon, 13 Jun 2022 06:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125599; cv=none; d=google.com; s=arc-20160816; b=bsHwQt1CG8zlbKb+qd7T68yL+B+hOk+PNa1ySvf+8wPnP+S3CAU+3HN/zolOJ2kTwG lPGxt6oLXsp1Z+aMw6aNKGm0gfaiWOsbzj+8lqF4DLKDeMubf3UL4ltPKbgid3/2/fne VWBuM75T/KE0KpDMWHTBtfM+sjJeqiF9MzGd7iyclLUEiNPjl9Z0RDJ6r8glXhIT1Kcg ru0NIBHRPGjwyXM/x5Hhkk3as55hcgxfk52MY8iIi0sDdNUNj9796zACdnazmDRLZXpE yUPIjQavB8OnMFXAoOthzujfv7/xvf5wfAAn5FYpqzvAdu3n3iAbKyCvKm8GyaL06717 EE4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=A0U3vNiXdz119LCD7+uQHzVZNT0uMzIdqmKJ1ETsO9o=; b=A90GixcQn3sc9ySmYnIybutPzZ3Cd4fSDOmdcAfl5iIq34mo8e4KxZE/pEkHK47BOJ t0mbYmBYLeg9K+HRFi3QEOSTiFEaMxzUE3y3yMe5Br4Y2uQC9D6qoL8q9b7Y85crCS0w wpoGFlBzV5l0pvbsWflG0ZBcZSXXdSxuhcXSJQm/LM8A6CocROVk5vffzyaKYCUVRMk5 Asz+jxS0oTxZuND17u4xx10+/YBswOrVVsKcfuvdZpKvMkkB/ed6OHKiESijk5fWIAG+ bn6PGtsl0NIjr3AE3SUijny77GnKXUWgfVD/NvvhYJZvy8BG2XaOqLxjEcYccDOoLLIm IRwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mAcmotJJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr3-20020a1709073f8300b00715e127b690si5114957ejc.855.2022.06.13.06.06.07; Mon, 13 Jun 2022 06:06:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mAcmotJJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348077AbiFMK4C (ORCPT + 99 others); Mon, 13 Jun 2022 06:56:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347786AbiFMKwd (ORCPT ); Mon, 13 Jun 2022 06:52:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 098D12458D; Mon, 13 Jun 2022 03:27:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5ED2760EF8; Mon, 13 Jun 2022 10:27:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70F45C34114; Mon, 13 Jun 2022 10:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116050; bh=yBMfBMsenoejD3SJApeyaIR+DRPPPmmkDIHXMUaPI6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mAcmotJJowfnTxOygy7VS9oQ5XKBrXDTjudjW1zSlBCTklyv8IF9Rm6dX12rj99/a lvpCcKUXKro+6r8ilGSrSsTWf81MXRPb7UP6aJGXu99fGoSo4k7bVy/ffXSEBlVNTK JvpDccHY/hZL5pVfBryy5rUo6aQAa752FAdwn9uk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Richard Weinberger , Nathan Chancellor Subject: [PATCH 4.14 123/218] um: chan_user: Fix winch_tramp() return value Date: Mon, 13 Jun 2022 12:09:41 +0200 Message-Id: <20220613094924.303302204@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094908.257446132@linuxfoundation.org> References: <20220613094908.257446132@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg commit 57ae0b67b747031bc41fb44643aa5344ab58607e 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: ccf1236ecac4 ("um: fix error return code in winch_tramp()") Reported-and-tested-by: Nathan Chancellor Signed-off-by: Johannes Berg Cc: stable@vger.kernel.org Signed-off-by: Richard Weinberger Signed-off-by: Greg Kroah-Hartman --- arch/um/drivers/chan_user.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/arch/um/drivers/chan_user.c +++ b/arch/um/drivers/chan_user.c @@ -220,7 +220,7 @@ static int winch_tramp(int fd, struct tt unsigned long *stack_out) { struct winch_data data; - int fds[2], n, err; + int fds[2], n, err, pid; char c; err = os_pipe(fds, 1, 1); @@ -238,8 +238,9 @@ static int winch_tramp(int fd, struct tt * problem with /dev/net/tun, which if held open by this * thread, prevents the TUN/TAP device from being reused. */ - err = run_helper_thread(winch_thread, &data, CLONE_FILES, stack_out); - if (err < 0) { + pid = run_helper_thread(winch_thread, &data, CLONE_FILES, stack_out); + if (pid < 0) { + err = pid; printk(UM_KERN_ERR "fork of winch_thread failed - errno = %d\n", -err); goto out_close; @@ -263,7 +264,7 @@ static int winch_tramp(int fd, struct tt goto out_close; } - return err; + return pid; out_close: close(fds[1]);