Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp491171pxj; Thu, 20 May 2021 14:18:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8958t7ADd+DgfBAqgty+HhUll19m5kVIocXOXTzhg7l/8zgAOlpR/LLtXYQQr0qV/cFSo X-Received: by 2002:a50:fd11:: with SMTP id i17mr6990107eds.23.1621545516899; Thu, 20 May 2021 14:18:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621545516; cv=none; d=google.com; s=arc-20160816; b=HLcpuXGKznd4+93n2NYHEoJTVsZ+XPODmjvBX8zY61+Vf5Ejn5ACH0fID+CnshT+Js Ch/X11fj+ICTGJweAeC6SX8Crad7tWafPxWsVbZkgq0nauxea7e3hPfsWlSZ5cRPFh8H cCERfLrpLhKyGhcwaN23Pic2kI8ZJ/rtnX8QqgDvqVHmxTv4vAzbdE44ZdoIzYiJWM09 z7PkYW6eiP4unMHmXuTYY5hmgigQCLNTBK/4s3twK3j7EBwES3ZjjvlnvEECPonzBDcu YhafbcZidQg95dGRT4f52OnSMi3waGP0ONLtkH/UqBmwB5WdGWNkoCT6TgSwCqQVVmHk 169Q== 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=pVCNUSHVILXeg0aJYtmBtbAoaLiZD6cMWfL2Zqi6om4=; b=xJ8Nv76c5n8BAHG9eKExifidCjK7V5cALkk2BkC/nOv1f3p7rcCRiP2qxWmuFv9Ic5 T7zXtiKO92kzIAhLNFCxZH+vJTYgsSL8er9p5LSF07KjNg83MqMBHHfZEffHPmwKf7k0 JPbLc8JoCvX2neZCxPPw69sHUP7viOutqUDsm+L4n2sFgNo6TceHHVfM7CNl5B96UaTQ JfJVi2663ewn0wCua6Is0e/7ZK5L9FEGhzTPhBH6Sl8Wf8k/Av4ctH+S3XNU38XKv32A TzDrHnMQ9OAWNXvqF4G7zvuYw8tCmhpfm6eOmvehfhPamSfOoEbVEzY4mPN0MxX68ryw niug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bVhMKt5K; 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 p4si477743edr.153.2021.05.20.14.18.13; Thu, 20 May 2021 14:18:36 -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=bVhMKt5K; 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 S239241AbhETLCd (ORCPT + 99 others); Thu, 20 May 2021 07:02:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:45066 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237947AbhETKoK (ORCPT ); Thu, 20 May 2021 06:44:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E773861C96; Thu, 20 May 2021 09:57:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504622; bh=JWBxnV+Asf0mk2kGN/PYA43yeYqpEAkA4ZyWW1vQK6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bVhMKt5KkzEdghlUCmqECBtpHczeLoBWD/OTGfFeYvxLD7KZEZM0oHCUX+O4vcQhg w+1U8OmVhrYLYuc/sDRPqb0IYIKO+OCqNlTlBh+NRSQgSq3eixmS6CAOMxQaDmsYdc YKVfvM4soKHG+UO2Tx4rX56/BBZkzpYpyBa/XMUo= 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.14 320/323] sit: proper dev_{hold|put} in ndo_[un]init methods Date: Thu, 20 May 2021 11:23:32 +0200 Message-Id: <20210520092131.211549239@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 @@ -209,8 +209,6 @@ static int ipip6_tunnel_create(struct ne ipip6_tunnel_clone_6rd(dev, sitn); - dev_hold(dev); - ipip6_tunnel_link(sitn, t); return 0; @@ -1393,7 +1391,7 @@ static int ipip6_tunnel_init(struct net_ dev->tstats = NULL; return err; } - + dev_hold(dev); return 0; }