This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 0/4] Fix {recv,send}{m}msg standard compliance (BZ#16919)


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. Add architecture specific socket.h header: splits the Linux
    socket.h definition in a platform specific one for the new
    msghdr and cmsghdr defition.  The is just a functional change
    to lay the required headers (more rationale where it is not
    possible to support only on header on the patch comments).

 2. 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.

 3. network: recvmsg and sendmsg standard compliance: this is the
    first patch of the BZ#16919 fix where it handle both recvmsg
    and sendmsg.

 4. 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 (4):
  Add architecture specific socket.h header
  Adjust kernel-features.h for sendmmsg/recvmmsg
  network: recvmsg and sendmsg standard compliance (BZ#16919)
  network: recvmmsg and sendmmsg standard compliance (BZ#16919)

 ChangeLog                                          | 211 +++++++++++
 conform/data/sys/socket.h-data                     |   8 +-
 nptl/Makefile                                      |   1 +
 sysdeps/unix/sysv/linux/Makefile                   |   5 +-
 sysdeps/unix/sysv/linux/aarch64/Versions           |   9 +
 sysdeps/unix/sysv/linux/aarch64/bits/socket.h      |  87 +++++
 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/bits/socket.h        |  66 ++++
 sysdeps/unix/sysv/linux/alpha/libc.abilist         |   5 +
 sysdeps/unix/sysv/linux/alpha/libpthread.abilist   |   3 +
 sysdeps/unix/sysv/linux/arm/bits/socket.h          |  64 ++++
 sysdeps/unix/sysv/linux/bits/socket-linux.h        | 355 +++++++++++++++++++
 sysdeps/unix/sysv/linux/bits/socket.h              | 389 ---------------------
 sysdeps/unix/sysv/linux/check_native.c             |  11 +-
 sysdeps/unix/sysv/linux/check_pf.c                 |  11 +-
 sysdeps/unix/sysv/linux/hppa/bits/socket.h         |  64 ++++
 sysdeps/unix/sysv/linux/i386/bits/socket.h         |  71 ++++
 sysdeps/unix/sysv/linux/i386/kernel-features.h     |   8 +-
 sysdeps/unix/sysv/linux/ia64/Versions              |   6 +
 sysdeps/unix/sysv/linux/ia64/bits/socket.h         |  70 ++++
 sysdeps/unix/sysv/linux/ia64/libc.abilist          |   5 +
 sysdeps/unix/sysv/linux/ia64/libpthread.abilist    |   3 +
 sysdeps/unix/sysv/linux/ifaddrs.c                  |  11 +-
 sysdeps/unix/sysv/linux/m68k/bits/socket.h         |  64 ++++
 sysdeps/unix/sysv/linux/m68k/kernel-features.h     |   2 +
 sysdeps/unix/sysv/linux/microblaze/bits/socket.h   |  71 ++++
 .../unix/sysv/linux/microblaze/kernel-features.h   |   6 +-
 sysdeps/unix/sysv/linux/mips/mips32/bits/socket.h  |  64 ++++
 sysdeps/unix/sysv/linux/mips/mips32/recvmmsg.c     |  29 --
 sysdeps/unix/sysv/linux/mips/mips32/sendmmsg.c     |  29 --
 sysdeps/unix/sysv/linux/mips/mips64/bits/socket.h  |  87 +++++
 .../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/nios2/bits/socket.h        |  64 ++++
 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  |   3 -
 .../sysv/linux/powerpc/powerpc32/bits/socket.h     |  64 ++++
 sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions |   6 +
 .../sysv/linux/powerpc/powerpc64/bits/socket.h     |  87 +++++
 .../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                 |  71 ++--
 sysdeps/unix/sysv/linux/recvmsg.c                  |  40 ++-
 sysdeps/unix/sysv/linux/s390/kernel-features.h     |   5 +
 sysdeps/unix/sysv/linux/s390/s390-32/bits/socket.h |  64 ++++
 sysdeps/unix/sysv/linux/s390/s390-64/Versions      |   9 +
 sysdeps/unix/sysv/linux/s390/s390-64/bits/socket.h |  70 ++++
 sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist  |   5 +
 .../sysv/linux/s390/s390-64/libpthread.abilist     |   3 +
 sysdeps/unix/sysv/linux/sendmmsg.c                 |  77 ++--
 sysdeps/unix/sysv/linux/sendmsg.c                  |  27 +-
 sysdeps/unix/sysv/linux/sh/bits/socket.h           |  64 ++++
 sysdeps/unix/sysv/linux/sh/kernel-features.h       |   3 -
 sysdeps/unix/sysv/linux/sparc/kernel-features.h    |   6 -
 .../unix/sysv/linux/sparc/sparc32/bits/socket.h    |  64 ++++
 sysdeps/unix/sysv/linux/sparc/sparc64/Versions     |   9 +
 .../unix/sysv/linux/sparc/sparc64/bits/socket.h    |  70 ++++
 sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist |   5 +
 .../sysv/linux/sparc/sparc64/libpthread.abilist    |   3 +
 sysdeps/unix/sysv/linux/tile/tilegx/bits/socket.h  |  87 +++++
 .../unix/sysv/linux/tile/tilegx/tilegx64/Versions  |   5 +
 .../sysv/linux/tile/tilegx/tilegx64/libc.abilist   |   5 +
 .../linux/tile/tilegx/tilegx64/libpthread.abilist  |   3 +
 sysdeps/unix/sysv/linux/tile/tilepro/bits/socket.h |  64 ++++
 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/bits/socket.h       |  70 ++++
 77 files changed, 2913 insertions(+), 542 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/aarch64/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/alpha/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/arm/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/bits/socket-linux.h
 delete mode 100644 sysdeps/unix/sysv/linux/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/hppa/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/i386/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/ia64/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/m68k/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/microblaze/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips32/bits/socket.h
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/recvmmsg.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/sendmmsg.c
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/bits/socket.h
 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/nios2/bits/socket.h
 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/powerpc/powerpc32/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/sh/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/tile/tilegx/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/Versions
 create mode 100644 sysdeps/unix/sysv/linux/tile/tilepro/bits/socket.h
 create mode 100644 sysdeps/unix/sysv/linux/x86_64/64/Versions
 create mode 100644 sysdeps/unix/sysv/linux/x86_64/bits/socket.h

-- 
1.9.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]