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


Groups > linux.kernel > #1299101

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

From Rainer Weikusat <rweikusat@mobileactivedefense.com>
Newsgroups linux.kernel
Subject Re: [PATCH] net: Fix potential NULL pointer dereference in __skb_try_recv_datagram
Date 2015-12-29 20:50 +0100
Message-ID <qL8ro-4OT-25@gated-at.bofh.it> (permalink)
References <qL7Ym-4Dn-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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_queue_walk(queue, skb) {
	*last = skb;
	*peeked = skb->peeked;
	if (flags & MSG_PEEK) {
		if (_off >= skb->len && (skb->len || _off ||
					 skb->peeked)) {
			_off -= skb->len;
			continue;
		}

		skb = skb_set_peeked(skb);
		error = PTR_ERR(skb);
		if (IS_ERR(skb)) {
			spin_unlock_irqrestore(&queue->lock,
					       cpu_flags);
			goto no_packet;
		}
                
		atomic_inc(&skb->users);
	}  else
		__skb_unlink(skb, queue);

	spin_unlock_irqrestore(&queue->lock, cpu_flags);
	*off = _off;
	return skb;
}

__skb_unlink is only called prior to returning from the function.
Consequently, it won't affect the skb_queue_walk code.
--
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