Skip to content

Commit

Permalink
sock: sock_dequeue_err_skb() needs hard irq safety
Browse files Browse the repository at this point in the history
Non NAPI drivers can call skb_tstamp_tx() and then sock_queue_err_skb()
from hard IRQ context.

Therefore, sock_dequeue_err_skb() needs to block hard irq or
corruptions or hangs can happen.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Fixes: 364a9e9 ("sock: deduplicate errqueue dequeue")
Fixes: cb820f8 ("net: Provide a generic socket error queue delivery method for Tx time stamps.")
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Feb 20, 2015
1 parent 846cd66 commit 997d5c3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -3621,13 +3621,14 @@ struct sk_buff *sock_dequeue_err_skb(struct sock *sk)
{
struct sk_buff_head *q = &sk->sk_error_queue;
struct sk_buff *skb, *skb_next;
unsigned long flags;
int err = 0;

spin_lock_bh(&q->lock);
spin_lock_irqsave(&q->lock, flags);
skb = __skb_dequeue(q);
if (skb && (skb_next = skb_peek(q)))
err = SKB_EXT_ERR(skb_next)->ee.ee_errno;
spin_unlock_bh(&q->lock);
spin_unlock_irqrestore(&q->lock, flags);

sk->sk_err = err;
if (err)
Expand Down

0 comments on commit 997d5c3

Please sign in to comment.