linux-imx/include
Jason Gunthorpe d15530ab5f sctp: Fixup v4mapped behaviour to comply with Sock API
commit 299ee123e1 upstream.

The SCTP socket extensions API document describes the v4mapping option as
follows:

8.1.15.  Set/Clear IPv4 Mapped Addresses (SCTP_I_WANT_MAPPED_V4_ADDR)

   This socket option is a Boolean flag which turns on or off the
   mapping of IPv4 addresses.  If this option is turned on, then IPv4
   addresses will be mapped to V6 representation.  If this option is
   turned off, then no mapping will be done of V4 addresses and a user
   will receive both PF_INET6 and PF_INET type addresses on the socket.
   See [RFC3542] for more details on mapped V6 addresses.

This description isn't really in line with what the code does though.

Introduce addr_to_user (renamed addr_v4map), which should be called
before any sockaddr is passed back to user space. The new function
places the sockaddr into the correct format depending on the
SCTP_I_WANT_MAPPED_V4_ADDR option.

Audit all places that touched v4mapped and either sanely construct
a v4 or v6 address then call addr_to_user, or drop the
unnecessary v4mapped check entirely.

Audit all places that call addr_to_user and verify they are on a sycall
return path.

Add a custom getname that formats the address properly.

Several bugs are addressed:
 - SCTP_I_WANT_MAPPED_V4_ADDR=0 often returned garbage for
   addresses to user space
 - The addr_len returned from recvmsg was not correct when
   returning AF_INET on a v6 socket
 - flowlabel and scope_id were not zerod when promoting
   a v4 to v6
 - Some syscalls like bind and connect behaved differently
   depending on v4mapped

Tested bind, getpeername, getsockname, connect, and recvmsg for proper
behaviour in v4mapped = 1 and 0 cases.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Tested-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2018-02-13 18:32:16 +00:00
..
acpi ACPICA: Tables: Fix an issue that FACS initialization is performed twice 2015-08-12 16:33:18 +02:00
asm-generic KAISER: Kernel Address Isolation 2018-01-07 01:46:49 +00:00
crypto crypto: hmac - require that the underlying hash algorithm is unkeyed 2018-01-01 20:51:05 +00:00
drm drm: Fix an unwanted master inheritance v2 2015-12-30 02:26:00 +00:00
keys
linux blktrace: Fix potential deadlock between delete & sysfs ops 2018-02-13 18:32:15 +00:00
math-emu
media tuner: Fix numberspace conflict between xc4000 and pti 5nf05 tuners 2012-01-25 16:13:51 -08:00
misc [media] altera-stapl: it is time to move out from staging 2011-09-23 15:00:57 -03:00
mtd mtd: kill old field for `struct mtd_info_user' 2011-09-11 15:57:44 +03:00
net sctp: Fixup v4mapped behaviour to comply with Sock API 2018-02-13 18:32:16 +00:00
pcmcia
rdma IB/core: Add inline function to validate port 2017-10-12 15:27:14 +01:00
rxrpc
scsi scsi: sd: Implement blacklist option for WRITE SAME w/ UNMAP 2018-01-01 20:50:55 +00:00
sound ALSA: seq: Avoid invalid lockdep class warning 2018-01-01 20:51:02 +00:00
target target: Fix lookup of dynamic NodeACLs during cached demo-mode operation 2013-03-06 03:24:03 +00:00
trace KVM: Fix stack-out-of-bounds read in write_mmio 2018-01-01 20:51:04 +00:00
video OMAPDSS: HDMI: PHY burnout fix 2012-03-12 12:31:38 -07:00
xen xen: Add RING_COPY_REQUEST() 2016-01-22 21:40:06 +00:00
Kbuild