core/netfilter.c: possible use of freed skb
Subsystems (2)
Hi Dave,
In nf_reinject(), info->okfn(skb) is called when the verdict is NF_ACCEPT. This okfn deals with the skb and is responsible for freeing the skb. Unfortunately the current code in nf_reinject() still uses this possibly freed skb.
The patch below fixes this without introducing any new code. It should be ok to dev_put the devices earlier, thanks to the preceding rcu_read_lock.
I also moved the dev_put's of info->{in,out}dev to keep the code together.
cheers,
Bart
net/core/netfilter.c renamed from net/core/netfilter.c.old +12 -13
@@ -557,6 +557,18 @@ void nf_reinject(struct sk_buff *skb, strcu_read_lock (); +/* Release those devices we held, or Alexey will kill me. */ +if (info->indev)dev_put (info->indev); +if (info->outdev)dev_put (info->outdev); +#if defined(CONFIG_BRIDGE ) || defined(CONFIG_BRIDGE_MODULE ) +if (skb->nf_bridge) { +if (skb->nf_bridge->physindev) +dev_put (skb->nf_bridge->physindev); +if (skb->nf_bridge->physoutdev) +dev_put (skb->nf_bridge->physoutdev); + } +#endif +/* Drop reference to owner of hook which queued us. */ module_put (info->elem->owner);
@@ -599,19 +611,6 @@ void nf_reinject(struct sk_buff *skb, st }rcu_read_unlock (); -/* Release those devices we held, or Alexey will kill me. */ -if (info->indev)dev_put (info->indev); -if (info->outdev)dev_put (info->outdev); -#if defined(CONFIG_BRIDGE ) || defined(CONFIG_BRIDGE_MODULE ) -if (skb->nf_bridge) { -if (skb->nf_bridge->physindev) -dev_put (skb->nf_bridge->physindev); -if (skb->nf_bridge->physoutdev) -dev_put (skb->nf_bridge->physoutdev); - } -#endif - -if (verdict ==NF_DROP )kfree_skb (skb);
Quoted 5 lines · On Sun, 27 Jul 2003 16:55:15 +0200 Bart De Schuymer <[email protected]> wrote:
In
nf_reinject(),info->okfn(skb)is called when the verdict isNF_ACCEPT. This okfn deals with the skb and is responsible for freeing the skb. Unfortunately the current code innf_reinject()still uses this possibly freed skb.
The patch below fixes this without introducing any new code.
This patch looks OK to me, can I get an ACK from the netfilter folks?
Quoted 2 lines · David S. Miller
This patch looks OK to me, can I get an ACK from the netfilter folks?
Dave, the patch looks fine to me.
Sorry for the delay, still catching up with everything that was lost while I was at OLS.
Please apply!
Signature · 5 lines
- Harald Welte <[email protected]> http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
David S. Miller
AppliedQuoted 6 lines · On Wed, 30 Jul 2003 16:06:29 +0200 Harald Welte <[email protected]> wrote:
Quoted 2 lines · David S. Miller
This patch looks OK to me, can I get an ACK from the netfilter folks?
Dave, the patch looks fine to me.
Applied, thanks guys.