diff mbox series

[1/6] xfrm: fix "disable_policy" on ipv4 early demux

Message ID 20221123093117.434274-2-steffen.klassert@secunet.com (mailing list archive)
State Accepted
Commit 3a5913183aa1b14148c723bda030e6102ad73008
Delegated to: Netdev Maintainers
Headers show
Series [1/6] xfrm: fix "disable_policy" on ipv4 early demux | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Pull request is its own cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/cc_maintainers fail 1 blamed authors not CCed: eyal.birger@gmail.com; 5 maintainers not CCed: pabeni@redhat.com eyal.birger@gmail.com edumazet@google.com dsahern@kernel.org yoshfuji@linux-ipv6.org
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 2
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Steffen Klassert Nov. 23, 2022, 9:31 a.m. UTC
From: Eyal Birger <eyal.birger@gmail.com>

The commit in the "Fixes" tag tried to avoid a case where policy check
is ignored due to dst caching in next hops.

However, when the traffic is locally consumed, the dst may be cached
in a local TCP or UDP socket as part of early demux. In this case the
"disable_policy" flag is not checked as ip_route_input_noref() was only
called before caching, and thus, packets after the initial packet in a
flow will be dropped if not matching policies.

Fix by checking the "disable_policy" flag also when a valid dst is
already available.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=216557
Reported-by: Monil Patel <monil191989@gmail.com>
Fixes: e6175a2ed1f1 ("xfrm: fix "disable_policy" flag use when arriving from different devices")
Signed-off-by: Eyal Birger <eyal.birger@gmail.com>

----

v2: use dev instead of skb->dev
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/ipv4/ip_input.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

patchwork-bot+netdevbpf@kernel.org Nov. 24, 2022, 3:30 a.m. UTC | #1
Hello:

This series was applied to netdev/net.git (master)
by Steffen Klassert <steffen.klassert@secunet.com>:

On Wed, 23 Nov 2022 10:31:11 +0100 you wrote:
> From: Eyal Birger <eyal.birger@gmail.com>
> 
> The commit in the "Fixes" tag tried to avoid a case where policy check
> is ignored due to dst caching in next hops.
> 
> However, when the traffic is locally consumed, the dst may be cached
> in a local TCP or UDP socket as part of early demux. In this case the
> "disable_policy" flag is not checked as ip_route_input_noref() was only
> called before caching, and thus, packets after the initial packet in a
> flow will be dropped if not matching policies.
> 
> [...]

Here is the summary with links:
  - [1/6] xfrm: fix "disable_policy" on ipv4 early demux
    https://git.kernel.org/netdev/net/c/3a5913183aa1
  - [2/6] xfrm: lwtunnel: squelch kernel warning in case XFRM encap type is not available
    https://git.kernel.org/netdev/net/c/d83f7040e184
  - [3/6] xfrm: replay: Fix ESN wrap around for GSO
    https://git.kernel.org/netdev/net/c/4b549ccce941
  - [4/6] af_key: Fix send_acquire race with pfkey_register
    https://git.kernel.org/netdev/net/c/7f57f8165cb6
  - [5/6] xfrm: Fix oops in __xfrm_state_delete()
    https://git.kernel.org/netdev/net/c/b97df039a68b
  - [6/6] xfrm: Fix ignored return value in xfrm6_init()
    https://git.kernel.org/netdev/net/c/40781bfb836e

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 1b512390b3cf..e880ce77322a 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -366,6 +366,11 @@  static int ip_rcv_finish_core(struct net *net, struct sock *sk,
 					   iph->tos, dev);
 		if (unlikely(err))
 			goto drop_error;
+	} else {
+		struct in_device *in_dev = __in_dev_get_rcu(dev);
+
+		if (in_dev && IN_DEV_ORCONF(in_dev, NOPOLICY))
+			IPCB(skb)->flags |= IPSKB_NOPOLICY;
 	}
 
 #ifdef CONFIG_IP_ROUTE_CLASSID