Skip to content

Commit 110c433

Browse files
Eric Dumazetdavem330
authored andcommitted
net: fix a race in sock_queue_err_skb()
As soon as an skb is queued into socket error queue, another thread can consume it, so we are not allowed to reference skb anymore, or risk use after free. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4a7e7c2 commit 110c433

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/core/skbuff.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3161,6 +3161,8 @@ static void sock_rmem_free(struct sk_buff *skb)
31613161
*/
31623162
int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb)
31633163
{
3164+
int len = skb->len;
3165+
31643166
if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
31653167
(unsigned)sk->sk_rcvbuf)
31663168
return -ENOMEM;
@@ -3175,7 +3177,7 @@ int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb)
31753177

31763178
skb_queue_tail(&sk->sk_error_queue, skb);
31773179
if (!sock_flag(sk, SOCK_DEAD))
3178-
sk->sk_data_ready(sk, skb->len);
3180+
sk->sk_data_ready(sk, len);
31793181
return 0;
31803182
}
31813183
EXPORT_SYMBOL(sock_queue_err_skb);

0 commit comments

Comments
 (0)