Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1255713imw; Tue, 5 Jul 2022 06:31:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vsZTdiTVIRvj6q0zOjYlwJYL7Sv53Y23yWOWV42hbOYjOk3BnL2QVeIOpxaWy31PRG869M X-Received: by 2002:a17:906:c354:b0:726:3b55:7045 with SMTP id ci20-20020a170906c35400b007263b557045mr33185292ejb.723.1657027874898; Tue, 05 Jul 2022 06:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657027874; cv=none; d=google.com; s=arc-20160816; b=Q1HyT2ZXhM/ogNGC0bnMWgAwh8HrkKfb1xqesbkm3KtM4B/WS0hLUQhL2A5tQPP1Cp /vH5vbo3FZXPMe41RcJqebs6iRg3OQO7OP0wCRwdNoCV4T1W2aqgnqonQg4YkcdHSlYw W5VDKAKsmouNzDwc1F/jSv41R01/o1jriATPpnQdoB/mNFIT1A/mZhhlXM15qwqUMq53 eqq/97B3A8SDxcxBUrWlPdMKc20NJVUqfJ0cgwAVhieuSenzWVjByakdKS97JQUIi7OU G7o4BqLqqxn/rL9hateo2VfuqTF2gn7zHl2SyanvJItNxKYo1jF6X9nkUtlPBX9K9Mi3 GYeg== 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=riVnFcNWkrlYRz006HFqCkIaFfQBhrYGy9zPAaLwzQg=; b=xUM1fRpLQOph719XvCSa1QEHPcFIG7WuDfvYYN0vNtlDsBk6a7DEWFzmhJ0QzLh3hJ MP8RcgCGU3e6UgmfSzEh+AnRn5TJryE5yD9D9BZuIsFNmHhMltAGc7+xABSmxzrt7YBY Fc36vnsEhAdnJc2x9LgwefvlQcs4rSOF7d7Ckehjg82LxAFAcpKJdliakNyBeDBGDeQS LeEurty40nFzZ+nzJGHUGl2ZG+wKqwtRHRSwLCkRPoa5jSfG71V99e7axXK1FgH1hbW0 5k5GNeDbtFEee/2aHz3Bd4LQrWN27pgLrssFI2r+3/QfmDbtYOUHvkQoInIAhqnuOeh8 CzTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lxZXKj9g; 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 b20-20020a056402351400b004357068ef59si46335675edd.282.2022.07.05.06.30.49; Tue, 05 Jul 2022 06:31:14 -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=lxZXKj9g; 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 S239248AbiGEMaX (ORCPT + 99 others); Tue, 5 Jul 2022 08:30:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236489AbiGEMRs (ORCPT ); Tue, 5 Jul 2022 08:17:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE892192A7; Tue, 5 Jul 2022 05:12:39 -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 6A57B61988; Tue, 5 Jul 2022 12:12:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73757C341C7; Tue, 5 Jul 2022 12:12:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657023158; bh=t+jAMUHlwRXalBDL3MFKIWQzbrorRRuqCTlbXnSuoew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lxZXKj9gruYlo+RX6nnMRmKYam24VgfCRfikKignkdQiKtnxzjL5kdQ4UwzmOXSW+ 5B6prZLVU7pgwkuKfrqKZT8hG0dYOHnuxb9wYlMbfyeL4cXa7RrrKbA6Ud+qT83eWX u7addeTf+18ApSXXMJdhWpyuzuVXHom1uGgmPfjQ= 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 5.15 58/98] net: tun: avoid disabling NAPI twice Date: Tue, 5 Jul 2022 13:58:16 +0200 Message-Id: <20220705115619.229845920@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220705115617.568350164@linuxfoundation.org> References: <20220705115617.568350164@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 @@ -641,7 +641,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); }