Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753893AbbL2TnM (ORCPT ); Tue, 29 Dec 2015 14:43:12 -0500 Received: from tiger.mobileactivedefense.com ([217.174.251.109]:56460 "EHLO tiger.mobileactivedefense.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753612AbbL2Tm6 (ORCPT ); Tue, 29 Dec 2015 14:42:58 -0500 From: Rainer Weikusat To: Jacob Siverskog Cc: netdev@vger.kernel.org, "David S . Miller" , Herbert Xu , Rainer Weikusat , Eric Dumazet , Konstantin Khlebnikov , Al Viro , linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: Fix potential NULL pointer dereference in __skb_try_recv_datagram In-Reply-To: <1451416224-15871-1-git-send-email-jacob@teenage.engineering> (Jacob Siverskog's message of "Tue, 29 Dec 2015 20:10:24 +0100") References: <1451416224-15871-1-git-send-email-jacob@teenage.engineering> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Date: Tue, 29 Dec 2015 19:42:36 +0000 Message-ID: <87y4cdyrbn.fsf@doppelsaurus.mobileactivedefense.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (tiger.mobileactivedefense.com [217.174.251.109]); Tue, 29 Dec 2015 19:42:44 +0000 (GMT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1125 Lines: 41 Jacob Siverskog 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/