Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp388154pxj; Thu, 20 May 2021 11:37:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeBQtYdbseiRSOhywbSjjfiEZiOHq+XM2EqTZo7OTSp8wvtXDwztpJ35de7vv0RnOvhdaQ X-Received: by 2002:a6b:8d0e:: with SMTP id p14mr6668927iod.30.1621535863350; Thu, 20 May 2021 11:37:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621535863; cv=none; d=google.com; s=arc-20160816; b=yTQ9TS1DGo1xSiE6Fto3B3pN9yiWu9ISrm9hKGDqS+dO57Ei2JPMPfn/NypWK11LCq LtDC6lP4s9l+lz4TaQh2VCZ7Y32Svc7uXpTmTbuBGKNmsaFQ0y93+AcOJgpfqnKqzVgn jr18HRDrj0UO2pDntgC8+8FGVUCvotzSRyj0Lln3gaGQsyKXXHf63XXnbOZAuStLmFoA ujPaeyg/QcUfIH1AgPJ2Gr/EwsJi3uSbO6x8UyWUAR9+iZlpcCTi+lN7RJQ5zWkxGgEI cmgfQYvPT+iqWPUxOgkoVBy7uAk9Y7Zbkz4tByLFuMYS+DCcNn3/bEymCDZIGCh0LApp Bs6A== 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=DGrr9nSJNcsXGJyOQaQh3ZXB/RUuMWKz9922kO1e0tQ=; b=HUkqfT3HRoC6OFwHADRjDcPrpRCUMRPj0vBuX8s4khHMi8ZOXDGEBHizt4WarxH/i4 zp/fBUcrdoFmIeeL+ojOAODFtCZqAcD5rgiKoRUnbW6a7dpIBUFKdg78cCIkycwZs0Vr cg3EDennFZz53bZrUWz71SDCUNjhVvGAHxFC2jmufHYLSfDMXCym88YkQi4++DctQ2cL Vo0q5Tq9DacZDmTFxDtA1Wvoa2ELJmHfBmSghXhSTi9czpGAV0NzUmrK/9YJhFZg2w6Y wBXpmzfmY2UaIeWOvURMGKh73DMjGth7VjPu+2+5+2zHLq88+c/BLDm+VkrPcE/kn5nR kqiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Gd768n1E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si2967247jaq.7.2021.05.20.11.37.30; Thu, 20 May 2021 11:37:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Gd768n1E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236974AbhETKZE (ORCPT + 99 others); Thu, 20 May 2021 06:25:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:47610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236155AbhETKO2 (ORCPT ); Thu, 20 May 2021 06:14:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8EFF16198A; Thu, 20 May 2021 09:44:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503874; bh=4NVkunrWWv/SvWyvkTcvMfr3v8kohHIvuaJRU7j1BSk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gd768n1EQ/PWiJC+3M+SDVf9VpW7mudR5v5HIhw+4Ka9CjZychfIH2O0u+ry9xoER f7vbNXROv3i3hWDReSS9Ws2Vibdjiiusfb4ss6S2yuuo1F5yE3I2m4GIs06VC1icQZ Kd3F4gRl9oga9bIpskr3scIcal+o6+TC/53JL0og= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , syzbot , "David S. Miller" Subject: [PATCH 4.19 419/425] sit: proper dev_{hold|put} in ndo_[un]init methods Date: Thu, 20 May 2021 11:23:08 +0200 Message-Id: <20210520092145.172633551@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet commit 6289a98f0817a4a457750d6345e754838eae9439 upstream. After adopting CONFIG_PCPU_DEV_REFCNT=n option, syzbot was able to trigger a warning [1] Issue here is that: - all dev_put() should be paired with a corresponding prior dev_hold(). - A driver doing a dev_put() in its ndo_uninit() MUST also do a dev_hold() in its ndo_init(), only when ndo_init() is returning 0. Otherwise, register_netdevice() would call ndo_uninit() in its error path and release a refcount too soon. Fixes: 919067cc845f ("net: add CONFIG_PCPU_DEV_REFCNT") Signed-off-by: Eric Dumazet Reported-by: syzbot Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/sit.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c @@ -215,8 +215,6 @@ static int ipip6_tunnel_create(struct ne ipip6_tunnel_clone_6rd(dev, sitn); - dev_hold(dev); - ipip6_tunnel_link(sitn, t); return 0; @@ -1407,7 +1405,7 @@ static int ipip6_tunnel_init(struct net_ dev->tstats = NULL; return err; } - + dev_hold(dev); return 0; }