netfilter fixes for 3.4-rc2
Subsystems (3)
[email protected]
maintainercover netfilter fixes for 3.4-rc2
From: Pablo Neira Ayuso <[email protected]>
Hi David,
The following patchset includes netfilter fixes for 3.4-rc2, they are:
* A couple of fixes for the IPv4 connection tracker from Jozsef. One to behave consistently with IPv6 and to follow the conntrack policy (ie. don't drop, the user controls what to do by dropping invalid packet via iptables). The other one checks for invalid IPv4 ihl values that go further the packet boundary.
* Fix missing ip6t_ext_hdr symbol if ip6tables is compiled xt_LOG is compiled built-in and ip6tables as module by myself.
* One fix for the error path of nf_conntrack_init_net introduced by the recently added nf_conntrack_timeout infrastructure from Gao Feng.
* We don't want to scale the window twice for picked up connection in the nf_ct_tcp code, from Changli Gao.
You can pull changes these from:
git://1984.lsi.us.es/net master
Changli Gao (1):
netfilter: nf_ct_tcp: don't scale the size of the window up twice
Gao feng (1):
netfilter: nf_conntrack: fix incorrect logic in nf_conntrack_init_net
Jozsef Kadlecsik (2):
netfilter: nf_ct_ipv4: handle invalid IPv4 and IPv6 packets consistently
netfilter: nf_ct_ipv4: packets with wrong ihl are invalid
Pablo Neira Ayuso (1):
netfilter: ip6_tables: ip6t_ext_hdr is now static inline
include/linux/netfilter_ipv6/ip6_tables.h | 12 +++++++++++- net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 12 ++++++++++-- net/ipv6/netfilter/ip6_tables.c | 14 -------------- net/netfilter/nf_conntrack_core.c | 2 +- net/netfilter/nf_conntrack_proto_tcp.c | 4 ++-- 5 files changed, 24 insertions(+), 20 deletions(-)
Signature · 1 line
1.7.2.5
[email protected]
maintainerPATCH 1/5 netfilter: nf_ct_tcp: don't scale the size of the window up twice
From: Changli Gao <[email protected]>
For a picked up connection, the window win is scaled twice: one is by the initialization code, and the other is by the sender updating code.
I use the temporary variable swin instead of modifying the variable win.
--- net/netfilter/nf_conntrack_proto_tcp.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_proto_tcp.c +2 -2
@@ -584,8 +584,8 @@ static bool tcp_in_window(const struct nf_conn *ct,* Let's try to use the data from the packet. */ sender->td_end = end; - win <<= sender->td_scale; - sender->td_maxwin = (win ==0 ?1 : win); + swin = win << sender->td_scale; + sender->td_maxwin = (swin ==0 ?1 : swin); sender->td_maxend = end + sender->td_maxwin;/* * We haven't seen traffic in the other direction yet
Signature · 1 line
1.7.2.5
[email protected]
maintainerPATCH 2/5 netfilter: ip6_tables: ip6t_ext_hdr is now static inline
In reply to [email protected]From: Pablo Neira Ayuso <[email protected]>
We may hit this in xt_LOG:
net/built-in.o:xt_LOG.c:function dump_ipv6_packet:
error: undefined reference to 'ip6t_ext_hdr'
happens with these config options:
CONFIG_NETFILTER_XT_TARGET_LOG=yCONFIG_IP6_NF_IPTABLES=m
ip6t_ext_hdr is fairly small and it is called in the packet path. Make it static inline.
--- include/linux/netfilter_ipv6/ip6_tables.h | 12 +++++++++++- net/ipv6/netfilter/ip6_tables.c | 14 -------------- 2 files changed, 11 insertions(+), 15 deletions(-)
include/linux/netfilter_ipv6/ip6_tables.h +11 -1
@@ -287,7 +287,17 @@ extern unsigned int ip6t_do_table(struct sk_buff *skb, struct xt_table *table);/* Check for an extension */ -extern int ip6t_ext_hdr (u8 nexthdr); +static inline int +ip6t_ext_hdr (u8 nexthdr) +{return (nexthdr ==IPPROTO_HOPOPTS ) || + (nexthdr ==IPPROTO_ROUTING ) || + (nexthdr ==IPPROTO_FRAGMENT ) || + (nexthdr ==IPPROTO_ESP ) || + (nexthdr ==IPPROTO_AH ) || + (nexthdr ==IPPROTO_NONE ) || + (nexthdr ==IPPROTO_DSTOPTS ); +} +/* find specified header and get offset to it */ extern int ipv6_find_hdr (const struct sk_buff *skb,unsigned int *offset,int target,unsigned short *fragoff);
net/ipv6/netfilter/ip6_tables.c +0 -14
@@ -78,19 +78,6 @@ EXPORT_SYMBOL_GPL(ip6t_alloc_initial_table);Hence the start of any table is given by get_table() below. */ -/* Check for an extension */ -int -ip6t_ext_hdr (u8 nexthdr) -{ -return (nexthdr ==IPPROTO_HOPOPTS ) || - (nexthdr ==IPPROTO_ROUTING ) || - (nexthdr ==IPPROTO_FRAGMENT ) || - (nexthdr ==IPPROTO_ESP ) || - (nexthdr ==IPPROTO_AH ) || - (nexthdr ==IPPROTO_NONE ) || - (nexthdr ==IPPROTO_DSTOPTS ); -} -/* Returns whether matches rule or not. */ /* Performance critical - called for every packet */ static inline bool
@@ -2366,7 +2353,6 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,EXPORT_SYMBOL (ip6t_register_table);EXPORT_SYMBOL (ip6t_unregister_table);EXPORT_SYMBOL (ip6t_do_table); -EXPORT_SYMBOL (ip6t_ext_hdr);EXPORT_SYMBOL (ipv6_find_hdr);module_init (ip6_tables_init);
Signature · 1 line
1.7.2.5
[email protected]
maintainerPATCH 3/5 netfilter: nf_ct_ipv4: handle invalid IPv4 and IPv6 packets consistently
In reply to [email protected]From: Jozsef Kadlecsik <[email protected]>
IPv6 conntrack marked invalid packets as INVALID and let the user drop those by an explicit rule, while IPv4 conntrack dropped such packets itself.
IPv4 conntrack is changed so that it marks INVALID packets and let the user to drop them.
--- net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +2 -2
@@ -74,12 +74,12 @@ static int ipv4_get_l4proto(const struct sk_buff *skb, unsigned int nhoff, iph =skb_header_pointer (skb, nhoff,sizeof (_iph), &_iph);if (iph ==NULL ) -return -NF_DROP ; +return -NF_ACCEPT ;/* Conntrack defragments packets, we might still see fragments * inside ICMP packets though. */ if (iph->frag_off &htons (IP_OFFSET )) -return -NF_DROP ; +return -NF_ACCEPT ; *dataoff = nhoff + (iph->ihl <<2 ); *protonum = iph->protocol;
Signature · 1 line
1.7.2.5
[email protected]
maintainerPATCH 4/5 netfilter: nf_ct_ipv4: packets with wrong ihl are invalid
In reply to [email protected]From: Jozsef Kadlecsik <[email protected]>
It was reported that the Linux kernel sometimes logs:
klogd: [2629147.402413] kernel BUG at net / netfilter / nf_conntrack_proto_tcp.c: 447!
klogd: [1072212.887368] kernel BUG at net / netfilter / nf_conntrack_proto_tcp.c: 392
ipv4_get_l4proto() in nf_conntrack_l3proto_ipv4.c and tcp_error() in nf_conntrack_proto_tcp.c should catch malformed packets, so the errors at the indicated lines - TCP options parsing - should not happen. However, tcp_error() relies on the "dataoff" offset to the TCP header, calculated by ipv4_get_l4proto(). But ipv4_get_l4proto() does not check bogus ihl values in IPv4 packets, which then can slip through tcp_error() and get caught at the TCP options parsing routines.
The patch fixes ipv4_get_l4proto() by invalidating packets with bogus ihl value.
The patch closes netfilter bugzilla id 771.
--- net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +8 -0
@@ -84,6 +84,14 @@ static int ipv4_get_l4proto(const struct sk_buff *skb, unsigned int nhoff, *dataoff = nhoff + (iph->ihl <<2 ); *protonum = iph->protocol; +/* Check bogus IP headers */ +if (*dataoff > skb->len) { +pr_debug ("nf_conntrack_ipv4: bogus IPv4 packet: " +"nhoff %u, ihl %u, skblen %u\n" , + nhoff, iph->ihl <<2 , skb->len); +return -NF_ACCEPT ; + } +return NF_ACCEPT ; }
Signature · 1 line
1.7.2.5
[email protected]
maintainerPATCH 5/5 netfilter: nf_conntrack: fix incorrect logic in nf_conntrack_init_net
In reply to [email protected]From: Gao feng <[email protected]>
in function nf_conntrack_init_net,when nf_conntrack_timeout_init falied, we should call nf_conntrack_ecache_fini to do rollback.
but the current code calls nf_conntrack_timeout_fini.
--- net/netfilter/nf_conntrack_core.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/netfilter/nf_conntrack_core.c +1 -1
@@ -1592,7 +1592,7 @@ static int nf_conntrack_init_net(struct net *net)return 0 ; err_timeout: -nf_conntrack_timeout_fini (net); +nf_conntrack_ecache_fini (net); err_ecache:nf_conntrack_tstamp_fini (net); err_tstamp:
Signature · 1 line
1.7.2.5
David Miller
maintainerFrom: [email protected]
Date: Tue, 10 Apr 2012 14:48:56 +0200
Quoted 1 line
The following patchset includes netfilter fixes for 3.4-rc2, they are:
...
Quoted 3 lines
You can pull changes these from:
git://1984.lsi.us.es/netmaster
Pulled, thanks a lot Pablo.