From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9CC2421EF8; Thu, 30 Jul 2026 14:58:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785423496; cv=none; b=NJqtsr4biV0nYiWwAWijpAFIWlKmiTPAaTvH8udPKG//rgwrWCOR2PdTtbHghzAKNbyfodFMjDpAobqXb6x0RvQyLFWw5P8hB+LGndEI+0KsU4tvwqIwq+0PltS9nBp5fanRkiPGSnDdx6lLKmQSW2pV7vmMjxxpOs2W/c9JRIc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785423496; c=relaxed/simple; bh=syWSD3ESGeR/cOTjTCLbiU3DHYv2ViSf22IxVoBWGuY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S3nWzQmfuQgD2fGPGNFauZXiAVQVl9IpdzO+0P66MrNXR9E8yf8j9gHDTtZchE199QYc6YxKmC9NdDL/XD9OU7Os7rqkySsDAoqXJHjVWssSxx3hG2HRTjtiQYv8BbG+I7i3ZtD8tgqPZ+wwJDf30h5/TReG7cHB+rp2FxIoGJ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=yQmGwCld; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="yQmGwCld" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4D471F000E9; Thu, 30 Jul 2026 14:58:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785423495; bh=v7nbG2L/4N/eH+YIHDd2wzzNxyyP70SDivsSlX+1UaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yQmGwCldwIF7Bo/7YK+E54aQCZekJVRbFfqAa5Ba0D/CZUsvp/efMspdMpNbyzIPk WULz1vNc8O52Z/TJzCVlNgTpfS2p2nl7OTlAEiG7/xU7HDCkEpqBZPD3x5o6ot0ozK vz0r34dR3qIJL/CKojx3qs4UNh8GW4SA1ajBEoyM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, AutonomousCodeSecurity@microsoft.com, "Xiang Mei (Microsoft)" , Steffen Klassert , Sasha Levin Subject: [PATCH 6.18 063/675] xfrm6: clear dst.dev on error to avoid double netdev_put in xfrm6_fill_dst() Date: Thu, 30 Jul 2026 16:06:33 +0200 Message-ID: <20260730141446.465468486@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730141445.110192266@linuxfoundation.org> References: <20260730141445.110192266@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xiang Mei (Microsoft) [ Upstream commit 136992de9bb91871084ae52d172610541c76e4d2 ] On the error path where in6_dev_get(dev) returns NULL, xfrm6_fill_dst() releases the device reference with netdev_put() but leaves xdst->u.dst.dev set. dst_destroy() later calls netdev_put(dst->dev) again, so the same net_device reference is released twice, underflowing its refcount (ref_tracker WARNING + "unregister_netdevice: waiting for to become free"). Clear xdst->u.dst.dev after the netdev_put(), the same way the XFRM device-offload paths xfrm_dev_state_add() and xfrm_dev_policy_add() in net/xfrm/xfrm_device.c NULL ->dev when releasing the reference on error. ref_tracker: reference already released. ref_tracker: allocated in: xfrm6_fill_dst (net/ipv6/xfrm6_policy.c:86) ... udpv6_sendmsg (net/ipv6/udp.c:1696) ... ref_tracker: freed in: xfrm6_fill_dst (net/ipv6/xfrm6_policy.c:90) ... WARNING: lib/ref_tracker.c:322 at ref_tracker_free+0x58b/0x780 dst_destroy (net/core/dst.c:115) rcu_core handle_softirqs ... Fixes: 84c4a9dfbf43 ("xfrm6: release dev before returning error") Reported-by: AutonomousCodeSecurity@microsoft.com Signed-off-by: Xiang Mei (Microsoft) Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/ipv6/xfrm6_policy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index 125ea9a5b8a082..3b749475f6ed65 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c @@ -88,6 +88,7 @@ static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev, xdst->u.rt6.rt6i_idev = in6_dev_get(dev); if (!xdst->u.rt6.rt6i_idev) { netdev_put(dev, &xdst->u.dst.dev_tracker); + xdst->u.dst.dev = NULL; return -ENODEV; } -- 2.53.0