From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752689AbdEAVyC (ORCPT ); Mon, 1 May 2017 17:54:02 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58082 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752649AbdEAVch (ORCPT ); Mon, 1 May 2017 17:32:37 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jamie Bainbridge , "David S. Miller" Subject: [PATCH 4.9 36/54] ipv6: check raw payload size correctly in ioctl Date: Mon, 1 May 2017 14:31:43 -0700 Message-Id: <20170501212633.232362871@linuxfoundation.org> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170501212631.798128131@linuxfoundation.org> References: <20170501212631.798128131@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jamie Bainbridge [ Upstream commit 105f5528b9bbaa08b526d3405a5bcd2ff0c953c8 ] In situations where an skb is paged, the transport header pointer and tail pointer can be the same because the skb contents are in frags. This results in ioctl(SIOCINQ/FIONREAD) incorrectly returning a length of 0 when the length to receive is actually greater than zero. skb->len is already correctly set in ip6_input_finish() with pskb_pull(), so use skb->len as it always returns the correct result for both linear and paged data. Signed-off-by: Jamie Bainbridge Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/raw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -1171,8 +1171,7 @@ static int rawv6_ioctl(struct sock *sk, spin_lock_bh(&sk->sk_receive_queue.lock); skb = skb_peek(&sk->sk_receive_queue); if (skb) - amount = skb_tail_pointer(skb) - - skb_transport_header(skb); + amount = skb->len; spin_unlock_bh(&sk->sk_receive_queue.lock); return put_user(amount, (int __user *)arg); }