: Netfilter fixes
Subsystems (2)
cover : Netfilter fixes
Hi Dave,
following a few netfilter fixes for 2.6.19, fixing invalid use of skb_trim in netfilter userspace queueing, conflicting optname values for ip6tables revision support and another byteorder problem in nfnetlink_log.
Please apply, thanks.
include/linux/in6.h | 12 +++++++++++- include/linux/netfilter/x_tables.h | 16 ---------------- include/linux/netfilter_arp/arp_tables.h | 25 +++++++++++++------------ include/linux/netfilter_ipv4/ip_tables.h | 27 +++++++++++++++------------ include/linux/netfilter_ipv6/ip6_tables.h | 27 +++++++++++++++------------ net/ipv4/netfilter/ip_queue.c | 7 ++++--- net/ipv6/netfilter/ip6_queue.c | 7 ++++--- net/ipv6/netfilter/ip6_tables.c | 2 +- net/netfilter/nfnetlink_log.c | 2 +- net/netfilter/nfnetlink_queue.c | 7 ++++--- 10 files changed, 68 insertions(+), 64 deletions(-)
Patrick McHardy:
[NETFILTER]: nfnetlink_log: fix byteorder of NFULA_SEQ_GLOBAL [NETFILTER]: Use pskb_trim in {ip,ip6,nfnetlink}_queue [NETFILTER]: ip6_tables: use correct nexthdr value in ipv6_find_hdr()
Yasuyuki Kozakai:
[NETFILTER]: ip6_tables: fixed conflicted optname for getsockopt
PATCH 1/4 : nfnetlink_log: fix byteorder of NFULA_SEQ_GLOBAL
[NETFILTER]: nfnetlink_log: fix byteorder of NFULA_SEQ_GLOBAL
NFULA_SEQ_GLOBAL should be in network byteorder.
Spotted by Al Viro.
---
commit 7c1ac6f74a10cb9fe0800de7e9a1626497dde438
tree bae81087a86be5325fd94b6c6ec26023328e09e0
parent bb831eb2027c12a740ad4e4ad78f2a0e841ae808
author Patrick McHardy <[email protected]> Tue, 14 Nov 2006 07:53:30 +0100 committer Patrick McHardy <[email protected]> Tue, 14 Nov 2006 07:53:30 +0100
net/netfilter/nfnetlink_log.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/netfilter/nfnetlink_log.c +1 -1
@@ -544,7 +544,7 @@ #endif }/* global sequence number */ if (inst->flags &NFULNL_CFG_F_SEQ_GLOBAL ) { - tmp_uint =atomic_inc_return (&global_seq); + tmp_uint =htonl (atomic_inc_return (&global_seq));NFA_PUT (inst->skb,NFULA_SEQ_GLOBAL ,sizeof (tmp_uint), &tmp_uint); }
PATCH 2/4 : Use pskb_trim in {ip,ip6,nfnetlink}_queue
In reply to Patrick McHardy[NETFILTER]: Use pskb_trim in {ip,ip6,nfnetlink}_queue
Based on patch by James D. Nurmi:
I've got some code very dependant on nfnetlink_queue, and turned up a large number of warns coming from skb_trim. While it's quite possibly my code, having not seen it on older kernels made me a bit suspect.
Anyhow, based on some googling I turned up this thread:
http://lkml.org/lkml/2006/8/13/56
And believe the issue to be related, so attached is a small patch to the kernel -- not sure if this is completely correct, but for anyone else hitting the WARN_ON(1) in skbuff.h, it might be helpful..
Ported to ip6_queue and nfnetlink_queue and added return value checks.
---
commit 0c9a47cafdd2f6db3e090359392efd64d5d027cd
tree ebefab5aef3e079f489a11d1072318406a72e503
parent 7c1ac6f74a10cb9fe0800de7e9a1626497dde438
author Patrick McHardy <[email protected]> Tue, 14 Nov 2006 07:57:11 +0100 committer Patrick McHardy <[email protected]> Tue, 14 Nov 2006 07:57:11 +0100
net/ipv4/netfilter/ip_queue.c | 7 ++++--- net/ipv6/netfilter/ip6_queue.c | 7 ++++--- net/netfilter/nfnetlink_queue.c | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-)
net/ipv4/netfilter/ip_queue.c +4 -3
@@ -351,9 +351,10 @@ ipq_mangle_ipv4(ipq_verdict_msg_t *v, stif (v->data_len <sizeof (*user_iph))return 0 ; diff = v->data_len - e->skb->len; -if (diff <0 ) -skb_trim (e->skb, v->data_len); -else if (diff >0 ) { +if (diff <0 ) { +if (pskb_trim (e->skb, v->data_len)) +return -ENOMEM ; + }else if (diff >0 ) {if (v->data_len >0xFFFF )return -EINVAL ;if (diff >skb_tailroom (e->skb)) {
net/ipv6/netfilter/ip6_queue.c +4 -3
@@ -349,9 +349,10 @@ ipq_mangle_ipv6(ipq_verdict_msg_t *v, stif (v->data_len <sizeof (*user_iph))return 0 ; diff = v->data_len - e->skb->len; -if (diff <0 ) -skb_trim (e->skb, v->data_len); -else if (diff >0 ) { +if (diff <0 ) { +if (pskb_trim (e->skb, v->data_len)) +return -ENOMEM ; + }else if (diff >0 ) {if (v->data_len >0xFFFF )return -EINVAL ;if (diff >skb_tailroom (e->skb)) {
net/netfilter/nfnetlink_queue.c +4 -3
@@ -622,9 +622,10 @@ nfqnl_mangle(void *data, int data_len, sint diff; diff = data_len - e->skb->len; -if (diff <0 ) -skb_trim (e->skb, data_len); -else if (diff >0 ) { +if (diff <0 ) { +if (pskb_trim (e->skb, data_len)) +return -ENOMEM ; + }else if (diff >0 ) {if (data_len >0xFFFF )return -EINVAL ;if (diff >skb_tailroom (e->skb)) {
PATCH 3/4 : ip6_tables: fixed conflicted optname for getsockopt
In reply to Patrick McHardy[NETFILTER]: ip6_tables: fixed conflicted optname for getsockopt
66 and 67 for getsockopt on IPv6 socket is doubly used for IPv6 Advanced API and ip6tables. This moves numbers for ip6tables to 68 and 69. This also kills XT_SO_* because {ip,ip6,arp}_tables doesn't have so much common numbers now.
The old userland tools keep to behave as ever, because old kernel always calls functions of IPv6 Advanced API for their numbers.
---
commit 73d0810541a170f679076824e0a8765ea6017a10
tree 42dad7f440cc4a9fcc91f4825dd27cedb8605dbc
parent 0c9a47cafdd2f6db3e090359392efd64d5d027cd
author Yasuyuki Kozakai <[email protected]> Tue, 14 Nov 2006 07:57:41 +0100 committer Patrick McHardy <[email protected]> Tue, 14 Nov 2006 07:57:41 +0100
include/linux/in6.h | 12 +++++++++++- include/linux/netfilter/x_tables.h | 16 ---------------- include/linux/netfilter_arp/arp_tables.h | 25 +++++++++++++------------ include/linux/netfilter_ipv4/ip_tables.h | 27 +++++++++++++++------------ include/linux/netfilter_ipv6/ip6_tables.h | 27 +++++++++++++++------------ 5 files changed, 54 insertions(+), 53 deletions(-)
include/linux/in6.h +11 -1
@@ -225,7 +225,7 @@ #define IPV6_USE_MIN_MTU 63#endif /* -* Netfilter +* Netfilter (1) * * Following socket options are used in ip6_tables; * see include/linux/netfilter_ipv6/ip6_tables.h.
@@ -240,4 +240,14 @@ #endif#define IPV6_RECVTCLASS 66#define IPV6_TCLASS 67 +/* +* Netfilter (2) +* +* Following socket options are used in ip6_tables; +* see include/linux/netfilter_ipv6/ip6_tables.h. +* +* IP6T_SO_GET_REVISION_MATCH 68 +* IP6T_SO_GET_REVISION_TARGET 69 +*/ +#endif
include/linux/netfilter/x_tables.h +0 -16
@@ -96,22 +96,6 @@ #define XT_STANDARD_TARGET ""/* Error verdict. */ #define XT_ERROR_TARGET "ERROR" -/* -* New IP firewall options for [gs]etsockopt at the RAW IP level. -* Unlike BSD Linux inherits IP options so you don't have to use a raw -* socket for this. Instead we check rights in the calls. */ -#define XT_BASE_CTL 64/* base for firewall socket options */ - -#define XT_SO_SET_REPLACE (XT_BASE_CTL) -#define XT_SO_SET_ADD_COUNTERS (XT_BASE_CTL + 1) -#define XT_SO_SET_MAX XT_SO_SET_ADD_COUNTERS - -#define XT_SO_GET_INFO (XT_BASE_CTL) -#define XT_SO_GET_ENTRIES (XT_BASE_CTL + 1) -#define XT_SO_GET_REVISION_MATCH (XT_BASE_CTL + 2) -#define XT_SO_GET_REVISION_TARGET (XT_BASE_CTL + 3) -#define XT_SO_GET_MAX XT_SO_GET_REVISION_TARGET -#define SET_COUNTER (c,b,p) do { (c).bcnt = (b); (c).pcnt = (p); } while(0)#define ADD_COUNTER (c,b,p) do { (c).bcnt += (b); (c).pcnt += (p); } while(0)
include/linux/netfilter_arp/arp_tables.h +13 -12
@@ -112,19 +112,20 @@ struct arpt_entry* New IP firewall options for [gs]etsockopt at the RAW IP level. * Unlike BSD Linux inherits IP options so you don't have to use a raw * socket for this. Instead we check rights in the calls. +* +* ATTENTION: check linux/in.h before adding new number here. */ -#define ARPT_CTL_OFFSET 32 -#define ARPT_BASE_CTL (XT_BASE_CTL+ARPT_CTL_OFFSET) - -#define ARPT_SO_SET_REPLACE (XT_SO_SET_REPLACE+ARPT_CTL_OFFSET) -#define ARPT_SO_SET_ADD_COUNTERS (XT_SO_SET_ADD_COUNTERS+ARPT_CTL_OFFSET) -#define ARPT_SO_SET_MAX (XT_SO_SET_MAX+ARPT_CTL_OFFSET) - -#define ARPT_SO_GET_INFO (XT_SO_GET_INFO+ARPT_CTL_OFFSET) -#define ARPT_SO_GET_ENTRIES (XT_SO_GET_ENTRIES+ARPT_CTL_OFFSET) -/* #define ARPT_SO_GET_REVISION_MATCH XT_SO_GET_REVISION_MATCH */ -#define ARPT_SO_GET_REVISION_TARGET (XT_SO_GET_REVISION_TARGET+ARPT_CTL_OFFSET) -#define ARPT_SO_GET_MAX (XT_SO_GET_REVISION_TARGET+ARPT_CTL_OFFSET) +#define ARPT_BASE_CTL 96 + +#define ARPT_SO_SET_REPLACE (ARPT_BASE_CTL) +#define ARPT_SO_SET_ADD_COUNTERS (ARPT_BASE_CTL + 1) +#define ARPT_SO_SET_MAX ARPT_SO_SET_ADD_COUNTERS + +#define ARPT_SO_GET_INFO (ARPT_BASE_CTL) +#define ARPT_SO_GET_ENTRIES (ARPT_BASE_CTL + 1) +/* #define ARPT_SO_GET_REVISION_MATCH (APRT_BASE_CTL + 2) */ +#define ARPT_SO_GET_REVISION_TARGET (ARPT_BASE_CTL + 3) +#define ARPT_SO_GET_MAX (ARPT_SO_GET_REVISION_TARGET)/* CONTINUE verdict for targets */ #define ARPT_CONTINUE XT_CONTINUE
include/linux/netfilter_ipv4/ip_tables.h +15 -12
@@ -101,18 +101,21 @@ struct ipt_entry/* * New IP firewall options for [gs]etsockopt at the RAW IP level. * Unlike BSD Linux inherits IP options so you don't have to use a raw -* socket for this. Instead we check rights in the calls. */ -#define IPT_BASE_CTL XT_BASE_CTL - -#define IPT_SO_SET_REPLACE XT_SO_SET_REPLACE -#define IPT_SO_SET_ADD_COUNTERS XT_SO_SET_ADD_COUNTERS -#define IPT_SO_SET_MAX XT_SO_SET_MAX - -#define IPT_SO_GET_INFO XT_SO_GET_INFO -#define IPT_SO_GET_ENTRIES XT_SO_GET_ENTRIES -#define IPT_SO_GET_REVISION_MATCH XT_SO_GET_REVISION_MATCH -#define IPT_SO_GET_REVISION_TARGET XT_SO_GET_REVISION_TARGET -#define IPT_SO_GET_MAX XT_SO_GET_REVISION_TARGET +* socket for this. Instead we check rights in the calls. +* +* ATTENTION: check linux/in.h before adding new number here. +*/ +#define IPT_BASE_CTL 64 + +#define IPT_SO_SET_REPLACE (IPT_BASE_CTL) +#define IPT_SO_SET_ADD_COUNTERS (IPT_BASE_CTL + 1) +#define IPT_SO_SET_MAX IPT_SO_SET_ADD_COUNTERS + +#define IPT_SO_GET_INFO (IPT_BASE_CTL) +#define IPT_SO_GET_ENTRIES (IPT_BASE_CTL + 1) +#define IPT_SO_GET_REVISION_MATCH (IPT_BASE_CTL + 2) +#define IPT_SO_GET_REVISION_TARGET (IPT_BASE_CTL + 3) +#define IPT_SO_GET_MAX IPT_SO_GET_REVISION_TARGET#define IPT_CONTINUE XT_CONTINUE#define IPT_RETURN XT_RETURN
include/linux/netfilter_ipv6/ip6_tables.h +15 -12
@@ -107,18 +107,21 @@ struct ip6t_entry/* * New IP firewall options for [gs]etsockopt at the RAW IP level. * Unlike BSD Linux inherits IP options so you don't have to use -* a raw socket for this. Instead we check rights in the calls. */ -#define IP6T_BASE_CTL XT_BASE_CTL - -#define IP6T_SO_SET_REPLACE XT_SO_SET_REPLACE -#define IP6T_SO_SET_ADD_COUNTERS XT_SO_SET_ADD_COUNTERS -#define IP6T_SO_SET_MAX XT_SO_SET_MAX - -#define IP6T_SO_GET_INFO XT_SO_GET_INFO -#define IP6T_SO_GET_ENTRIES XT_SO_GET_ENTRIES -#define IP6T_SO_GET_REVISION_MATCH XT_SO_GET_REVISION_MATCH -#define IP6T_SO_GET_REVISION_TARGET XT_SO_GET_REVISION_TARGET -#define IP6T_SO_GET_MAX XT_SO_GET_REVISION_TARGET +* a raw socket for this. Instead we check rights in the calls. +* +* ATTENTION: check linux/in6.h before adding new number here. +*/ +#define IP6T_BASE_CTL 64 + +#define IP6T_SO_SET_REPLACE (IP6T_BASE_CTL) +#define IP6T_SO_SET_ADD_COUNTERS (IP6T_BASE_CTL + 1) +#define IP6T_SO_SET_MAX IP6T_SO_SET_ADD_COUNTERS + +#define IP6T_SO_GET_INFO (IP6T_BASE_CTL) +#define IP6T_SO_GET_ENTRIES (IP6T_BASE_CTL + 1) +#define IP6T_SO_GET_REVISION_MATCH (IP6T_BASE_CTL + 4) +#define IP6T_SO_GET_REVISION_TARGET (IP6T_BASE_CTL + 5) +#define IP6T_SO_GET_MAX IP6T_SO_GET_REVISION_TARGET/* CONTINUE verdict for targets */ #define IP6T_CONTINUE XT_CONTINUE
PATCH 4/4 : ip6_tables: use correct nexthdr value in ipv6_find_hdr()
In reply to Patrick McHardy[NETFILTER]: ip6_tables: use correct nexthdr value in ipv6_find_hdr()
nexthdr is NEXTHDR_FRAGMENT, the nexthdr value from the fragment header is hp->nexthdr.
---
commit 85ac8773cc9bc1301cd3be323cb046c0b98998b7
tree 97048b2f41047e7f2bf440fe5ca8ec9986e3fe5c
parent 73d0810541a170f679076824e0a8765ea6017a10
author Patrick McHardy <[email protected]> Tue, 14 Nov 2006 07:57:54 +0100 committer Patrick McHardy <[email protected]> Tue, 14 Nov 2006 07:57:54 +0100
net/ipv6/netfilter/ip6_tables.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/ipv6/netfilter/ip6_tables.c +1 -1
@@ -1494,7 +1494,7 @@ int ipv6_find_hdr(const struct sk_buff *if (_frag_off) {if (target <0 && ((!ipv6_ext_hdr (hp->nexthdr)) || - nexthdr ==NEXTHDR_NONE )) { + hp->nexthdr ==NEXTHDR_NONE )) {if (fragoff) *fragoff = _frag_off;return hp->nexthdr;
David Miller
maintainerFrom: Patrick McHardy <[email protected]>
Date: Tue, 14 Nov 2006 08:03:26 +0100 (MET)
Quoted 5 lines
following a few netfilter fixes for 2.6.19, fixing invalid use of
skb_trimin netfilter userspace queueing, conflicting optname values for ip6tables revision support and another byteorder problem innfnetlink_log.Please apply, thanks.
All applied, thanks a lot Patrick.