From patchwork Wed Sep 11 13:46:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13800589 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4D748EE49A9 for ; Wed, 11 Sep 2024 13:47:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=n23LjBJEpWfCJ+ZxF/dGp1fjzZeTLOwCdh892p3XNbw=; b=u784FfbQDaB6mW2Ktrvtdgl8mr jlffqKy4gul8HIZJaixhlmNamutHmhP/8AIXBfqd0Jm/fBL8T5vDI4RSBSn970ZGKEykTJf96S0nW ecOguwjtIDkLmvD4eoqZsWuZ+yCvJZ0dsTNvbSkX2uFBdkhDCyIi44iUyllbqRrchTygeVFWr/wPp Zl0LUEuwD22OJNNqIH7X+7LIIqdE57AAMIBlQlVjSpXtLo7XTG1/wDHBYxUwwJE/c/QKQDEwlw/Qd tDMS7QCklPd19Cie0EMiMdDWhSIIiW1fe0aXT6OcRJBZsEVXrSjKE+CrHhztEuEQ912KN1/lu9y8V 25rODPug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1soNh3-00000009lLE-3k6M; Wed, 11 Sep 2024 13:47:37 +0000 Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1soNg0-00000009l8l-1CiC for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2024 13:46:34 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id BD583E000F; Wed, 11 Sep 2024 13:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1726062388; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=n23LjBJEpWfCJ+ZxF/dGp1fjzZeTLOwCdh892p3XNbw=; b=pRqGDVCCBpD3EjD2DQcSvoUP39gd3hMsePX4B4dOblNuSkMYeWHKtCmj+mFNetkskrgpHo QNwEkf1JoCLaoOpzxWHl/pwzQUp8VSnAK0m5l1qP/7yTiF+n7fI6zfx0jfOzHXLqO5yY36 jP0bidcJ21tRvHi4u62uX0FqVnA5L7gulFKm3uslDHCu6EUz5QQOUPcVjtNiWPrWwD7RGm yrnUP4/xse0sRzWgKEMTgJJ3+T+JVTSD9hDBqdjHDkZGxFnM+jJsu0hyKxCdNE6u3STK8g BI+WPsRlbHmmXmMjBvD5ABzN3b0W47fBuPVIuwAxps0QrM/1+LpRqxtKDuWmRg== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?utf-8?q?K=C3=B6ry_Maincent?= , Jesse Brandeburg , =?utf-8?q?Marek_Beh=C3=BAn?= , Piergiorgio Beruto , Oleksij Rempel , =?utf-8?q?Nicol=C3=B2_Veronese?= , Simon Horman , mwojtas@chromium.org, Nathan Chancellor , Antoine Tenart , Marc Kleine-Budde , Dan Carpenter , Romain Gantois , syzbot+e9ed4e4368d450c8f9db@syzkaller.appspotmail.com Subject: [PATCH net-next] net: ethtool: phy: Clear the netdev context pointer for DUMP requests Date: Wed, 11 Sep 2024 15:46:21 +0200 Message-ID: <20240911134623.1739633-1-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240911_064632_775750_4F6C3D53 X-CRM114-Status: UNSURE ( 9.45 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The context info allows continuing DUMP requests, shall they fill the netlink buffer. When performing unfiltered dump request, clear the dev pointer in the context at the end of the dump, avoiding the release of the netdevice. In the case of a filtered DUMP, the refcount for the netdev was held when parsing the header, and is released in the .done() callback. Reported-by: syzbot+e9ed4e4368d450c8f9db@syzkaller.appspotmail.com Closes: https://lore.kernel.org/netdev/000000000000d3bf150621d361a7@google.com/ Fixes: 17194be4c8e1 ("net: ethtool: Introduce a command to list PHYs on an interface") Signed-off-by: Maxime Chevallier --- net/ethtool/phy.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/ethtool/phy.c b/net/ethtool/phy.c index 560dd039c662..99d2a8b6144c 100644 --- a/net/ethtool/phy.c +++ b/net/ethtool/phy.c @@ -301,6 +301,11 @@ int ethnl_phy_dumpit(struct sk_buff *skb, struct netlink_callback *cb) ctx->phy_index = 0; } + + /* Clear the context netdev pointer so avoid a netdev_put from + * the .done() callback + */ + ctx->phy_req_info->base.dev = NULL; } rtnl_unlock();