Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp625977pxj; Thu, 20 May 2021 18:17:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyn+llyUBaJmh5JJDi+kIz26AAprV7vx3HwZuBxcxR8ZxHi9+4e2sSqeLiC7l+OVroOuD27 X-Received: by 2002:a05:6402:416:: with SMTP id q22mr8005160edv.204.1621559848711; Thu, 20 May 2021 18:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621559848; cv=none; d=google.com; s=arc-20160816; b=sH2qBPyoNrS9+JrMiahHWvTuP6PYxRx++Z10c9pb2BXoFL/mPC4nVEybrg+WvQQCyk k0iA1tyjmY8iPQ4jFaln7hFqNw6wu9m+1gYyghkaieWuYHqbLlQGAPYIyHi2zl13Braq zwfcWgLkqONqT6G6MaehHRuA0MLSjqlLxKMgiCPYayKwWdLPfHznrd6ipWdcmx4xwydq /3aJ2UorAvEnWF7CPOnP8WbEQRsry87JzLTb1BBcEar0SfOX2i0bs7Tk+08OomkKEX38 oI5bx/Jyqyraa1QKcMFDUaxNEV/QZdXXyzA1vkb1COcWpEmzC29JfRuU/7h01nXevVB1 gAOQ== 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=GIgCwlvcG9+kUZQMyyCCS0Jupbfbgf+d3hJIloLMXHk=; b=hq9wxkurfpucUg13eOMHcioS7SbKtme57JC+qN6KhycAka1w5ElrSvNTtIvq6ypLB4 AkRtaVVxFoel8Kvot9FwYpI7/NA6CWrOKN/WuMkuVDicn5282tI0WN9otSC93iZBeZf1 +V9RZ8ItT4wv5ajBA0Q4dmL+95nIH0ky/YBRvxfMolrRYvIyCFiPz7fO0dlHb+JClJEI 7c01bhm4aLAMLiasmH7O9ucUowlIg2feGnhegGGuZ15NqvJCTEAfhWJUV95owD5m7ZWn e8XT8Fd2QHbCyi3OCPME9uc3EmnU64Q5F5E3kjW21AKLhjDMakEicirHxQOEuuGkUf8x dsmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B2GjwxSO; 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 a4si928315ejc.644.2021.05.20.18.16.46; Thu, 20 May 2021 18:17:28 -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=B2GjwxSO; 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 S242024AbhETLqP (ORCPT + 99 others); Thu, 20 May 2021 07:46:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:44012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241520AbhETLYo (ORCPT ); Thu, 20 May 2021 07:24:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 008BF61968; Thu, 20 May 2021 10:12:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505566; bh=HKJcPFWEfWxSCjuhXD9zo4ge2BXyQcW4uNDhnkX1zVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B2GjwxSOMdTSbuJxED4IJIt7K9KIoMV7XbGfR9iZk4EEj+Te4LaRyPdDH0SkG9mOF UA4DSXIUtUbvvBXqiFrkuB2nLP6YX4k8dzrUxPA3GIJiekhs5JduMFzV33vQ97OCUt OguqsVEGH4G/49d+htYB8GNsP53ADcv8BCREksVw= 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.4 186/190] sit: proper dev_{hold|put} in ndo_[un]init methods Date: Thu, 20 May 2021 11:24:10 +0200 Message-Id: <20210520092108.317235983@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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 dev->rtnl_link_ops = &sit_link_ops; - dev_hold(dev); - ipip6_tunnel_link(sitn, t); return 0; @@ -1399,7 +1397,7 @@ static int ipip6_tunnel_init(struct net_ dev->tstats = NULL; return err; } - + dev_hold(dev); return 0; }