Netfilter fixes for net
Subsystems (3)
Pablo Neira Ayuso
maintainercover Netfilter fixes for net
Hi David,
The following patchset contains two one-liner fixes for your net tree, they are:
1) Disable fast hash operations for 2-bytes length keys which is leading to incorrect lookups in nf_tables, from Anatole Denis.
2) Reload pointer ipv4 header after ip_route_me_harder() given this may result in use-after-free due to skbuff header reallocation, patch from Tejaswi Tanikella.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thanks!
----------------------------------------------------------------
The following changes since commit 28e33f9d78eefe98ea86673ab31e988b37a9a738:
bpf: disallow arithmetic operations on context pointer (2017-10-18 13:21:13 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git HEAD
for you to fetch changes up to 7400bb4b5800831581a82f71700af6a5e815c3c8:
netfilter: nf_reject_ipv4: Fix use-after-free in send_reset (2017-11-01 12:15:29 +0100)
----------------------------------------------------------------
Anatole Denis (1):
netfilter: nft_set_hash: disable fast_ops for 2-len keys
Tejaswi Tanikella (1):
netfilter: nf_reject_ipv4: Fix use-after-free in send_reset
net/ipv4/netfilter/nf_reject_ipv4.c | 2 ++ net/netfilter/nft_set_hash.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-)
Pablo Neira Ayuso
maintainerPATCH 1/2 netfilter: nft_set_hash: disable fast_ops for 2-len keys
From: Anatole Denis <[email protected]>
jhash_1word of a u16 is a different value from jhash of the same u16 with length 2.
Since elements are always inserted in sets using jhash over the actual klen, this would lead to incorrect lookups on fixed-size sets with a key length of 2, as they would be inserted with hash value jhash(key, 2) and looked up with hash value jhash_1word(key), which is different.
Example reproducer(v4.13+), using anonymous sets which always have a fixed size:
table inet t {
chain c {
type filter hook output priority 0; policy accept;
tcp dport { 10001, 10003, 10005, 10007, 10009 } counter packets 4 bytes 240 reject tcp dport 10001 counter packets 4 bytes 240 reject
tcp dport 10003 counter packets 4 bytes 240 reject
tcp dport 10005 counter packets 4 bytes 240 reject
tcp dport 10007 counter packets 0 bytes 0 reject
tcp dport 10009 counter packets 4 bytes 240 reject
}
}
then use nc -z localhost <port> to probe; incorrectly hashed ports will pass through the set lookup and increment the counter of an individual rule.
jhash being seeded with a random value, it is not deterministic which ports will incorrectly hash, but in testing with 5 ports in the set I always had 4 or 5 with an incorrect hash value.
--- net/netfilter/nft_set_hash.c | 1 - 1 file changed, 1 deletion(-)
net/netfilter/nft_set_hash.c +0 -1
@@ -643,7 +643,6 @@ nft_hash_select_ops(const struct nft_ctx *ctx, const struct nft_set_desc *desc, {if (desc->size) {switch (desc->klen) { -case 2 :case 4 :return &nft_hash_fast_ops;default :
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH 2/2 netfilter: nf_reject_ipv4: Fix use-after-free in send_reset
In reply to Pablo Neira AyusoFrom: Tejaswi Tanikella <[email protected]>
niph is not updated after pskb_expand_head changes the skb head. It still points to the freed data, which is then used to update tot_len and checksum. This could cause use-after-free poison crash.
Update niph, if ip_route_me_harder does not fail.
This only affects the interaction with REJECT targets and br_netfilter.
--- net/ipv4/netfilter/nf_reject_ipv4.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv4/netfilter/nf_reject_ipv4.c +2 -0
@@ -132,6 +132,8 @@ void nf_send_reset(struct net *net, struct sk_buff *oldskb, int hook)if (ip_route_me_harder (net, nskb,RTN_UNSPEC )) goto free_nskb; + niph =ip_hdr (nskb); +/* "Never happens" */ if (nskb->len >dst_mtu (skb_dst (nskb))) goto free_nskb;
Signature · 1 line
2.11.0
David Miller
maintainerFrom: Pablo Neira Ayuso <[email protected]>
Date: Wed, 1 Nov 2017 19:48:10 +0100
Quoted 6 lines
The following patchset contains two one-liner fixes for your net tree, they are:
1) Disable fast hash operations for 2-bytes length keys which is leading to incorrect lookups in
nf_tables, from Anatole Denis.
Quoted 7 lines
2) Reload pointer ipv4 header after
ip_route_me_harder()given this may result in use-after-free due to skbuff header reallocation, patch from Tejaswi Tanikella.You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Pulled, thanks a lot Pablo.