Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp242332pxj; Thu, 20 May 2021 08:25:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaTICQ5nhKTcql/NIsAAeH/v9hqwfa5lUZ0uvxJ788/+gRrZqrivQLRv1xOe/5jMaJ2VE8 X-Received: by 2002:a92:db11:: with SMTP id b17mr6581157iln.277.1621524324092; Thu, 20 May 2021 08:25:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621524324; cv=none; d=google.com; s=arc-20160816; b=aCX/sqCBBwJNog+HkER7b18ssiFMKDgAOvCcciO2DJ73BAZhSjEO6WkAYim6WKgZrM yes3YnfKQYpEkGz0rpOJePrXdGoape4UtizqxVbIuZpx7y382PnylbhKjf+kSlSxEk0Z IDy0f9T4zyqhWHlKSvCXBF7huVRPNj4mQQCm7Ca9RHwKemK1O9POib+F4TZDDU/JDSiJ DxEAOoAllKl7AClVJkrVOW6dBmXAjE0Bm0gO/HSoU6HIXXybhqKdAdlIjBr3yzJmP/8h VsP0XPLYhxWkO6Wp9VhgnTk9om+M8/5UcbFus6ReEAQd/lUc5YLj9QK/0H3Lp2a6bt5P dAlQ== 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=4KvoASpfi6n7TaM86PlMgPzEm3ZX3y72h7XIysM5uLM=; b=c0qYdaMVMmFymZBrosTqXY5ZFUUb6iMAJzgY21fYXxAFYOhO0sjyX99m+sGN9e1QBa CPkkFspiH2+zMksPjDAk4i5BtHaMkCaIEt84x5OrJxeQHPyFghGGXldqat1IGGL4fmB6 oCK7cwiBgcfiniAnnjXmx/0CFP6glIKBO40T14I8vK4yvBVbs4lxr7Ciz/usX7NUzl/Z NBW/IWCuutFvzvBMkXDv9v/Pv6EP0AsYeuPMM0yCRYOFslkNIci7M006Bzy5uSjffx2c h1Muwd79OTpy3Wet8C+FULNQgpcl2y8pGtHWSrputmgYJHPj6+CIia/fG7+BBGFoFebs KCag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WXuSSb1U; 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 t19si2282593iog.66.2021.05.20.08.25.10; Thu, 20 May 2021 08:25:24 -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=WXuSSb1U; 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 S232707AbhETJf4 (ORCPT + 99 others); Thu, 20 May 2021 05:35:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:35514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232478AbhETJdj (ORCPT ); Thu, 20 May 2021 05:33:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4112A61279; Thu, 20 May 2021 09:28:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621502933; bh=j/RXrYRZb7AUWpnUJVgtc9C+bR3V8FmRalDuy/IbEEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WXuSSb1Ueqsio/f6NK/YDgHUNQEd8omXuW+2hf4fXUqcBTUSjSN/CjOD+kW+d9o6j ZVyPINabosiGFq67+9EVRzS7xa5kF7xUnKL4sQYbL6ssYTq+CH2M3plXPuu9jkG6Xi aRbbAf4S7pBhdwSBLAOmNefMB4+WHVHsK+FQfpoA= 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.4 32/37] sit: proper dev_{hold|put} in ndo_[un]init methods Date: Thu, 20 May 2021 11:22:53 +0200 Message-Id: <20210520092053.335721768@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092052.265851579@linuxfoundation.org> References: <20210520092052.265851579@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 @@ -211,8 +211,6 @@ static int ipip6_tunnel_create(struct ne ipip6_tunnel_clone_6rd(dev, sitn); - dev_hold(dev); - ipip6_tunnel_link(sitn, t); return 0; @@ -1408,7 +1406,7 @@ static int ipip6_tunnel_init(struct net_ dev->tstats = NULL; return err; } - + dev_hold(dev); return 0; }