summaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/kernel-features.h
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-07-22 12:36:09 +0000
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-08-27 20:50:00 +0000
commit04e29690214c72cf7a55e6f4a46e044502d2350a (patch)
tree181c80b165e0105018ed031801973522b3e93a8c /sysdeps/unix/sysv/linux/kernel-features.h
parentbb6cb29f8ed7efc0897612918ea2d7382f9dab4e (diff)
downloadglibc-azanella/bz18231.tar.gz
sysvipc: Set ipc_perm mode as mode_t (BZ#18231)azanella/bz18231
This patch sets the mode field in ipc_perm as mode_t for all architectures, as POSIX specification [1]. The changes required are as follow: 1. It moves the ipc_perm definition out of ipc.h to its own header ipc_perm.h. It also allows consolidate the IPC_* definition on only one header. 2. The generic implementation follow the kernel ipc64_perm size so the syscall can be made directly without temporary buffer copy. However, since glibc defines the MODE field as mode_t, it omits the __PAD1 field (since glibc does not export mode_t as 16-bit for any architecture). It is a two-fold improvement: 2.1. New implementation which follow Linux UAPI will not need to provide an arch-specific ipc-perm.h header neither wrongly use the wrong 16-bit definition from previous default ipc.h (as csky did). 2.1. It allows consolidate ipc_perm definition for architectures that already provide mode_t as 32-bit. 3. All kernel ABIs for the supported architectures already provides the expected padding for mode type extension to 32-bit. However, some architectures the padding has the wrong placement, so it requires the ipc control routines (msgctl, semctl, and shmctl) to adjust the mode field accordingly. Currently they are armeb, microblaze, m68k, s390, and sheb. A new assume is added, __ASSUME_SYSVIPC_SUPPORT_MODE32, which the required architecture undefine. 4. For the architecture that undefined __ASSUME_SYSVIPC_SUPPORT_MODE32, it also requires compat symbols that do not adjust the mode field. Checked on arm-linux-gnueabihf, aarch64-linux-gnu, powerpc64le-linux-gnu, and x86_64-linux-gnu. I also checked the sysvipc tests on hppa-linux-gnu, sh4-linux-gnu, s390x-linux-gnu, and s390-linux-gnu. [BZ #18231] * sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add bits/ipc-perm.h. * sysdeps/unix/sysv/linux/aarch64/bits/ipc.h: Remove file. * sysdeps/unix/sysv/linux/alpha/bits/ipc.h: Likewise. * sysdeps/unix/sysv/linux/hppa/bits/ipc.h: Likewise. * sysdeps/unix/sysv/linux/ia64/bits/ipc.h: Likewise. * sysdeps/unix/sysv/linux/mips/bits/ipc.h: Likewise. * sysdeps/unix/sysv/linux/powerpc/bits/ipc.h: Likewise. * sysdeps/unix/sysv/linux/s390/bits/ipc.h: Likewise. * sysdeps/unix/sysv/linux/sparc/bits/ipc.h: Likewise. * sysdeps/unix/sysv/linux/arm/kernel-features.h [__BYTE_ORDER == __BIG_ENDIAN] (__ASSUME_SYSVIPC_SUPPORT_MODE32): Undefine. * sysdeps/sysv/linux/microblaze/kernel-features.h: Likewise. * sysdeps/unix/sysv/linux/s390/kernel-features.h [!__s390x__] (__ASSUME_SYSVIPC_SUPPORT_MODE32): Define. * sysdeps/unix/sysv/linux/sh/kernel-features.h (__ASSUME_SYSVIPC_SUPPORT_MODE32): Define. * sysdeps/unix/sysv/linux/m68k/kernel-features.h: Likewise. * sysdeps/unix/sysv/linux/bits/ipc-perm.h: New file. * sysdeps/unix/sysv/linux/powerpc/bits/ipc-perm.h: Likewise. * sysdeps/unix/sysv/linux/sparc/bits/ipc-perm.h: Likewise. * sysdeps/unix/sysv/linux/bits/ipc.h (ipc_perm): Move to bits/ipc-perm.h. * sysdeps/unix/sysv/linux/hppa/bits/ipc-perm.h: New file. * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_SYSVIPC_SUPPORT_MODE32): Define. * sysdeps/unix/sysv/linux/msgctl.c (DEFAULT_VERSION): Define as 2.30 if __ASSUME_SYSVIPC_SUPPORT_MODE32 is not defined. (msgctl_syscall, __msgctl_mode16): New symbol. (__new_msgctl): Handle if __ASSUME_SYSVIPC_SUPPORT_MODE32 is not defined. * sysdeps/unix/sysv/linux/semctl.c: Likewise. * sysdeps/unix/sysv/linux/shmctl.c: Likewise. * sysdeps/unix/sysv/linux/arm/be/libc.abilist (GLIBC_2.30): Add msgctl, semctl, and shmctl. * sysdeps/sysv/linux/microblaze/be/libc.abilist: Likewise. * conform/data/sys/ipc.h-data: Only xfail {struct ipc_perm} mode_t mode for Hurd. * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/be/libc.abilist: Likewise. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_ipc.h.html
Diffstat (limited to 'sysdeps/unix/sysv/linux/kernel-features.h')
-rw-r--r--sysdeps/unix/sysv/linux/kernel-features.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
index 1518bb5228..91152158f1 100644
--- a/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/kernel-features.h
@@ -81,6 +81,14 @@
either support ipc syscall and/or all the ipc correspondent syscalls. */
#define __ASSUME_DIRECT_SYSVIPC_SYSCALLS 1
+/* All supported architectures reserve a 32-bit for MODE field in sysvipc
+ ipc_perm. However, some kernel ABI interfaces still expect a 16-bit
+ field. This is only an issue if arch-defined IPC_PERM padding is on a
+ wrong position regarding endianness. In this case, the IPC control
+ routines (msgctl, semctl, and semtctl) requires to shift the value to
+ correct place.
+ The ABIs that requires it define __ASSUME_SYSVIPC_BROKEN_MODE_T. */
+
/* Support for p{read,write}v2 was added in 4.6. However Linux default
implementation does not assume the __ASSUME_* and instead use a fallback
implementation based on p{read,write}v and returning an error for