Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1242435imw; Tue, 5 Jul 2022 06:18:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u5nZLKNvvbnBB0A8VsAtMbwuuYcw0zrm5WPDG2zBC0k2Rwd6wQ4/uMRDBEiaVlIeD/E1xX X-Received: by 2002:a17:90a:890e:b0:1ef:85d5:515d with SMTP id u14-20020a17090a890e00b001ef85d5515dmr14556082pjn.109.1657027122319; Tue, 05 Jul 2022 06:18:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657027122; cv=none; d=google.com; s=arc-20160816; b=n9MQbBRSnV3/coYiOrRPcja2DElBXcVNPBaUnXrY1cEQsWcdcDoljwHPCKG869B5VQ JWsdaTZy+cHXa1ZeKmbkjVEUhdtiRCgcNUt/apGDPad2odCHNKSWua13ojUG/rogwDVb o9kPjkTWjQZrxHCUScSBBU2BYyAWlTU/u1RUTKOvohtg2rGSH5+++v/FPjLDZWN6CSje +v2naQ4QjwjznK8+qmU3S4W8CV5wV/obvdhDKuRzOonunYQFZ4iccNzQ8rlG+ssaH8yk JhigR5xa/DmkL1aoH0kXTR+uO9V6bV85YtkjxNE1iROw6986XUAF4C1L0fDDgP8T+0O0 lk9g== 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=8mhSWTMXRNO0F6rR0+p+4FzbfK66agM4E33gi+dn1TM=; b=SQmIhfYpJYhm6kcpGI9c6PtFgopCg3nTUAnJRZX6oU5shES+TlwG+mWIj/FgJ4YEXm ddpjWQCmWMxW7i2GglykaDZ8Dt10Vh7DRzGFrrEaojlkInTeZSftZwtHHGeClr8umqXQ DDtSvwqqthU9kwxZ5ILyhPlpmUxMaCvCQh8RRHzQA4dmjZDOC0110J0hyRWYH3APXliU OUCPsprEbtXzbeTLNgCchEVAMg+VBpFHBfFBfa4CWm4S3krx/HU079y4Bu/EiHXzE5WD r/1DGskjempiY9bzheDftCTUVpC1TDFqj9JZYGU+GI7pNIO9WX0319uYZzn4O+jdKVlq SG2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mLsRrjUX; 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 ls16-20020a17090b351000b001ef92a92b72si5095692pjb.17.2022.07.05.06.18.30; Tue, 05 Jul 2022 06:18:42 -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=mLsRrjUX; 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 S233589AbiGEMEe (ORCPT + 99 others); Tue, 5 Jul 2022 08:04:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233453AbiGEMCq (ORCPT ); Tue, 5 Jul 2022 08:02:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61D1C17E21; Tue, 5 Jul 2022 05:02:45 -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 ams.source.kernel.org (Postfix) with ESMTPS id 10B37B817D3; Tue, 5 Jul 2022 12:02:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74C28C341C7; Tue, 5 Jul 2022 12:02:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657022562; bh=RBN1VrK3jAHNYDEBxvR5VsJAYA7eBYhPYQO6FEJg6Ik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mLsRrjUX5CMWqKo3IT+65JxshvcWUC1dtjvxqbpVLiIAOeek0JHzjeZcbsghAHzvI IklF3/Ob5kg5aB50nGBePGTT1DDqUHVdkE9ayI/4bntTkxsUfI028kblSq7L7omgHR auQCBtjvK1qOE7i2V6eZFjiAkI/rP7XfyremAfr4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Eric Dumazet , Jakub Kicinski Subject: [PATCH 4.19 21/33] net: tun: avoid disabling NAPI twice Date: Tue, 5 Jul 2022 13:58:13 +0200 Message-Id: <20220705115607.334949507@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220705115606.709817198@linuxfoundation.org> References: <20220705115606.709817198@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=-7.8 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: Jakub Kicinski commit ff1fa2081d173b01cebe2fbf0a2d0f1cee9ce4b5 upstream. Eric reports that syzbot made short work out of my speculative fix. Indeed when queue gets detached its tfile->tun remains, so we would try to stop NAPI twice with a detach(), close() sequence. Alternative fix would be to move tun_napi_disable() to tun_detach_all() and let the NAPI run after the queue has been detached. Fixes: a8fc8cb5692a ("net: tun: stop NAPI when detaching queues") Reported-by: syzbot Reported-by: Eric Dumazet Reviewed-by: Eric Dumazet Link: https://lore.kernel.org/r/20220629181911.372047-1-kuba@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/tun.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -710,7 +710,8 @@ static void __tun_detach(struct tun_file tun = rtnl_dereference(tfile->tun); if (tun && clean) { - tun_napi_disable(tfile); + if (!tfile->detached) + tun_napi_disable(tfile); tun_napi_del(tfile); }