Skip to contentSkip to conversation

LLC: Avoid potential NULL dereference in net/llc/af_llc.c::llc_ui_accept() .

PATCH In review Jesper Juhl 2 participants 3 messages Nov 2, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 LLC: Avoid potential NULL dereference in net/llc/af_llc.c::llc_ui_accept() .

Since skb_dequeue() may return NULL we risk dereferencing a NULL pointer at
if (!skb->sk)
This patch avoids that by also testing for a NULL skb.

---

net/llc/af_llc.c +1 -1
index 2652ead..a3c885f 100644
@@ -620,7 +620,7 @@ static int llc_ui_accept(struct socket *
 	        llc_sk(sk)->laddr.lsap);
 	skb = skb_dequeue(&sk->sk_receive_queue);
 	rc = -EINVAL;
-	if (!skb->sk)
+	if (!skb || !skb->sk)
 		goto frees;
 	rc = 0;
 	newsk = skb->sk;
maintainer
#1 lore raw

From: Jesper Juhl <[email protected]>
Date: Thu, 2 Nov 2006 01:21:53 +0100

Quoted 6 lines

Since skb_dequeue() may return NULL we risk dereferencing a NULL pointer at
if (!skb->sk)
This patch avoids that by also testing for a NULL skb.

It can't return NULL in this context because we just checked skb_queue_empty() with the socket lock held and llc_wait_data() will return zero only if skb_queue_empty() is false.

I know it's hard for automated tools to see this, but it's not reasonable to put this extra check in there since it is superfluous due to the above mentioned invariants.

#2 lore raw
Quoted 10 lines · David Miller

From: Jesper Juhl <[email protected]>
Date: Thu, 2 Nov 2006 01:21:53 +0100

Quoted 6 lines

Since skb_dequeue() may return NULL we risk dereferencing a NULL pointer at
if (!skb->sk)
This patch avoids that by also testing for a NULL skb.

Quoted 8 lines

It can't return NULL in this context because we just checked skb_queue_empty() with the socket lock held and llc_wait_data() will return zero only if skb_queue_empty() is false.

I know it's hard for automated tools to see this, but it's not reasonable to put this extra check in there since it is superfluous due to the above mentioned invariants.

Fair enough. Ignore the patch.
Thank you for the explanation.

Signature · 3 lines
Jesper Juhl <[email protected]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html