about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/s390
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-10-10 18:13:11 +0000
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-10-10 17:33:27 -0300
commit2f959dfe849e0646e27403f2e4091536496ac0f0 (patch)
treee530ee01021cfd26c841278e831ab14245a8a1d0 /sysdeps/unix/sysv/linux/s390
parent8a3ca0fdd33629854a73ffd9251aa9d77e4766e4 (diff)
downloadglibc-2f959dfe849e0646e27403f2e4091536496ac0f0.tar.gz
glibc-2f959dfe849e0646e27403f2e4091536496ac0f0.tar.xz
glibc-2f959dfe849e0646e27403f2e4091536496ac0f0.zip
sysvipc: Set ipc_perm mode as mode_t (BZ#18231)
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_BROKEN_MODE_T, which the
     required ABIs define.

  4. For the ABIs that define __ASSUME_SYSVIPC_BROKEN_MODE_T, it also
     require 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.

I also did a sanity test against armeb qemu usermode for the sysvipc
tests.

	[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_BROKEN_MODE_T):
	Define.
	* sysdeps/sysv/linux/microblaze/kernel-features.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/kernel-features.h
	[!__s390x__] (__ASSUME_SYSVIPC_BROKEN_MODE_T): Define.
	* sysdeps/unix/sysv/linux/sh/kernel-features.h
	(__ASSUME_SYSVIPC_BROKEN_MODE_T): 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: Add comment about
	__ASSUME_SYSVIPC_BROKEN_MODE_T semantic.
	* sysdeps/unix/sysv/linux/msgctl.c (DEFAULT_VERSION): Define as
	2.31 if __ASSUME_SYSVIPC_BROKEN_MODE_T is defined.
	(msgctl_syscall, __msgctl_mode16): New symbol.
	(__new_msgctl): Add bits for __ASSUME_SYSVIPC_BROKEN_MODE_T.
	* sysdeps/unix/sysv/linux/semctl.c: Likewise.
	* sysdeps/unix/sysv/linux/shmctl.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/be/libc.abilist (GLIBC_2.31): Add
	msgctl, semctl, and shmctl.
	* sysdeps/sysv/linux/microblaze/be/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/s390/s390-32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/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/Versions (libc) [GLIBC_2.31]: Add
	msgctl, semctl, and shmctl.
	* sysdeps/unix/sysv/linux/arm/be/Versions: New file.
	* sysdeps/unix/sysv/linux/microblaze/be/Versions: Likewise.
	* sysdeps/unix/sysv/linux/sh/be/Versions: Likewise.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_ipc.h.html
Diffstat (limited to 'sysdeps/unix/sysv/linux/s390')
-rw-r--r--sysdeps/unix/sysv/linux/s390/bits/ipc.h60
-rw-r--r--sysdeps/unix/sysv/linux/s390/kernel-features.h3
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-32/Versions3
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist3
4 files changed, 9 insertions, 60 deletions
diff --git a/sysdeps/unix/sysv/linux/s390/bits/ipc.h b/sysdeps/unix/sysv/linux/s390/bits/ipc.h
deleted file mode 100644
index d4dd567ea9..0000000000
--- a/sysdeps/unix/sysv/linux/s390/bits/ipc.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright (C) 2001-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef _SYS_IPC_H
-# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
-#endif
-
-#include <bits/types.h>
-#include <bits/wordsize.h>
-
-/* Mode bits for `msgget', `semget', and `shmget'.  */
-#define IPC_CREAT	01000		/* Create key if key does not exist. */
-#define IPC_EXCL	02000		/* Fail if key exists.	*/
-#define IPC_NOWAIT	04000		/* Return error on wait.  */
-
-/* Control commands for `msgctl', `semctl', and `shmctl'.  */
-#define IPC_RMID	0		/* Remove identifier.  */
-#define IPC_SET		1		/* Set `ipc_perm' options.  */
-#define IPC_STAT	2		/* Get `ipc_perm' options.  */
-#ifdef __USE_GNU
-#define IPC_INFO	3		/* See ipcs.  */
-#endif
-
-/* Special key values.	*/
-#define IPC_PRIVATE	((__key_t) 0)	/* Private key.	 */
-
-
-/* Data structure used to pass permission information to IPC operations.  */
-struct ipc_perm
-  {
-    __key_t __key;			/* Key.	 */
-    __uid_t uid;			/* Owner's user ID.  */
-    __gid_t gid;			/* Owner's group ID.  */
-    __uid_t cuid;			/* Creator's user ID.  */
-    __gid_t cgid;			/* Creator's group ID.	*/
-#if __WORDSIZE == 64
-    __mode_t mode;			/* Read/write permission.  */
-#else
-    unsigned short int mode;		/* Read/write permission.  */
-    unsigned short int __pad1;
-#endif
-    unsigned short int __seq;		/* Sequence number.  */
-    unsigned short int __pad2;
-    unsigned long int __glibc_reserved1;
-    unsigned long int __glibc_reserved2;
-  };
diff --git a/sysdeps/unix/sysv/linux/s390/kernel-features.h b/sysdeps/unix/sysv/linux/s390/kernel-features.h
index 7e7437df5c..6dca32c6c7 100644
--- a/sysdeps/unix/sysv/linux/s390/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/s390/kernel-features.h
@@ -47,6 +47,9 @@
 
 /* s390 only supports ipc syscall.  */
 #undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+#ifndef __s390x__
+# define __ASSUME_SYSVIPC_BROKEN_MODE_T
+#endif
 
 #undef __ASSUME_CLONE_DEFAULT
 #define __ASSUME_CLONE_BACKWARDS2
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/Versions b/sysdeps/unix/sysv/linux/s390/s390-32/Versions
index 1c120e8cbe..99193982a7 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/Versions
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/Versions
@@ -49,6 +49,9 @@ libc {
   GLIBC_2.11 {
     fallocate64;
   }
+  GLIBC_2.31 {
+    msgctl; semctl; shmctl;
+  }
 }
 
 libutil {
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index 122d0fb65a..4feca641b0 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2180,6 +2180,9 @@ GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.31 msgctl F
+GLIBC_2.31 semctl F
+GLIBC_2.31 shmctl F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F