Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2175903iof; Tue, 7 Jun 2022 22:14:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaJq8pohCoeBbHFRz4pN82q1ornjqL959lDhh29ZR16Mnxv02rAip4/4vJfxjkwqbuR6K8 X-Received: by 2002:a63:fb0f:0:b0:3fa:f1d2:140 with SMTP id o15-20020a63fb0f000000b003faf1d20140mr28235630pgh.487.1654665254708; Tue, 07 Jun 2022 22:14:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665254; cv=none; d=google.com; s=arc-20160816; b=fNDrCgU0bJEWD3jlkHghfjsqpSPbuaNzqgye9l++H+vdWQmfN8DKcxLBRWt6RmCiUg FxdZ9+KVuykuj0CYk+PQuXsZmvTwM0jqdGIfWNZaD4KtT5UTxr9+RMQLk5AoyVJwBMR9 vu/aFPTfZWvlFjC9bDWwmuxVJFmdRr1BrwbWrFbIzWSDuQJOrn0eiwaK28n4kNJpUfkh 3ZgMZC8DDwThaWqj+GvjzuCBOdt8qiQ3Zr1bwmYVu+ZpnzNmqesd8Ja+H0vqjftijhLe /b0bGXHCFK+8GaSIvhIpu+i33tFl3QrjHJT0IBlT8MKNTedc1vFLVUYjUI/EHoKYhurM Ds0A== 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=Zix3xffgn53f9nfNtvNUUag51RJocvgVPji9RULblaX37WpZpjBQUxq4pjlOa/AC6M Js/g+Id6hBcFUTHJTpEDW2KZvugm7rfsG1r4KnrTDpe48phPXlMUBB/x7kp/3t04gxIy lw+yblrDEk3Ci7eayxsUuPqBSH1TbGvnqf186KamtHFQRACva/E30PUoAhjIwy1q/W+b 7QZmmssCPtipmK9Dz0eMRN7XKlaK4bfrRjzhlmi1FpnxZp370SYi7MFs64K2xiEwo7fZ DDmKzDDdabMDm+Etm6dmtJoUqkg2zmFOQMBrjROEt0U1q9ZE/fLvW62bbg/EmaQ6RH5s HjFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pzp7KA7i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j9-20020a056a00130900b0051872773159si27786095pfu.228.2022.06.07.22.14.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:14:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pzp7KA7i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4A65241640B; Tue, 7 Jun 2022 21:44:15 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358174AbiFGUJf (ORCPT + 99 others); Tue, 7 Jun 2022 16:09:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355958AbiFGTRr (ORCPT ); Tue, 7 Jun 2022 15:17:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FCA045054; Tue, 7 Jun 2022 11:08:02 -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 9408D61926; Tue, 7 Jun 2022 18:07:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0209C385A5; Tue, 7 Jun 2022 18:07:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654625278; bh=yBMfBMsenoejD3SJApeyaIR+DRPPPmmkDIHXMUaPI6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pzp7KA7iENRTQvEYreeG/KnuZqV0NR4wVy2KOexOhPRY7ux5DKygerrTwphI8bnUE uWdvikMgHmuuKycVbe4sFSJ3bACXihUr+aN2+eDLIJuW/HDFIg9n5du5y73ll0B3vd /HFwFb4LBlXTTAknwkkizRrho3IUQYEeqm49NmHc= 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 5.15 612/667] um: chan_user: Fix winch_tramp() return value Date: Tue, 7 Jun 2022 19:04:37 +0200 Message-Id: <20220607164953.030012320@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164934.766888869@linuxfoundation.org> References: <20220607164934.766888869@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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]);