Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1299324

Re: [PATCH] net: Fix potential NULL pointer dereference in __skb_try_recv_datagram

From Jacob Siverskog <jacob@teenage.engineering>
Newsgroups linux.kernel
Subject Re: [PATCH] net: Fix potential NULL pointer dereference in __skb_try_recv_datagram
Date 2015-12-30 12:20 +0100
Message-ID <qLmXo-5SI-21@gated-at.bofh.it> (permalink)
References <qL7Ym-4Dn-3@gated-at.bofh.it> <qL8ro-4OT-25@gated-at.bofh.it> <qL8KL-5c0-37@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Dec 29, 2015 at 9:08 PM, David Miller <davem@davemloft.net> wrote:
> From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
> Date: Tue, 29 Dec 2015 19:42:36 +0000
>
>> Jacob Siverskog <jacob@teenage.engineering> writes:
>>> This should fix a NULL pointer dereference I encountered (dump
>>> below). Since __skb_unlink is called while walking,
>>> skb_queue_walk_safe should be used.
>>
>> The code in question is:
>  ...
>> __skb_unlink is only called prior to returning from the function.
>> Consequently, it won't affect the skb_queue_walk code.
>
> Agreed, this patch doesn't fix anything.

Ok. Thanks for your feedback. How do you believe the issue could be
solved? Investigating it gives:

static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list)
{
struct sk_buff *next, *prev;

list->qlen--;
     51c: e2433001 sub r3, r3, #1
     520: e58b3074 str r3, [fp, #116] ; 0x74
next   = skb->next;
prev   = skb->prev;
     524: e894000c ldm r4, {r2, r3}
skb->next  = skb->prev = NULL;
     528: e5841000 str r1, [r4]
     52c: e5841004 str r1, [r4, #4]
next->prev = prev;
     530: e5823004 str r3, [r2, #4]                          <--
trapping instruction (r2 NULL)

Register contents:
r7 : c58cfe1c  r6 : c06351d0  r5 : c77810ac  r4 : c583eac0
r3 : 00000000  r2 : 00000000  r1 : 00000000  r0 : 20000013

If I understand this correctly, then r4 = skb, r2 = next, r3 = prev.

Should there be a check for this in __skb_try_recv_datagram?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] net: Fix potential NULL pointer dereference in __skb_try_recv_datagram Jacob Siverskog <jacob@teenage.engineering> - 2015-12-29 20:20 +0100
  Re: [PATCH] net: Fix potential NULL pointer dereference in __skb_try_recv_datagram Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-12-29 20:50 +0100
    Re: [PATCH] net: Fix potential NULL pointer dereference in  __skb_try_recv_datagram David Miller <davem@davemloft.net> - 2015-12-29 21:10 +0100
      Re: [PATCH] net: Fix potential NULL pointer dereference in __skb_try_recv_datagram Jacob Siverskog <jacob@teenage.engineering> - 2015-12-30 12:20 +0100
        Re: [PATCH] net: Fix potential NULL pointer dereference in __skb_try_recv_datagram Eric Dumazet <edumazet@google.com> - 2015-12-30 14:30 +0100
          Re: [PATCH] net: Fix potential NULL pointer dereference in __skb_try_recv_datagram Eric Dumazet <edumazet@google.com> - 2015-12-30 15:40 +0100
          Re: [PATCH] net: Fix potential NULL pointer dereference in __skb_try_recv_datagram Jacob Siverskog <jacob@teenage.engineering> - 2015-12-30 15:40 +0100
            Re: [PATCH] net: Fix potential NULL pointer dereference in __skb_try_recv_datagram Cong Wang <xiyou.wangcong@gmail.com> - 2015-12-30 23:40 +0100
        Re: [PATCH] net: Fix potential NULL pointer dereference in __skb_try_recv_datagram Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-12-30 16:40 +0100

csiph-web