This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH v2 0/3] Fix {recv,send}{m}msg standard compliance (BZ#16919)
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: libc-alpha at sourceware dot org
- Date: Wed, 23 Mar 2016 11:30:57 -0300
- Subject: [PATCH v2 0/3] Fix {recv,send}{m}msg standard compliance (BZ#16919)
- Authentication-results: sourceware.org; auth=none
Changes from previous version:
- Drop architecture specific socket.h header in favor of using wordsize.h
definitions.
- Drop recvmmsg and sendmmsg refactor.
---
This is an attempt of fixing the BZ#16919, recvmsg standard compliance,
where Linux and POSIX differs in the msghdr and mmsghdr internal struct
sizes. The issue is POSIX defines [1] both msghdr.msg_namelen,
msghdr.controllen, and cmsghdr.cmsg_len as socklen_t, where Linux uses
size_t. So for 64-bits architectures where size_t is larger sockelen_t
it leads to standard inconsistence. Linux also added recvmmsg and
sendmmsg, which uses a composite struct based on msghdr (mmsghdr).
As stated in comment 6 at bugzilla report, both recvmsg and recvmmsg
uses the msghdr structures which lie in memory that's (by the interface
contract) writable by the function, so the adjustment is just to patch
with zero the padding memebers. However sendmmsg's msghdr points to
an already-filled control buffer containing cmsghdr structures that
is not writable by the function's contract.
So the proposed solutions follow four patches:
1. Adjust kernel-features.h for sendmmsg/recvmmsg: this try to
simplify the sendmmsg/recvmmsg __ASSUME definition and also
fixes some x86 bugs when building using old kernel definitions.
2. network: recvmsg and sendmsg standard compliance: this is the
first patch of the BZ#16919 fix where it handle both recvmsg
and sendmsg.
3. network: recvmmsg and sendmmsg standard compliance: the second
patch where is handles both recvmmsg and sendmmsg.
This current solutions have some open spots that I would like to
discuss:
1. Current sendmsg fix does not handle larger msg_control neither
pads the cmsghdr associated. The problem with this approach
is to accomplish a complete fix it will require to allocate
a limited buffer, copying the incoming struct and zero pad.
Although it tend to work it also add some limitation of total
msg_control length.
The general usage for such facily is passing file descriptors
and permissions between processes over unix sockets so it might
be factible to use a large stack allocated buffer (1024, 2048
or large) and return ENOMEM for larger buffers.
2. Current approach adds symbol versioning for older implementation
which uses the syscall directly. This is the default GLIBC
policy for such changes, whoever I am not sure if there is any
realword application that might break with this new implementation.
So one option could get rid of the compatbility symbols.
[1] http://pubs.opengroup.org/onlinepubs/9699919799/
Adhemerval Zanella (3):
Adjust kernel-features.h defaults for recvmsg and sendmsg
network: recvmsg and sendmsg standard compliance (BZ#16919)
network: recvmmsg and sendmmsg standard compliance (BZ#16919)
ChangeLog | 180 +++++++++++++++
conform/data/sys/socket.h-data | 8 +-
nptl/Makefile | 1 +
sysdeps/unix/sysv/linux/Makefile | 3 +-
sysdeps/unix/sysv/linux/aarch64/Versions | 9 +
sysdeps/unix/sysv/linux/aarch64/libc.abilist | 5 +
sysdeps/unix/sysv/linux/aarch64/libpthread.abilist | 3 +
sysdeps/unix/sysv/linux/alpha/Versions | 6 +
sysdeps/unix/sysv/linux/alpha/libc.abilist | 5 +
sysdeps/unix/sysv/linux/alpha/libpthread.abilist | 3 +
sysdeps/unix/sysv/linux/alpha/syscalls.list | 2 -
sysdeps/unix/sysv/linux/arm/syscalls.list | 2 -
sysdeps/unix/sysv/linux/bits/socket.h | 45 +++-
sysdeps/unix/sysv/linux/check_native.c | 11 +-
sysdeps/unix/sysv/linux/check_pf.c | 11 +-
sysdeps/unix/sysv/linux/generic/syscalls.list | 2 -
sysdeps/unix/sysv/linux/hppa/syscalls.list | 2 -
sysdeps/unix/sysv/linux/i386/kernel-features.h | 4 +-
sysdeps/unix/sysv/linux/ia64/Versions | 6 +
sysdeps/unix/sysv/linux/ia64/libc.abilist | 5 +
sysdeps/unix/sysv/linux/ia64/libpthread.abilist | 3 +
sysdeps/unix/sysv/linux/ia64/syscalls.list | 2 -
sysdeps/unix/sysv/linux/ifaddrs.c | 11 +-
sysdeps/unix/sysv/linux/kernel-features.h | 8 +
sysdeps/unix/sysv/linux/m68k/kernel-features.h | 4 +-
.../unix/sysv/linux/microblaze/kernel-features.h | 4 +-
.../unix/sysv/linux/mips/mips64/libpthread.abilist | 3 +
.../sysv/linux/mips/mips64/n32/libpthread.abilist | 256 +++++++++++++++++++++
sysdeps/unix/sysv/linux/mips/mips64/n64/Versions | 10 +
.../unix/sysv/linux/mips/mips64/n64/libc.abilist | 5 +
sysdeps/unix/sysv/linux/mips/syscalls.list | 2 -
sysdeps/unix/sysv/linux/oldrecvmmsg.c | 91 ++++++++
sysdeps/unix/sysv/linux/oldrecvmsg.c | 42 ++++
sysdeps/unix/sysv/linux/oldsendmmsg.c | 90 ++++++++
sysdeps/unix/sysv/linux/oldsendmsg.c | 42 ++++
sysdeps/unix/sysv/linux/powerpc/kernel-features.h | 2 -
sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions | 6 +
.../sysv/linux/powerpc/powerpc64/libc-le.abilist | 5 +
.../unix/sysv/linux/powerpc/powerpc64/libc.abilist | 5 +
.../linux/powerpc/powerpc64/libpthread-le.abilist | 3 +
.../linux/powerpc/powerpc64/libpthread.abilist | 3 +
sysdeps/unix/sysv/linux/recvmmsg.c | 61 +++--
sysdeps/unix/sysv/linux/recvmsg.c | 40 +++-
sysdeps/unix/sysv/linux/s390/kernel-features.h | 7 +-
sysdeps/unix/sysv/linux/s390/s390-64/Versions | 9 +
sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 5 +
.../sysv/linux/s390/s390-64/libpthread.abilist | 3 +
sysdeps/unix/sysv/linux/sendmmsg.c | 72 ++++--
sysdeps/unix/sysv/linux/sendmsg.c | 27 ++-
sysdeps/unix/sysv/linux/sh/kernel-features.h | 5 -
sysdeps/unix/sysv/linux/sparc/sparc64/Versions | 9 +
sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist | 5 +
.../sysv/linux/sparc/sparc64/libpthread.abilist | 3 +
.../unix/sysv/linux/sparc/sparc64/syscalls.list | 2 -
.../unix/sysv/linux/tile/tilegx/tilegx64/Versions | 11 +
.../sysv/linux/tile/tilegx/tilegx64/libc.abilist | 5 +
.../linux/tile/tilegx/tilegx64/libpthread.abilist | 3 +
sysdeps/unix/sysv/linux/x86_64/64/Versions | 10 +
sysdeps/unix/sysv/linux/x86_64/64/libc.abilist | 5 +
.../unix/sysv/linux/x86_64/64/libpthread.abilist | 3 +
sysdeps/unix/sysv/linux/x86_64/syscalls.list | 2 -
61 files changed, 1081 insertions(+), 116 deletions(-)
create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/libpthread.abilist
create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/Versions
create mode 100644 sysdeps/unix/sysv/linux/oldrecvmmsg.c
create mode 100644 sysdeps/unix/sysv/linux/oldrecvmsg.c
create mode 100644 sysdeps/unix/sysv/linux/oldsendmmsg.c
create mode 100644 sysdeps/unix/sysv/linux/oldsendmsg.c
create mode 100644 sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/Versions
create mode 100644 sysdeps/unix/sysv/linux/x86_64/64/Versions
--
1.9.1