netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-2.6 resent] af_packet: Don't use skb after dev_queue_xmit()
@ 2010-01-09 12:38 Jarek Poplawski
  2010-01-10 21:51 ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Jarek Poplawski @ 2010-01-09 12:38 UTC (permalink / raw)
  To: David Miller
  Cc: Michael Breuer, Stephen Hemminger, akpm, flyboy, linux-kernel,
	netdev

tpacket_snd() can change and kfree an skb after dev_queue_xmit(),
which is illegal.

With debugging by: Stephen Hemminger <shemminger@vyatta.com>

Reported-by: Michael Breuer <mbreuer@majjas.com>
Tested-by: Michael Breuer <mbreuer@majjas.com>
Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
---

 net/packet/af_packet.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index e0516a2..aba2049 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1021,9 +1021,10 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
 
 		status = TP_STATUS_SEND_REQUEST;
 		err = dev_queue_xmit(skb);
-		if (unlikely(err > 0 && (err = net_xmit_errno(err)) != 0))
-			goto out_xmit;
 		packet_increment_head(&po->tx_ring);
+		if (unlikely(err > 0 && (err = net_xmit_errno(err)) != 0))
+			goto out_put;
+
 		len_sum += tp_len;
 	} while (likely((ph != NULL) ||
 			((!(msg->msg_flags & MSG_DONTWAIT)) &&
@@ -1033,9 +1034,6 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
 	err = len_sum;
 	goto out_put;
 
-out_xmit:
-	skb->destructor = sock_wfree;
-	atomic_dec(&po->tx_ring.pending);
 out_status:
 	__packet_set_status(po, ph, status);
 	kfree_skb(skb);

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

end of thread, other threads:[~2010-01-11 23:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-09 12:38 [PATCH net-2.6 resent] af_packet: Don't use skb after dev_queue_xmit() Jarek Poplawski
2010-01-10 21:51 ` David Miller
2010-01-10 22:21   ` Jarek Poplawski
2010-01-11  8:04   ` [PATCH net-2.6 alt.3] " Jarek Poplawski
2010-01-11 22:30     ` Michael Breuer
2010-01-11 22:48       ` Jarek Poplawski
2010-01-11 23:07         ` David Miller
2010-01-11 23:39         ` 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).