All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ipv6: check raw payload size correctly in ioctl
@ 2017-04-26  0:43 Jamie Bainbridge
  2017-04-26 19:00 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Jamie Bainbridge @ 2017-04-26  0:43 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, netdev
  Cc: Jamie Bainbridge

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 <jbainbri@redhat.com>
---
 net/ipv6/raw.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index f174e76e6505d4045e940c9fceef765d2aaa937d..0da6a12b5472e322d679572c7244e5c9bc467741 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -1178,8 +1178,7 @@ static int rawv6_ioctl(struct sock *sk, int cmd, unsigned long arg)
 		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);
 	}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ipv6: check raw payload size correctly in ioctl
  2017-04-26  0:43 [PATCH] ipv6: check raw payload size correctly in ioctl Jamie Bainbridge
@ 2017-04-26 19:00 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-04-26 19:00 UTC (permalink / raw)
  To: jbainbri; +Cc: kuznet, jmorris, yoshfuji, kaber, netdev

From: Jamie Bainbridge <jbainbri@redhat.com>
Date: Wed, 26 Apr 2017 10:43:27 +1000

> 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 <jbainbri@redhat.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-26 19:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-26  0:43 [PATCH] ipv6: check raw payload size correctly in ioctl Jamie Bainbridge
2017-04-26 19:00 ` David Miller

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.