: 2.6.24 regression fixes
Subsystems (3)
cover : 2.6.24 regression fixes
These patches fix some netfilter regressions in 2.6.24 introduced by the removal of double skb pointers:
- a BUG when enlarging packets queued to userspace
- inverted error checking of skb_make_writable in bridge netfilter
- use of incorrect return codes after skb_make_writable errors in bridge netfilter
Please apply, thanks.
net/bridge/netfilter/ebt_dnat.c | 4 ++-- net/bridge/netfilter/ebt_redirect.c | 4 ++-- net/bridge/netfilter/ebt_snat.c | 4 ++-- net/ipv4/netfilter/arpt_mangle.c | 2 +- net/ipv4/netfilter/ip_queue.c | 12 +++++++----- net/ipv6/netfilter/ip6_queue.c | 10 ++++++---- net/netfilter/nfnetlink_queue.c | 10 ++++++---- 7 files changed, 26 insertions(+), 20 deletions(-)
Patrick McHardy (3):
[NETFILTER]: nfnetlink_queue: fix SKB_LINEAR_ASSERT when mangling packet data [NETFILTER]: Fix incorrect use of skb_make_writable
[NETFILTER]: fix ebtable targets return
PATCH 1/3 : nfnetlink_queue: fix SKB_LINEAR_ASSERT when mangling packet data
[NETFILTER]: nfnetlink_queue: fix SKB_LINEAR_ASSERT when mangling packet data
Upstream commit e2b58a67:
As reported by Tomas Simonaitis <[email protected]>, inserting new data in skbs queued over {ip,ip6,nfnetlink}_queue triggers a SKB_LINEAR_ASSERT in skb_put().
Going back through the git history, it seems this bug is present since at least 2.6.12-rc2, probably even since the removal of skb_linearize() for netfilter.
Linearize non-linear skbs through skb_copy_expand() when enlarging them. Tested by Thomas, fixes bugzilla #9933.
---
commit 2e1a9528d31fda88923d6615eb4933df07f59762
tree 46cc8d288a33e945bec29f529a8f56d47c1b37bd
parent c78cb439103bf7deba5feb64921398d0ff93179a
author Patrick McHardy <[email protected]> Mon, 25 Feb 2008 14:51:16 +0100 committer Patrick McHardy <[email protected]> Mon, 25 Feb 2008 14:51:16 +0100
net/ipv4/netfilter/ip_queue.c | 12 +++++++----- net/ipv6/netfilter/ip6_queue.c | 10 ++++++---- net/netfilter/nfnetlink_queue.c | 10 ++++++---- 3 files changed, 19 insertions(+), 13 deletions(-)
net/ipv4/netfilter/ip_queue.c +7 -5
@@ -336,8 +336,8 @@ static int ipq_mangle_ipv4(ipq_verdict_msg_t *v, struct ipq_queue_entry *e) {int diff; -int err;struct iphdr *user_iph = (struct iphdr *)v->payload; +struct sk_buff *nskb;if (v->data_len <sizeof (*user_iph))return 0 ;
@@ -349,14 +349,16 @@ ipq_mangle_ipv4(ipq_verdict_msg_t *v, struct ipq_queue_entry *e)if (v->data_len >0xFFFF )return -EINVAL ;if (diff >skb_tailroom (e->skb)) { - err =pskb_expand_head (e->skb,0 , + nskb =skb_copy_expand (e->skb,0 , diff -skb_tailroom (e->skb),GFP_ATOMIC ); -if (err) { +if (!nskb) {printk (KERN_WARNING "ip_queue: error " -"in mangle, dropping packet: %d\n" , -err); -return err; +"in mangle, dropping packet\n" ); +return -ENOMEM ; } +kfree_skb (e->skb); + e->skb = nskb; }skb_put (e->skb, diff); }
net/ipv6/netfilter/ip6_queue.c +6 -4
@@ -333,8 +333,8 @@ static int ipq_mangle_ipv6(ipq_verdict_msg_t *v, struct ipq_queue_entry *e) {int diff; -int err;struct ipv6hdr *user_iph = (struct ipv6hdr *)v->payload; +struct sk_buff *nskb;if (v->data_len <sizeof (*user_iph))return 0 ;
@@ -346,14 +346,16 @@ ipq_mangle_ipv6(ipq_verdict_msg_t *v, struct ipq_queue_entry *e)if (v->data_len >0xFFFF )return -EINVAL ;if (diff >skb_tailroom (e->skb)) { - err =pskb_expand_head (e->skb,0 , + nskb =skb_copy_expand (e->skb,0 , diff -skb_tailroom (e->skb),GFP_ATOMIC ); -if (err) { +if (!nskb) {printk (KERN_WARNING "ip6_queue: OOM " "in mangle, dropping packet\n" ); -return err; +return -ENOMEM ; } +kfree_skb (e->skb); + e->skb = nskb; }skb_put (e->skb, diff); }
net/netfilter/nfnetlink_queue.c +6 -4
@@ -616,8 +616,8 @@ err_out_put:static int nfqnl_mangle (void *data,int data_len,struct nfqnl_queue_entry *e) { +struct sk_buff *nskb;int diff; -int err; diff = data_len - e->skb->len;if (diff <0 ) {
@@ -627,14 +627,16 @@ nfqnl_mangle(void *data, int data_len, struct nfqnl_queue_entry *e)if (data_len >0xFFFF )return -EINVAL ;if (diff >skb_tailroom (e->skb)) { - err =pskb_expand_head (e->skb,0 , + nskb =skb_copy_expand (e->skb,0 , diff -skb_tailroom (e->skb),GFP_ATOMIC ); -if (err) { +if (!nskb) {printk (KERN_WARNING "nf_queue: OOM " "in mangle, dropping packet\n" ); -return err; +return -ENOMEM ; } +kfree_skb (e->skb); + e->skb = nskb; }skb_put (e->skb, diff); }
Re: [NETFILTER -stable 01/03]: nfnetlink_queue: fix SKB_LINEAR_ASSERT when mangling packet data
Quoted 11 lines · Patrick McHardy
[NETFILTER]:
nfnetlink_queue: fixSKB_LINEAR_ASSERTwhen mangling packet dataUpstream commit
e2b58a67:As reported by Tomas Simonaitis <[email protected]>, inserting new data in skbs queued over {ip,ip6,nfnetlink}_queue triggers a
SKB_LINEAR_ASSERTinskb_put().Going back through the git history, it seems this bug is present since at least 2.6.12-rc2, probably even since the removal of
skb_linearize()for netfilter.
Just to avoid confusion: this part of the changelog is wrong, I initialy didn't realize this was just introduced recently and forgot to edit it out for -stable.
PATCH 2/3 : Fix incorrect use of skb_make_writable
In reply to Patrick McHardy[NETFILTER]: Fix incorrect use of skb_make_writable
Upstream commit eb1197bc0:
http://bugzilla.kernel.org/show_bug.cgi?id=9920
The function skb_make_writable returns true or false.
---
commit 3040fdefd830230ef6c2515715755f312a24f814
tree 05308bc27435162f4b2060158ee87abf786e8d0e
parent 2e1a9528d31fda88923d6615eb4933df07f59762
author Patrick McHardy <[email protected]> Mon, 25 Feb 2008 14:51:17 +0100 committer Patrick McHardy <[email protected]> Mon, 25 Feb 2008 14:51:17 +0100
net/bridge/netfilter/ebt_dnat.c | 2 +- net/bridge/netfilter/ebt_redirect.c | 2 +- net/bridge/netfilter/ebt_snat.c | 2 +- net/ipv4/netfilter/arpt_mangle.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
net/bridge/netfilter/ebt_dnat.c +1 -1
@@ -20,7 +20,7 @@ static int ebt_target_dnat(struct sk_buff *skb, unsigned int hooknr, {struct ebt_nat_info *info = (struct ebt_nat_info *)data; -if (skb_make_writable (skb,0 )) +if (!skb_make_writable (skb,0 ))return NF_DROP ;memcpy (eth_hdr (skb)->h_dest, info->mac,ETH_ALEN );
net/bridge/netfilter/ebt_redirect.c +1 -1
@@ -21,7 +21,7 @@ static int ebt_target_redirect(struct sk_buff *skb, unsigned int hooknr, {struct ebt_redirect_info *info = (struct ebt_redirect_info *)data; -if (skb_make_writable (skb,0 )) +if (!skb_make_writable (skb,0 ))return NF_DROP ;if (hooknr !=NF_BR_BROUTING )
net/bridge/netfilter/ebt_snat.c +1 -1
@@ -22,7 +22,7 @@ static int ebt_target_snat(struct sk_buff *skb, unsigned int hooknr, {struct ebt_nat_info *info = (struct ebt_nat_info *) data; -if (skb_make_writable (skb,0 )) +if (!skb_make_writable (skb,0 ))return NF_DROP ;memcpy (eth_hdr (skb)->h_source, info->mac,ETH_ALEN );
net/ipv4/netfilter/arpt_mangle.c +1 -1
@@ -19,7 +19,7 @@ target(struct sk_buff *skb,unsigned char *arpptr;int pln, hln; -if (skb_make_writable (skb, skb->len)) +if (!skb_make_writable (skb, skb->len))return NF_DROP ; arp =arp_hdr (skb);
PATCH 3/3 : fix ebtable targets return
In reply to Patrick McHardy[NETFILTER]: fix ebtable targets return
Upstream commit 1b04ab459:
The function ebt_do_table doesn't take NF_DROP as a verdict from the targets.
---
commit a07e4d33874c30069459f82917b2d334e5c58125
tree 91dda0811ebb02f60ba50c447834bb2bdb781cf6
parent 3040fdefd830230ef6c2515715755f312a24f814
author Patrick McHardy <[email protected]> Mon, 25 Feb 2008 14:51:17 +0100 committer Patrick McHardy <[email protected]> Mon, 25 Feb 2008 14:51:17 +0100
net/bridge/netfilter/ebt_dnat.c | 2 +- net/bridge/netfilter/ebt_redirect.c | 2 +- net/bridge/netfilter/ebt_snat.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
net/bridge/netfilter/ebt_dnat.c +1 -1
@@ -21,7 +21,7 @@ static int ebt_target_dnat(struct sk_buff *skb, unsigned int hooknr,struct ebt_nat_info *info = (struct ebt_nat_info *)data;if (!skb_make_writable (skb,0 )) -return NF_DROP ; +return EBT_DROP ;memcpy (eth_hdr (skb)->h_dest, info->mac,ETH_ALEN );return info->target;
net/bridge/netfilter/ebt_redirect.c +1 -1
@@ -22,7 +22,7 @@ static int ebt_target_redirect(struct sk_buff *skb, unsigned int hooknr,struct ebt_redirect_info *info = (struct ebt_redirect_info *)data;if (!skb_make_writable (skb,0 )) -return NF_DROP ; +return EBT_DROP ;if (hooknr !=NF_BR_BROUTING ) memcpy(eth_hdr(skb)->h_dest,
net/bridge/netfilter/ebt_snat.c +1 -1
@@ -23,7 +23,7 @@ static int ebt_target_snat(struct sk_buff *skb, unsigned int hooknr,struct ebt_nat_info *info = (struct ebt_nat_info *) data;if (!skb_make_writable (skb,0 )) -return NF_DROP ; +return EBT_DROP ;memcpy (eth_hdr (skb)->h_source, info->mac,ETH_ALEN ); if (!(info->target & NAT_ARP_BIT) &&