* [PATCH 0/5] netfilter fixes for 3.4-rc2
@ 2012-04-10 12:48 pablo
2012-04-10 12:48 ` [PATCH 1/5] netfilter: nf_ct_tcp: don't scale the size of the window up twice pablo
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: pablo @ 2012-04-10 12:48 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
From: Pablo Neira Ayuso <pablo@netfilter.org>
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(-)
--
1.7.2.5
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/5] netfilter: nf_ct_tcp: don't scale the size of the window up twice
2012-04-10 12:48 [PATCH 0/5] netfilter fixes for 3.4-rc2 pablo
@ 2012-04-10 12:48 ` pablo
2012-04-10 12:48 ` [PATCH 2/5] netfilter: ip6_tables: ip6t_ext_hdr is now static inline pablo
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pablo @ 2012-04-10 12:48 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
From: Changli Gao <xiaosuo@gmail.com>
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.
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Acked-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_proto_tcp.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 361eade..0d07a1d 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -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
--
1.7.2.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/5] netfilter: ip6_tables: ip6t_ext_hdr is now static inline
2012-04-10 12:48 [PATCH 0/5] netfilter fixes for 3.4-rc2 pablo
2012-04-10 12:48 ` [PATCH 1/5] netfilter: nf_ct_tcp: don't scale the size of the window up twice pablo
@ 2012-04-10 12:48 ` pablo
2012-04-10 12:48 ` [PATCH 3/5] netfilter: nf_ct_ipv4: handle invalid IPv4 and IPv6 packets consistently pablo
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pablo @ 2012-04-10 12:48 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
From: Pablo Neira Ayuso <pablo@netfilter.org>
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=y
CONFIG_IP6_NF_IPTABLES=m
ip6t_ext_hdr is fairly small and it is called in the packet path.
Make it static inline.
Reported-by: Simon Kirby <sim@netnation.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
include/linux/netfilter_ipv6/ip6_tables.h | 12 +++++++++++-
net/ipv6/netfilter/ip6_tables.c | 14 --------------
2 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h
index f549adc..1bc898b 100644
--- a/include/linux/netfilter_ipv6/ip6_tables.h
+++ b/include/linux/netfilter_ipv6/ip6_tables.h
@@ -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);
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 94874b0..9d4e155 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -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);
--
1.7.2.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/5] netfilter: nf_ct_ipv4: handle invalid IPv4 and IPv6 packets consistently
2012-04-10 12:48 [PATCH 0/5] netfilter fixes for 3.4-rc2 pablo
2012-04-10 12:48 ` [PATCH 1/5] netfilter: nf_ct_tcp: don't scale the size of the window up twice pablo
2012-04-10 12:48 ` [PATCH 2/5] netfilter: ip6_tables: ip6t_ext_hdr is now static inline pablo
@ 2012-04-10 12:48 ` pablo
2012-04-10 12:49 ` [PATCH 4/5] netfilter: nf_ct_ipv4: packets with wrong ihl are invalid pablo
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pablo @ 2012-04-10 12:48 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
From: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
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.
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index de9da21..750b06a 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -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;
--
1.7.2.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/5] netfilter: nf_ct_ipv4: packets with wrong ihl are invalid
2012-04-10 12:48 [PATCH 0/5] netfilter fixes for 3.4-rc2 pablo
` (2 preceding siblings ...)
2012-04-10 12:48 ` [PATCH 3/5] netfilter: nf_ct_ipv4: handle invalid IPv4 and IPv6 packets consistently pablo
@ 2012-04-10 12:49 ` pablo
2012-04-10 12:49 ` [PATCH 5/5] netfilter: nf_conntrack: fix incorrect logic in nf_conntrack_init_net pablo
2012-04-10 18:43 ` [PATCH 0/5] netfilter fixes for 3.4-rc2 David Miller
5 siblings, 0 replies; 7+ messages in thread
From: pablo @ 2012-04-10 12:49 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
From: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
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.
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index 750b06a..cf73cc7 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -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;
}
--
1.7.2.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/5] netfilter: nf_conntrack: fix incorrect logic in nf_conntrack_init_net
2012-04-10 12:48 [PATCH 0/5] netfilter fixes for 3.4-rc2 pablo
` (3 preceding siblings ...)
2012-04-10 12:49 ` [PATCH 4/5] netfilter: nf_ct_ipv4: packets with wrong ihl are invalid pablo
@ 2012-04-10 12:49 ` pablo
2012-04-10 18:43 ` [PATCH 0/5] netfilter fixes for 3.4-rc2 David Miller
5 siblings, 0 replies; 7+ messages in thread
From: pablo @ 2012-04-10 12:49 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
From: Gao feng <gaofeng@cn.fujitsu.com>
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.
Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_core.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 3cc4487..729f157 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -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:
--
1.7.2.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/5] netfilter fixes for 3.4-rc2
2012-04-10 12:48 [PATCH 0/5] netfilter fixes for 3.4-rc2 pablo
` (4 preceding siblings ...)
2012-04-10 12:49 ` [PATCH 5/5] netfilter: nf_conntrack: fix incorrect logic in nf_conntrack_init_net pablo
@ 2012-04-10 18:43 ` David Miller
5 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2012-04-10 18:43 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel, netdev
From: pablo@netfilter.org
Date: Tue, 10 Apr 2012 14:48:56 +0200
> The following patchset includes netfilter fixes for 3.4-rc2, they are:
...
> You can pull changes these from:
>
> git://1984.lsi.us.es/net master
Pulled, thanks a lot Pablo.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-04-10 18:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-10 12:48 [PATCH 0/5] netfilter fixes for 3.4-rc2 pablo
2012-04-10 12:48 ` [PATCH 1/5] netfilter: nf_ct_tcp: don't scale the size of the window up twice pablo
2012-04-10 12:48 ` [PATCH 2/5] netfilter: ip6_tables: ip6t_ext_hdr is now static inline pablo
2012-04-10 12:48 ` [PATCH 3/5] netfilter: nf_ct_ipv4: handle invalid IPv4 and IPv6 packets consistently pablo
2012-04-10 12:49 ` [PATCH 4/5] netfilter: nf_ct_ipv4: packets with wrong ihl are invalid pablo
2012-04-10 12:49 ` [PATCH 5/5] netfilter: nf_conntrack: fix incorrect logic in nf_conntrack_init_net pablo
2012-04-10 18:43 ` [PATCH 0/5] netfilter fixes for 3.4-rc2 David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).