From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D376BC433EF for ; Wed, 29 Jun 2022 16:27:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230118AbiF2Q1K (ORCPT ); Wed, 29 Jun 2022 12:27:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230079AbiF2Q1J (ORCPT ); Wed, 29 Jun 2022 12:27:09 -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 D0F123617A for ; Wed, 29 Jun 2022 09:27:08 -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 9E270B82582 for ; Wed, 29 Jun 2022 16:27:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A0B0C34114; Wed, 29 Jun 2022 16:27:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656520026; bh=rINkVNkAb2OHNSzfVBfdFdvGgjSA3sDWP5Md9K0aI7k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=iXDXWuW2Ea7U8RH7O0wC2k7cxMKAHc91jM4eUuWqa5sN6maw6nuhRuAfXdoLAnqkq aLLfNt2W7tx/O1DlfDczjZ3iO/gjNw8lYedhNiPR6ClxEh9/DuKXJi199fWZ7VgVwX m68zvxjcvrb5KMzgsU7Yd/CWSCA0GnCwwyuzVO1OuVPQjgFS9RTMQPKQ8gax916g7/ VqLK5NGvpzPdQgnH+fmPYCLfYEQ80a29OQtLSXRMF66uwi9ZZeuV+0WpsKM2n7q7BR J6IbCwz8byIOLs0LnLoyIdlGLVjsVZ37jbwbD7RvqJQ16fZPN+DPOkC8jQbVB1YKSt 97IKymtFxce7g== Date: Wed, 29 Jun 2022 09:27:05 -0700 From: Jakub Kicinski To: Eric Dumazet Cc: "David S . Miller" , Paolo Abeni , netdev , Eric Dumazet , syzbot , Petar Penkov Subject: Re: [PATCH net] net: tun: do not call napi_disable() twice Message-ID: <20220629092705.3c18985b@kernel.org> In-Reply-To: References: <20220629093752.1935215-1-edumazet@google.com> <20220629091750.1f0dc8ed@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, 29 Jun 2022 18:19:58 +0200 Eric Dumazet wrote: > On Wed, Jun 29, 2022 at 6:17 PM Jakub Kicinski wrote: > > > > On Wed, 29 Jun 2022 09:37:52 +0000 Eric Dumazet wrote: > > > syzbot reported a hang in tun_napi_disable() while RTNL is held. > > > > > > Because tun.c logic is complicated, I chose to: > > > > > > 1) rename tun->napi_enabled to tun->napi_configured > > > > > > 2) Add a new boolean, tracking if tun->napi is enabled or not. > > > > Not a huge surprise TBH :S > > > > Is there a repro? > > Yes, here it is: > > // autogenerated by syzkaller (https://github.com/google/syzkaller) Thanks! let me test this: diff --git a/drivers/net/tun.c b/drivers/net/tun.c index e2eb35887394..8776a9e1a8f5 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -661,7 +661,6 @@ static void __tun_detach(struct tun_file *tfile, bool clean) sock_put(&tfile->sk); } else { tun_disable_queue(tun, tfile); - tun_napi_disable(tfile); } synchronize_net(); @@ -719,6 +718,7 @@ static void tun_detach_all(struct net_device *dev) --tun->numqueues; } list_for_each_entry(tfile, &tun->disabled, next) { + tun_napi_disable(tfile); tfile->socket.sk->sk_shutdown = RCV_SHUTDOWN; tfile->socket.sk->sk_data_ready(tfile->socket.sk); RCU_INIT_POINTER(tfile->tun, NULL);