Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Guillaume Nault <gnault@redhat.com>
To: David Miller <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org,
	Steffen Klassert <steffen.klassert@secunet.com>,
	Herbert Xu <herbert@gondor.apana.org.au>
Subject: [PATCH v2 net 1/4] xfrm: Don't accidentally set RTO_ONLINK in decode_session4()
Date: Mon, 10 Jan 2022 14:43:06 +0100	[thread overview]
Message-ID: <ce6a296ddbf7e6700c40adeb24b69dc667a78823.1641821242.git.gnault@redhat.com> (raw)
In-Reply-To: <cover.1641821242.git.gnault@redhat.com>

Similar to commit 94e2238969e8 ("xfrm4: strip ECN bits from tos field"),
clear the ECN bits from iph->tos when setting ->flowi4_tos.
This ensures that the last bit of ->flowi4_tos is cleared, so
ip_route_output_key_hash() isn't going to restrict the scope of the
route lookup.

Use ~INET_ECN_MASK instead of IPTOS_RT_MASK, because we have no reason
to clear the high order bits.

Found by code inspection, compile tested only.

Fixes: 4da3089f2b58 ("[IPSEC]: Use TOS when doing tunnel lookups")
Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
 net/xfrm/xfrm_policy.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 84d2361da015..4924b9135c6e 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -31,6 +31,7 @@
 #include <linux/if_tunnel.h>
 #include <net/dst.h>
 #include <net/flow.h>
+#include <net/inet_ecn.h>
 #include <net/xfrm.h>
 #include <net/ip.h>
 #include <net/gre.h>
@@ -3295,7 +3296,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
 	fl4->flowi4_proto = iph->protocol;
 	fl4->daddr = reverse ? iph->saddr : iph->daddr;
 	fl4->saddr = reverse ? iph->daddr : iph->saddr;
-	fl4->flowi4_tos = iph->tos;
+	fl4->flowi4_tos = iph->tos & ~INET_ECN_MASK;
 
 	if (!ip_is_fragment(iph)) {
 		switch (iph->protocol) {
-- 
2.21.3


  reply	other threads:[~2022-01-10 13:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10 13:43 [PATCH v2 net 0/4] ipv4: Fix accidental RTO_ONLINK flags passed to ip_route_output_key_hash() Guillaume Nault
2022-01-10 13:43 ` Guillaume Nault [this message]
2022-01-10 13:43 ` [PATCH v2 net 2/4] gre: Don't accidentally set RTO_ONLINK in gre_fill_metadata_dst() Guillaume Nault
2022-01-10 13:43 ` [PATCH v2 net 3/4] libcxgb: Don't accidentally set RTO_ONLINK in cxgb_find_route() Guillaume Nault
2022-01-10 13:43 ` [PATCH v2 net 4/4] mlx5: Don't accidentally set RTO_ONLINK before mlx5e_route_lookup_ipv4_get() Guillaume Nault
2022-01-12  4:50 ` [PATCH v2 net 0/4] ipv4: Fix accidental RTO_ONLINK flags passed to ip_route_output_key_hash() patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ce6a296ddbf7e6700c40adeb24b69dc667a78823.1641821242.git.gnault@redhat.com \
    --to=gnault@redhat.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    --subject='Re: [PATCH v2 net 1/4] xfrm: Don'\''t accidentally set RTO_ONLINK in decode_session4()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).