about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/semctl.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2022-11-08 14:15:02 +0100
committerFlorian Weimer <fweimer@redhat.com>2022-11-11 18:45:04 +0100
commit0f90d6204d79223fd32248c774df0cb7f0e604de (patch)
tree4b0c9b65f68d726cfca2af954d303a858758c7eb /sysdeps/unix/sysv/linux/semctl.c
parent70410f2286cc36c9ccb133878811c728ae51725f (diff)
downloadglibc-0f90d6204d79223fd32248c774df0cb7f0e604de.tar.gz
glibc-0f90d6204d79223fd32248c774df0cb7f0e604de.tar.xz
glibc-0f90d6204d79223fd32248c774df0cb7f0e604de.zip
Linux: Support __IPC_64 in sysvctl *ctl command arguments (bug 29771)
Old applications pass __IPC_64 as part of the command argument because
old glibc did not check for unknown commands, and passed through the
arguments directly to the kernel, without adding __IPC_64.
Applications need to continue doing that for old glibc compatibility,
so this commit enables this approach in current glibc.

For msgctl and shmctl, if no translation is required, make
direct system calls, as we did before the time64 changes.  If
translation is required, mask __IPC_64 from the command argument.

For semctl, the union-in-vararg argument handling means that
translation is needed on all architectures.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
(cherry picked from commit 22a46dee24351fd5f4f188ad80554cad79c82524)
Diffstat (limited to 'sysdeps/unix/sysv/linux/semctl.c')
-rw-r--r--sysdeps/unix/sysv/linux/semctl.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/semctl.c b/sysdeps/unix/sysv/linux/semctl.c
index 77a8130c18..3458b018bc 100644
--- a/sysdeps/unix/sysv/linux/semctl.c
+++ b/sysdeps/unix/sysv/linux/semctl.c
@@ -140,6 +140,13 @@ __semctl64 (int semid, int semnum, int cmd, ...)
   union semun64 arg64 = { 0 };
   va_list ap;
 
+  /* Some applications pass the __IPC_64 flag in cmd, to invoke
+     previously unsupported commands back when there was no EINVAL
+     error checking in glibc.  Mask the flag for the switch statements
+     below.  semctl_syscall adds back the __IPC_64 flag for the actual
+     system call.  */
+  cmd &= ~__IPC_64;
+
   /* Get the argument only if required.  */
   switch (cmd)
     {