mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 21:07:02 +09:00
af_packet: Don't use skb after dev_queue_xmit()
[ Upstream commit eb70df13ee ]
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>
With help from: David S. Miller <davem@davemloft.net>
Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Tested-by: Michael Breuer<mbreuer@majjas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
ecb7287c5f
commit
3125258f78
@@ -1028,8 +1028,20 @@ 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;
|
||||
if (unlikely(err > 0)) {
|
||||
err = net_xmit_errno(err);
|
||||
if (err && __packet_get_status(po, ph) ==
|
||||
TP_STATUS_AVAILABLE) {
|
||||
/* skb was destructed already */
|
||||
skb = NULL;
|
||||
goto out_status;
|
||||
}
|
||||
/*
|
||||
* skb was dropped but not destructed yet;
|
||||
* let's treat it like congestion or err < 0
|
||||
*/
|
||||
err = 0;
|
||||
}
|
||||
packet_increment_head(&po->tx_ring);
|
||||
len_sum += tp_len;
|
||||
} while (likely((ph != NULL) || ((!(msg->msg_flags & MSG_DONTWAIT))
|
||||
@@ -1039,9 +1051,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);
|
||||
|
||||
Reference in New Issue
Block a user