netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: fix a race in sock_queue_err_skb()
@ 2012-04-06  8:49 Eric Dumazet
  2012-04-06  9:08 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2012-04-06  8:49 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

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 <eric.dumazet@gmail.com>
---
 net/core/skbuff.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index f223cdc..baf8d28 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3161,6 +3161,8 @@ static void sock_rmem_free(struct sk_buff *skb)
  */
 int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb)
 {
+	int len = skb->len;
+
 	if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
 	    (unsigned)sk->sk_rcvbuf)
 		return -ENOMEM;
@@ -3175,7 +3177,7 @@ int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb)
 
 	skb_queue_tail(&sk->sk_error_queue, skb);
 	if (!sock_flag(sk, SOCK_DEAD))
-		sk->sk_data_ready(sk, skb->len);
+		sk->sk_data_ready(sk, len);
 	return 0;
 }
 EXPORT_SYMBOL(sock_queue_err_skb);

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

* Re: [PATCH] net: fix a race in sock_queue_err_skb()
  2012-04-06  8:49 [PATCH] net: fix a race in sock_queue_err_skb() Eric Dumazet
@ 2012-04-06  9:08 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-04-06  9:08 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 06 Apr 2012 10:49:10 +0200

> 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 <eric.dumazet@gmail.com>

Applied and queued up for -stable.

Thanks for following up on this.

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

end of thread, other threads:[~2012-04-06  9:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-06  8:49 [PATCH] net: fix a race in sock_queue_err_skb() Eric Dumazet
2012-04-06  9:08 ` 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).