summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-09-29 14:29:48 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-10-02 16:11:55 -0300
commita16d2abd496bd974a88207d5599265aae5ae4880 (patch)
treea14903b78d6a30e04825173ce4157f2263e88ec1 /sysdeps
parent574500a108be1d2a6a0dc97a075c9e0a98371aba (diff)
downloadglibc-a16d2abd496bd974a88207d5599265aae5ae4880.tar.gz
glibc-a16d2abd496bd974a88207d5599265aae5ae4880.tar.xz
glibc-a16d2abd496bd974a88207d5599265aae5ae4880.zip
sysvipc: Return EINVAL for invalid semctl commands
It avoids regressions on possible future commands that might require
additional libc support.  The downside is new commands added by newer
kernels will need further glibc support.

Checked on x86_64-linux-gnu and i686-linux-gnu (Linux v4.15 and v5.4).
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/unix/sysv/linux/semctl.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/semctl.c b/sysdeps/unix/sysv/linux/semctl.c
index 1cdabde8f2..0279acc3f2 100644
--- a/sysdeps/unix/sysv/linux/semctl.c
+++ b/sysdeps/unix/sysv/linux/semctl.c
@@ -158,6 +158,15 @@ __semctl64 (int semid, int semnum, int cmd, ...)
       arg64 = va_arg (ap, union semun64);
       va_end (ap);
       break;
+    case IPC_RMID:      /* arg ignored.  */
+    case GETNCNT:
+    case GETPID:
+    case GETVAL:
+    case GETZCNT:
+      break;
+    default:
+      __set_errno (EINVAL);
+      return -1;
     }
 
 #if __IPC_TIME64
@@ -277,6 +286,7 @@ __semctl (int semid, int semnum, int cmd, ...)
       arg = va_arg (ap, union semun);
       va_end (ap);
       break;
+    /* __semctl64 handles non-supported commands.  */
     }
 
   struct __semid64_ds semid64;