From a16d2abd496bd974a88207d5599265aae5ae4880 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Tue, 29 Sep 2020 14:29:48 -0300 Subject: 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). --- sysdeps/unix/sysv/linux/semctl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sysdeps/unix/sysv') 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; -- cgit v1.2.3