Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1257539imw; Tue, 5 Jul 2022 06:32:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vFYWKQo466UARXomtq7H/Ndb8s+TepUF2zFzT0af8c/Dpp4uyZMzljEFuzY9ihb6FxW8bE X-Received: by 2002:a17:907:1623:b0:722:ef86:e25c with SMTP id hb35-20020a170907162300b00722ef86e25cmr34569303ejc.461.1657027962487; Tue, 05 Jul 2022 06:32:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657027962; cv=none; d=google.com; s=arc-20160816; b=wcYj64p02nBuy/W0SeFdmA74VxrTCL4QA0I6gMO50tY1F9KE0b67Pg5btp9izBH67b DpGZ4pPoc5kWtlMiQvEk2sY9ascnzv2ZHNuWZGRpGfQ29NeSMNP6hed9e+mFg2d5x12x pV/FF80PquMKacKm2Zja+xJpwgB6Ktoj03xF7qaI3mKb2K/KoyEgA/JjigOiYV/oCHWM q+V0zsJ65PDyYXMnWSUZ1xe6bKV57v1NG0hLszCQdrutn9COab2NkBnPoT4ih8EYwxMT m+cxVMrURzsnkpHAlsun7M0svqImTNuK+M9i0JYTR+Wol6QD5MVPJmQXtgdnHrQJ85qI CZ3w== 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=Gj4VAIeL7Mf37Rpud+6tEE2Zp364zlEfbUB8Kylzrkc=; b=z/lqUphaOUwZk6/5gr9m12hNX0ezZkq22VqfrJNPgn0FC7hj9YPAVO1/htjevSLF2Y t8op67iTyMCzZ2KWO9QOjWty2Sjtn7aWBNSyyrn2wsNSNdt2jGPlisX0RO9fkLrZ9Ln/ 4+sDHqJQGCI4yZLIM3oSeQRsi+UgbTlTjcpX+jiaCK1Xa6Huzykvk+Aykj9vMLagdH1Z C74zXuI/x7BesmKA2D0lBQ0V+jaEo+9+XubZCcIPw7YlWfepmAobQ3qIRJrwhCGlQIl/ LcQuqYr/3RL3nf+JYxsThPGrpdWNGIYg+7l8l72RbZrK5Ix6kSX3wB+MdqVRnHGC83qu jSow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BpCWTJvW; 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 ga39-20020a1709070c2700b00726b4dfce1esi16658761ejc.167.2022.07.05.06.32.16; Tue, 05 Jul 2022 06:32: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=BpCWTJvW; 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 S233694AbiGEMD7 (ORCPT + 99 others); Tue, 5 Jul 2022 08:03:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233289AbiGEMC3 (ORCPT ); Tue, 5 Jul 2022 08:02:29 -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 AEC991834F; Tue, 5 Jul 2022 05:02:10 -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 4230E617B1; Tue, 5 Jul 2022 12:02:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5496CC341C7; Tue, 5 Jul 2022 12:02:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657022529; bh=1aNxRSM3WSh6dT/Y9hf3086GdEr426ZdQj2p6D8x9j0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BpCWTJvWNjT6FH7J+8IflXSwVijrXCrBFieVltyLyT24xJxXL21XuUne+w/Qp3j3V FZ/FGbS4vAta3kG1BMw4t/S0pEh2UCXKSCm6Kc1zzeVtHjUYsiomabBAty+j2kyzFL glvk6otMSbU6XfZ2qTm1Oc/5olWD1Hq6EYD6sKro= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+b75c138e9286ac742647@syzkaller.appspotmail.com, Jakub Kicinski Subject: [PATCH 4.19 10/33] net: tun: unlink NAPI from device on destruction Date: Tue, 5 Jul 2022 13:58:02 +0200 Message-Id: <20220705115607.012470204@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 3b9bc84d311104906d2b4995a9a02d7b7ddab2db upstream. Syzbot found a race between tun file and device destruction. NAPIs live in struct tun_file which can get destroyed before the netdev so we have to del them explicitly. The current code is missing deleting the NAPI if the queue was detached first. Fixes: 943170998b20 ("tun: enable NAPI for TUN/TAP driver") Reported-by: syzbot+b75c138e9286ac742647@syzkaller.appspotmail.com Link: https://lore.kernel.org/r/20220623042039.2274708-1-kuba@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/tun.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -797,6 +797,7 @@ static void tun_detach_all(struct net_de sock_put(&tfile->sk); } list_for_each_entry_safe(tfile, tmp, &tun->disabled, next) { + tun_napi_del(tfile); tun_enable_queue(tfile); tun_queue_purge(tfile); xdp_rxq_info_unreg(&tfile->xdp_rxq);