xfrm: fix "disable_policy" on ipv4 early demux
authorEyal Birger <eyal.birger@gmail.com>
Sun, 9 Oct 2022 19:16:43 +0000 (22:16 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 Dec 2022 16:41:02 +0000 (17:41 +0100)
commitecc6ce4fdf0d62366604bc6a4cd6f50e19301a4e
tree31b72310e17909d249fcedd9a32c6b6fac331cb3
parent5a792c1d4d779cf9d23f188c023fe145656dab28
xfrm: fix "disable_policy" on ipv4 early demux

[ Upstream commit 3a5913183aa1b14148c723bda030e6102ad73008 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv4/ip_input.c