Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2204989pxj; Thu, 20 May 2021 02:31:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIkSP5BAq6pDf0z28KIgu1lPwzV0FPh2CnUDz/xHt8z6wH1ZTKY6RCAy+1dsVuGg8AQOBf X-Received: by 2002:a17:906:6b96:: with SMTP id l22mr3698639ejr.456.1621503060796; Thu, 20 May 2021 02:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621503060; cv=none; d=google.com; s=arc-20160816; b=I+5yICcQxRVPX59l01X3oUGLSDfgNOhIJdCl96tIk/hVxHsvnoicgJZ+0banz3faiC bDa2F0OM/6pyCJ7ex8sfVAIS1rWwcNrtq6A45RQUvqa6u6fqvIPHrui3HSRhjOo5iY+m 5AGHCcuQc36Mioirh64J1CBWbSxois8eOn97WamZF2MGOpVMqwdCpZPcXYC2qstSgJMP o+Wf8B33fhu2NVhSyVfDCRYZEkoJT1R/1U0ivN59ZoezPLaKvjB0AWzw8T797MVVAbzY HdCOLoXlx2VdbgfD59e1VsUyWU75TadJV2iKNLHQ/St/BHY6tVDpuTtjhYk56nNDsUuh JGaA== 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=vxA8/Q+llZWFJQB108cS8G3nqNf3PsKJxrxGKjwV/YI=; b=BBpM+x1dDt6keYkZey9JADrZjppZixC9E18tLn9Q0xgl/KjL5mMvkLsGg2MzxxaOvK KnSEY+/1V1FMFUagw/CSlRw/9JyCmEGK9FPXz85Kf1xs6VyAddDXoy3lWewDu/ABkAyV up0qmj6thOjBnZD2ld2cu9uGh9X2Afl2ESjK6jt02gFMleiNGSpYc0Y6z1Tr9FHec/sZ 6WKPdnI+jkZeTL9DtsWc30bL1bLjx9NPPokT51ugh5/KhJb4z7vNlVO8CXL532QvIwMm XsKX042qs6FZT1rN5nIgm6zAvH70tLPVvLN1DoA8SzpdI7L20bdiQEDe6fY+QFnO3jDN Ys8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Z+gO4BgO; 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 f8si1791167edk.566.2021.05.20.02.30.35; Thu, 20 May 2021 02:31:00 -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=Z+gO4BgO; 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 S231993AbhETJ2j (ORCPT + 99 others); Thu, 20 May 2021 05:28:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:54734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231549AbhETJ1e (ORCPT ); Thu, 20 May 2021 05:27:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C40FD61363; Thu, 20 May 2021 09:26:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621502773; bh=p/ygo+1Wb6+E/Plt2HTQEAWZfAZPL1UudxQB/9P9TS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z+gO4BgOG+0/X8iU7OR6CMJgI3p60IVk/dJ8SY4uQ7/ii5YRHlgFFU6B8RCMHokGu mab7eza0Gle7bCjMZ5puaujW89ezD66lRt7wNwWOygbVnI5tCTfkOSdeHpeddX8oqX D+Gs0fCKXN8FoqIOyv6F0EY86QPKrb7VWHlo2ExU= 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 5.12 43/45] sit: proper dev_{hold|put} in ndo_[un]init methods Date: Thu, 20 May 2021 11:22:31 +0200 Message-Id: <20210520092054.909014767@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092053.516042993@linuxfoundation.org> References: <20210520092053.516042993@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 @@ -218,8 +218,6 @@ static int ipip6_tunnel_create(struct ne ipip6_tunnel_clone_6rd(dev, sitn); - dev_hold(dev); - ipip6_tunnel_link(sitn, t); return 0; @@ -1456,7 +1454,7 @@ static int ipip6_tunnel_init(struct net_ dev->tstats = NULL; return err; } - + dev_hold(dev); return 0; }