From: Miao Wang Date: Tue, 22 Jun 2021 04:24:50 +0000 (+0800) Subject: net/ipv4: swap flow ports when validating source X-Git-Tag: v4.19.198~274 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=0cb6b100b869164dcd4b48e8c236e0a9f1c8c0ad;p=users%2Fdwmw2%2Flinux.git net/ipv4: swap flow ports when validating source [ Upstream commit c69f114d09891adfa3e301a35d9e872b8b7b5a50 ] When doing source address validation, the flowi4 struct used for fib_lookup should be in the reverse direction to the given skb. fl4_dport and fl4_sport returned by fib4_rules_early_flow_dissect should thus be swapped. Fixes: 5a847a6e1477 ("net/ipv4: Initialize proto and ports in flow struct") Signed-off-by: Miao Wang Reviewed-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index b96aa88087be1..70e5e9e5d8351 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -353,6 +353,8 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst, fl4.flowi4_proto = 0; fl4.fl4_sport = 0; fl4.fl4_dport = 0; + } else { + swap(fl4.fl4_sport, fl4.fl4_dport); } if (fib_lookup(net, &fl4, &res, 0))