* [PATCH] LLC: Avoid potential NULL dereference in net/llc/af_llc.c::llc_ui_accept() .
@ 2006-11-02 0:21 Jesper Juhl
2006-11-02 0:27 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2006-11-02 0:21 UTC (permalink / raw)
To: linux-kernel; +Cc: Jay Schulist, Arnaldo Carvalho de Melo, davem, Jesper Juhl
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.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 2652ead..a3c885f 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -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;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] LLC: Avoid potential NULL dereference in net/llc/af_llc.c::llc_ui_accept() .
2006-11-02 0:21 [PATCH] LLC: Avoid potential NULL dereference in net/llc/af_llc.c::llc_ui_accept() Jesper Juhl
@ 2006-11-02 0:27 ` David Miller
2006-11-02 0:30 ` Jesper Juhl
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2006-11-02 0:27 UTC (permalink / raw)
To: jesper.juhl; +Cc: linux-kernel, jschlst, acme
From: Jesper Juhl <jesper.juhl@gmail.com>
Date: Thu, 2 Nov 2006 01:21:53 +0100
> 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.
>
>
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] LLC: Avoid potential NULL dereference in net/llc/af_llc.c::llc_ui_accept() .
2006-11-02 0:27 ` David Miller
@ 2006-11-02 0:30 ` Jesper Juhl
0 siblings, 0 replies; 3+ messages in thread
From: Jesper Juhl @ 2006-11-02 0:30 UTC (permalink / raw)
To: David Miller; +Cc: linux-kernel, jschlst, acme
On 02/11/06, David Miller <davem@davemloft.net> wrote:
> From: Jesper Juhl <jesper.juhl@gmail.com>
> Date: Thu, 2 Nov 2006 01:21:53 +0100
>
> > 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.
> >
> >
> > Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
>
> 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.
--
Jesper Juhl <jesper.juhl@gmail.com>
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-11-02 0:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-02 0:21 [PATCH] LLC: Avoid potential NULL dereference in net/llc/af_llc.c::llc_ui_accept() Jesper Juhl
2006-11-02 0:27 ` David Miller
2006-11-02 0:30 ` Jesper Juhl
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.