Skip to contentSkip to conversation

Patch "sctp: Fix mangled IPv4 addresses on a IPv6 listening socket" has been added to the 4.0-stable tree

PATCH [email protected] 1 participant 1 message Jun 13, 2015

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

sctp: Fix mangled IPv4 addresses on a IPv6 listening socket

to the 4.0-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
sctp-fix-mangled-ipv4-addresses-on-a-ipv6-listening-socket.patch
and it can be found in the queue-4.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Sat Jun 13 09:48:35 PDT 2015

From: Jason Gunthorpe <[email protected]>
Date: Tue, 26 May 2015 17:30:17 -0600
Subject: sctp: Fix mangled IPv4 addresses on a IPv6 listening socket

From: Jason Gunthorpe <[email protected]>

[ Upstream commit 9302d7bb0c5cd46be5706859301f18c137b2439f ]

sctp_v4_map_v6 was subtly writing and reading from members of a union in a way the clobbered data it needed to read before it read it.

Zeroing the v6 flowinfo overwrites the v4 sin_addr with 0, meaning that every place that calls sctp_v4_map_v6 gets ::ffff:0.0.0.0 as the result.

Reorder things to guarantee correct behaviour no matter what the union layout is.

This impacts user space clients that open an IPv6 SCTP socket and receive IPv4 connections. Prior to 299ee user space would see a sockaddr with AF_INET and a correct address, after 299ee the sockaddr is AF_INET6, but the address is wrong.

Fixes 299ee123e198 (sctp: Fixup v4mapped behaviour to comply with Sock API)
---
 include/net/sctp/sctp.h |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
include/net/sctp/sctp.h +5 -2
@@ -571,11 +571,14 @@ static inline void sctp_v6_map_v4(union
 /* Map v4 address to v4-mapped v6 address */
 static inline void sctp_v4_map_v6(union sctp_addr *addr)
 {
+	__be16 port;
+
+	port = addr->v4.sin_port;
+	addr->v6.sin6_addr.s6_addr32[3] = addr->v4.sin_addr.s_addr;
+	addr->v6.sin6_port = port;
 	addr->v6.sin6_family = AF_INET6;
 	addr->v6.sin6_flowinfo = 0;
 	addr->v6.sin6_scope_id = 0;
-	addr->v6.sin6_port = addr->v4.sin_port;
-	addr->v6.sin6_addr.s6_addr32[3] = addr->v4.sin_addr.s_addr;
 	addr->v6.sin6_addr.s6_addr32[0] = 0;
 	addr->v6.sin6_addr.s6_addr32[1] = 0;
 	addr->v6.sin6_addr.s6_addr32[2] = htonl(0x0000ffff);

Patches currently in stable-queue which might be from [email protected] are

queue-4.0/sctp-fix-mangled-ipv4-addresses-on-a-ipv6-listening-socket.patch