提交 584505aa 编写于 作者: M Miao Wang 提交者: Yang Yingliang

net/ipv4: swap flow ports when validating source

stable inclusion
from linux-4.19.198
commit 0cb6b100b869164dcd4b48e8c236e0a9f1c8c0ad

--------------------------------

[ Upstream commit c69f114d ]

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: 5a847a6e ("net/ipv4: Initialize proto and ports in flow struct")
Signed-off-by: NMiao Wang <shankerwangmiao@gmail.com>
Reviewed-by: NDavid Ahern <dsahern@kernel.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 f946cf1e
......@@ -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))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册