diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-09-09 06:42:53 -0400 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-09-12 12:52:32 -0400 |
commit | 71212c9b04eba76faa4dca26ccd1552d6bb300c1 (patch) | |
tree | c94e136ed7989fd72d416cd506bcca99b5549472 | |
parent | 10151d7b03e23afce76a59f717f2616a10ddef86 (diff) |
netfilter: nf_tables: don't drop IPv6 packets that cannot parse transport
This is overly conservative and not flexible at all, so better let them
go through and let the filtering policy decide what to do with them. We
use skb_header_pointer() all over the place so we would just fail to
match when trying to access fields from malformed traffic.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | include/net/netfilter/nf_tables_ipv6.h | 6 | ||||
-rw-r--r-- | net/ipv6/netfilter/nf_tables_ipv6.c | 4 | ||||
-rw-r--r-- | net/ipv6/netfilter/nft_chain_route_ipv6.c | 4 |
3 files changed, 4 insertions, 10 deletions
diff --git a/include/net/netfilter/nf_tables_ipv6.h b/include/net/netfilter/nf_tables_ipv6.h index 39b7b717b540..d150b5066201 100644 --- a/include/net/netfilter/nf_tables_ipv6.h +++ b/include/net/netfilter/nf_tables_ipv6.h | |||
@@ -4,7 +4,7 @@ | |||
4 | #include <linux/netfilter_ipv6/ip6_tables.h> | 4 | #include <linux/netfilter_ipv6/ip6_tables.h> |
5 | #include <net/ipv6.h> | 5 | #include <net/ipv6.h> |
6 | 6 | ||
7 | static inline int | 7 | static inline void |
8 | nft_set_pktinfo_ipv6(struct nft_pktinfo *pkt, | 8 | nft_set_pktinfo_ipv6(struct nft_pktinfo *pkt, |
9 | struct sk_buff *skb, | 9 | struct sk_buff *skb, |
10 | const struct nf_hook_state *state) | 10 | const struct nf_hook_state *state) |
@@ -17,15 +17,13 @@ nft_set_pktinfo_ipv6(struct nft_pktinfo *pkt, | |||
17 | protohdr = ipv6_find_hdr(pkt->skb, &thoff, -1, &frag_off, NULL); | 17 | protohdr = ipv6_find_hdr(pkt->skb, &thoff, -1, &frag_off, NULL); |
18 | if (protohdr < 0) { | 18 | if (protohdr < 0) { |
19 | nft_set_pktinfo_proto_unspec(pkt, skb); | 19 | nft_set_pktinfo_proto_unspec(pkt, skb); |
20 | return -1; | 20 | return; |
21 | } | 21 | } |
22 | 22 | ||
23 | pkt->tprot_set = true; | 23 | pkt->tprot_set = true; |
24 | pkt->tprot = protohdr; | 24 | pkt->tprot = protohdr; |
25 | pkt->xt.thoff = thoff; | 25 | pkt->xt.thoff = thoff; |
26 | pkt->xt.fragoff = frag_off; | 26 | pkt->xt.fragoff = frag_off; |
27 | |||
28 | return 0; | ||
29 | } | 27 | } |
30 | 28 | ||
31 | static inline int | 29 | static inline int |
diff --git a/net/ipv6/netfilter/nf_tables_ipv6.c b/net/ipv6/netfilter/nf_tables_ipv6.c index 30b22f4dff55..05d05926962a 100644 --- a/net/ipv6/netfilter/nf_tables_ipv6.c +++ b/net/ipv6/netfilter/nf_tables_ipv6.c | |||
@@ -22,9 +22,7 @@ static unsigned int nft_do_chain_ipv6(void *priv, | |||
22 | { | 22 | { |
23 | struct nft_pktinfo pkt; | 23 | struct nft_pktinfo pkt; |
24 | 24 | ||
25 | /* malformed packet, drop it */ | 25 | nft_set_pktinfo_ipv6(&pkt, skb, state); |
26 | if (nft_set_pktinfo_ipv6(&pkt, skb, state) < 0) | ||
27 | return NF_DROP; | ||
28 | 26 | ||
29 | return nft_do_chain(&pkt, priv); | 27 | return nft_do_chain(&pkt, priv); |
30 | } | 28 | } |
diff --git a/net/ipv6/netfilter/nft_chain_route_ipv6.c b/net/ipv6/netfilter/nft_chain_route_ipv6.c index 71d995ff3108..01eb0f658366 100644 --- a/net/ipv6/netfilter/nft_chain_route_ipv6.c +++ b/net/ipv6/netfilter/nft_chain_route_ipv6.c | |||
@@ -32,9 +32,7 @@ static unsigned int nf_route_table_hook(void *priv, | |||
32 | u_int8_t hop_limit; | 32 | u_int8_t hop_limit; |
33 | u32 mark, flowlabel; | 33 | u32 mark, flowlabel; |
34 | 34 | ||
35 | /* malformed packet, drop it */ | 35 | nft_set_pktinfo_ipv6(&pkt, skb, state); |
36 | if (nft_set_pktinfo_ipv6(&pkt, skb, state) < 0) | ||
37 | return NF_DROP; | ||
38 | 36 | ||
39 | /* save source/dest address, mark, hoplimit, flowlabel, priority */ | 37 | /* save source/dest address, mark, hoplimit, flowlabel, priority */ |
40 | memcpy(&saddr, &ipv6_hdr(skb)->saddr, sizeof(saddr)); | 38 | memcpy(&saddr, &ipv6_hdr(skb)->saddr, sizeof(saddr)); |