Skip to contentSkip to conversation

inet: fix IP(V6)_RECVORIGDSTADDR for udp sockets

PATCH In review Willem de Bruijn 2 participants 2 messages Dec 22, 2016 – Dec 23, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 inet: fix IP(V6)_RECVORIGDSTADDR for udp sockets

From: Willem de Bruijn <[email protected]>

Socket cmsg IP(V6)_RECVORIGDSTADDR checks that port range lies within the packet. For sockets that have transport headers pulled, transport offset can be negative. Use signed comparison to avoid overflow.

Fixes e6afc8ace6dd ("udp: remove headers from UDP packets before queueing")
---
 net/ipv4/ip_sockglue.c | 2 +-
 net/ipv6/datagram.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/ip_sockglue.c +1 -1
index 8b13881..9760734 100644
@@ -148,7 +148,7 @@ static void ip_cmsg_recv_dstaddr(struct msghdr *msg, struct sk_buff *skb)
 	const struct iphdr *iph = ip_hdr(skb);
 	__be16 *ports = (__be16 *)skb_transport_header(skb);
 
-	if (skb_transport_offset(skb) + 4 > skb->len)
+	if (skb_transport_offset(skb) + 4 > (int)skb->len)
 		return;
 
 	/* All current transport protocols have the port numbers in the
net/ipv6/datagram.c +1 -1
index 0489e19..1407426 100644
@@ -701,7 +701,7 @@ void ip6_datagram_recv_specific_ctl(struct sock *sk, struct msghdr *msg,
 		struct sockaddr_in6 sin6;
 		__be16 *ports = (__be16 *) skb_transport_header(skb);
 
-		if (skb_transport_offset(skb) + 4 <= skb->len) {
+		if (skb_transport_offset(skb) + 4 <= (int)skb->len) {
 			/* All current transport protocols have the port numbers in the
 			 * first four bytes of the transport header and this function is
 			 * written with this assumption in mind.
Signature · 1 line
2.8.0.rc3.226.g39d4020
maintainer
#1 lore raw

From: Willem de Bruijn <[email protected]>
Date: Thu, 22 Dec 2016 18:19:16 -0500

Quoted 9 lines

From: Willem de Bruijn <[email protected]>

Socket cmsg IP(V6)_RECVORIGDSTADDR checks that port range lies within the packet. For sockets that have transport headers pulled, transport offset can be negative. Use signed comparison to avoid overflow.

Fixes e6afc8ace6dd ("udp: remove headers from UDP packets before queueing")

Applied and queued up for -stable.