From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BA3AF2512D6; Wed, 5 Mar 2025 18:08:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741198097; cv=none; b=i37XmE+uq0q3tlm4Y1K7jCukB5IWZNMKTw36S40wMYAswF6XwX+9++zdn0Qu0IO04HnGPjKNRXId3hF6ju+I9dWDN4DJMkPAh5CyCfdV4+9gr26hE/gP1JRTzwjr9i9ys8oH4dqJvYBNMLPqNushzZum0u/cUQc5fqjbivPtc5k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741198097; c=relaxed/simple; bh=T7DFJOBUsepXelEabAhGEJEGruVQMcmflc8QEVHzC0E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nYQHlasQ2HnTUjPhQA7JhNGpP2isAo+BCnRxCfzHmkqMsuRzzFqMYqIV5J8O6dEuY93KCYybWA9OjzalSxYcldnd7kXlnsscY05yy+hSAJ3wQl+uHyofsMe+GgWk4Y0UP8d9lG89b3a7uUoSQPwK0hU8OnkZmjLRwI7guJvYyxo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=X9JXh+Ks; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="X9JXh+Ks" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D56D2C4CEE0; Wed, 5 Mar 2025 18:08:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1741198097; bh=T7DFJOBUsepXelEabAhGEJEGruVQMcmflc8QEVHzC0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X9JXh+KsXaVQGtOWwSE3vyFK7di+4CD1oUdoEH73WJWvl10RYv3QxgR4WNPsKVQlx T/lvRbYgSdHEn4DVvpohE5mq4ZU1O5YXRdzyFvMxlwSzMr4vrgzZ7YRC4Lm4kVslIe Iu1+Zz4hSdh2REHKNede/Ci/Ci2oPUL3Iluy5uXQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexander Aring , Ido Schimmel , Justin Iurman , Paolo Abeni , Sasha Levin Subject: [PATCH 6.12 063/150] net: ipv6: fix dst ref loop on input in rpl lwt Date: Wed, 5 Mar 2025 18:48:12 +0100 Message-ID: <20250305174506.352448661@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250305174503.801402104@linuxfoundation.org> References: <20250305174503.801402104@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Justin Iurman [ Upstream commit 13e55fbaec176119cff68a7e1693b251c8883c5f ] Prevent a dst ref loop on input in rpl_iptunnel. Fixes: a7a29f9c361f ("net: ipv6: add rpl sr tunnel") Cc: Alexander Aring Cc: Ido Schimmel Reviewed-by: Ido Schimmel Signed-off-by: Justin Iurman Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/ipv6/rpl_iptunnel.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/net/ipv6/rpl_iptunnel.c b/net/ipv6/rpl_iptunnel.c index 0ac4283acdf20..7c05ac846646f 100644 --- a/net/ipv6/rpl_iptunnel.c +++ b/net/ipv6/rpl_iptunnel.c @@ -262,10 +262,18 @@ static int rpl_input(struct sk_buff *skb) { struct dst_entry *orig_dst = skb_dst(skb); struct dst_entry *dst = NULL; + struct lwtunnel_state *lwtst; struct rpl_lwt *rlwt; int err; - rlwt = rpl_lwt_lwtunnel(orig_dst->lwtstate); + /* We cannot dereference "orig_dst" once ip6_route_input() or + * skb_dst_drop() is called. However, in order to detect a dst loop, we + * need the address of its lwtstate. So, save the address of lwtstate + * now and use it later as a comparison. + */ + lwtst = orig_dst->lwtstate; + + rlwt = rpl_lwt_lwtunnel(lwtst); local_bh_disable(); dst = dst_cache_get(&rlwt->cache); @@ -280,7 +288,9 @@ static int rpl_input(struct sk_buff *skb) if (!dst) { ip6_route_input(skb); dst = skb_dst(skb); - if (!dst->error) { + + /* cache only if we don't create a dst reference loop */ + if (!dst->error && lwtst != dst->lwtstate) { local_bh_disable(); dst_cache_set_ip6(&rlwt->cache, dst, &ipv6_hdr(skb)->saddr); -- 2.39.5