All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH/RFC] core/netfilter.c: possible use of freed skb
@ 2003-07-27 14:55 Bart De Schuymer
  2003-07-27 22:50 ` David S. Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Bart De Schuymer @ 2003-07-27 14:55 UTC (permalink / raw)
  To: David S.Miller; +Cc: netfilter-devel

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

--- linux-2.6.0-test1/net/core/netfilter.c.old	2003-07-27 16:22:50.000000000 +0200
+++ linux-2.6.0-test1/net/core/netfilter.c	2003-07-27 16:30:48.000000000 +0200
@@ -557,6 +557,18 @@ void nf_reinject(struct sk_buff *skb, st
 
 	rcu_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);
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-07-30 23:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-07-27 14:55 [PATCH/RFC] core/netfilter.c: possible use of freed skb Bart De Schuymer
2003-07-27 22:50 ` David S. Miller
2003-07-30 14:06   ` Harald Welte
2003-07-30 23:56     ` David S. Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.