summaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/bits/socket.h
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2016-03-18 17:34:33 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2016-05-25 17:39:01 -0300
commitaf7f7c7ec8dea1aad43f2cbed34c8a7c246fba97 (patch)
tree388e31472f15a4520c609938bbb2f6a66c805301 /sysdeps/unix/sysv/linux/bits/socket.h
parentabf29edd4a3918d80822e19b306aca004b84c21c (diff)
network: recvmsg and sendmsg standard compliance (BZ#16919)
POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen to be of size int and socklen_t respectively. However Linux defines it as both size_t and for 64-bit it requires some adjustments to make the functions standard compliance. This patch fixes it by creating a temporary header and zeroing the pad fields for 64-bits architecture where size of size_t exceeds the size of the int. Also the new recvmsg and sendmsg implementation is only added on libc, with libpthread only containing a compat symbol. Tested on x86_64, i686, aarch64, armhf, and powerpc64le. * conform/data/sys/socket.h-data (msghdr.msg_iovlen): Remove xfail- and change to correct expected type. (msghdr.msg_controllen): Likewise. (cmsghdr.cmsg_len): Likewise. * sysdeps/unix/sysv/linux/bits/socket.h (msghdr.msg_iovlen): Fix expected POSIX assumption about the size. (msghdr.msg_controllen): Likewise. (msghdr.__glibc_reserved1): Likewise. (msghdr.__glibc_reserved2): Likewise. (cmsghdr.cmsg_len): Likewise. (cmsghdr.__glibc_reserved1): Likewise. * nptl/Makefile (libpthread-routines): Remove ptw-recvmsg and ptw-sendmsg. Add ptw-oldrecvmsg and ptw-oldsendmsg. (CFLAGS-sendmsg.c): Remove rule. (CFLAGS-recvmsg.c): Likewise. (CFLAGS-oldsendmsg.c): Add rule. (CFLAGS-oldrecvmsg.c): Likewise. * sysdeps/unix/sysv/linux/alpha/Versions [libc] (GLIBC_2.24): Add recvmsg and sendmsg. * sysdeps/unix/sysv/linux/aarch64/Version [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/arm/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/hppa/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/i386/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/ia64/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/m68k/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/microblaze/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/mips/mips32/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/mips/mips64/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/nios2/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/powerpc/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/sh/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/sparc/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/Versions [libc] (GLIBC_2.24): Likewise. ( sysdeps/unix/sysv/linux/tile/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/Versions [libc] (GLIBC_2.24): Likewise. ( sysdeps/unix/sysv/linux/x86_64/64/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/x84_64/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/Makefile [$(subdir) = socket)] (sysdep_headers): Add oldrecvmsg and oldsendmsg. (CFLAGS-sendmsg.c): Add rule. (CFLAGS-recvmsg.c): Likewise. (CFLAGS-oldsendmsg.c): Likewise. (CFLAGS-oldrecvmsg.c): Likewise. * sysdeps/unix/sysv/linux/check_native.c (__check_native): Fix msghdr initialization. * sysdeps/unix/sysv/linux/check_pf.c (make_request): Likewise. * sysdeps/unix/sysv/linux/ifaddrs.c (__netlink_request): Likewise. * sysdeps/unix/sysv/linux/oldrecvmsg.c: New file. * sysdeps/unix/sysv/linux/oldsendmsg.c: Likewise. * sysdeps/unix/sysv/linux/recvmsg.c (__libc_recvmsg): Adjust msghdr iovlen and controllen fields to adjust to POSIX specification. * sysdeps/unix/sysv/linux/sendmsg.c (__libc_sendmsg): Likewise. * sysdeps/unix/sysv/linux/aarch64/libc.abilist: New version and added recvmsg and sendmsg. * sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist: Likewise. * sysdeps/unix/linux/powerpc/powerpc32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise. * sysdepe/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise. Likewise. Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist: Likewise. Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
Diffstat (limited to 'sysdeps/unix/sysv/linux/bits/socket.h')
-rw-r--r--sysdeps/unix/sysv/linux/bits/socket.h49
1 files changed, 39 insertions, 10 deletions
diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h
index 2eb95f7e20..ef4629a743 100644
--- a/sysdeps/unix/sysv/linux/bits/socket.h
+++ b/sysdeps/unix/sysv/linux/bits/socket.h
@@ -27,6 +27,8 @@
#include <stddef.h>
#include <sys/types.h>
+#include <endian.h>
+#include <bits/wordsize.h>
/* Type for length arguments in socket calls. */
#ifndef __socklen_t_defined
@@ -250,13 +252,32 @@ struct msghdr
socklen_t msg_namelen; /* Length of address data. */
struct iovec *msg_iov; /* Vector of data to send/receive into. */
- size_t msg_iovlen; /* Number of elements in the vector. */
+#if __WORDSIZE == 64
+# if __BYTE_ORDER == __BIG_ENDIAN
+ int __glibc_reserved1; /* Pad to adjust Linux size to POSIX defined
+ size for msg_iovlen. */
+ int msg_iovlen; /* Number of elements in the vector. */
+# else
+ int msg_iovlen;
+ int __glibc_reserved1;
+# endif
+#else
+ int msg_iovlen;
+#endif
void *msg_control; /* Ancillary data (eg BSD filedesc passing). */
- size_t msg_controllen; /* Ancillary data buffer length.
- !! The type should be socklen_t but the
- definition of the kernel is incompatible
- with this. */
+#if __WORDSIZE == 64
+# if __BYTE_ORDER == __BIG_ENDIAN
+ int __glibc_reserved2; /* Pad to adjust Linux size to POSIX defined
+ size for msg_controllen. */
+ socklen_t msg_controllen; /* Ancillary data buffer length. */
+# else
+ socklen_t msg_controllen;
+ int __glibc_reserved2;
+# endif
+#else
+ socklen_t msg_controllen;
+#endif
int msg_flags; /* Flags on received message. */
};
@@ -264,11 +285,19 @@ struct msghdr
/* Structure used for storage of ancillary data object information. */
struct cmsghdr
{
- size_t cmsg_len; /* Length of data in cmsg_data plus length
- of cmsghdr structure.
- !! The type should be socklen_t but the
- definition of the kernel is incompatible
- with this. */
+#if __WORDSIZE == 64
+# if __BYTE_ORDER == __BIG_ENDIAN
+ int __glibc_reserved1; /* Pad toadjust Linux size to POSIX defined
+ size for cmsg_len. */
+ socklen_t cmsg_len; /* Length of data in cmsg_data plus length
+ of cmsghdr structure. */
+# else
+ socklen_t cmsg_len;
+ int __glibc_reserved1;
+# endif
+#else
+ socklen_t cmsg_len;
+#endif
int cmsg_level; /* Originating protocol. */
int cmsg_type; /* Protocol specific type. */
#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L