From dd8d558394b2b8cb7f743a2a4bf763974d6c2dd9 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sun, 6 Dec 2020 08:00:00 +0000 Subject: [PATCH 162/162] tests: disable tests for invalid semctl commands on glibc >= 2.32 Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882, glibc skips semctl syscall invocations and returns EINVAL for invalid semctl commands. * tests/ipc_sem.c [GLIBC_PREREQ_GE(2, 32)] (TEST_SEMCTL_BOGUS_CMD): Define to 0. [!TEST_SEMCTL_BOGUS_CMD] (TEST_SEMCTL_BOGUS_CMD): Define to 1. (main) [!TEST_SEMCTL_BOGUS_CMD] (bogus_semid, bogus_semnum, bogus_cmd, bogus_arg): Do not define and do not use. --- tests/ipc_sem.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tests/ipc_sem.c b/tests/ipc_sem.c index 7341f72..0351e53 100644 --- a/tests/ipc_sem.c +++ b/tests/ipc_sem.c @@ -20,6 +20,21 @@ # define SEM_STAT_ANY 20 #endif +#undef TEST_SEMCTL_BOGUS_CMD + +/* + * Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882, + * glibc skips semctl syscall invocations and returns EINVAL + * for invalid semctl commands. + */ +#if GLIBC_PREREQ_GE(2, 32) +# define TEST_SEMCTL_BOGUS_CMD 0 +#endif + +#ifndef TEST_SEMCTL_BOGUS_CMD +# define TEST_SEMCTL_BOGUS_CMD 1 +#endif + #if XLAT_RAW # define str_ipc_flags "0xface1e00" # define str_ipc_private "0" @@ -78,13 +93,15 @@ main(void) static const key_t private_key = (key_t) (0xffffffff00000000ULL | IPC_PRIVATE); static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL; - static const int bogus_semid = 0xfdb97531; - static const int bogus_semnum = 0xeca86420; static const int bogus_size = 0xdec0ded1; static const int bogus_flags = 0xface1e55; +#if TEST_SEMCTL_BOGUS_CMD + static const int bogus_semid = 0xfdb97531; + static const int bogus_semnum = 0xeca86420; static const int bogus_cmd = 0xdeadbeef; static const unsigned long bogus_arg = (unsigned long) 0xbadc0dedfffffaceULL; +#endif int rc; union semun un; @@ -102,11 +119,13 @@ main(void) printf("semget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id); atexit(cleanup); +#if TEST_SEMCTL_BOGUS_CMD rc = semctl(bogus_semid, bogus_semnum, bogus_cmd, bogus_arg); -#define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)" +# define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)" printf("semctl\\(%d, %d, (%s\\|)?%s, " SEMCTL_BOGUS_ARG_FMT "\\) = %s\n", bogus_semid, bogus_semnum, str_ipc_64, str_bogus_cmd, bogus_arg, bogus_arg, sprintrc_grep(rc)); +#endif un.buf = &ds; if (semctl(id, 0, IPC_STAT, un)) diff --git a/tests-m32/ipc_sem.c b/tests-m32/ipc_sem.c index 7341f72..0351e53 100644 --- a/tests-m32/ipc_sem.c +++ b/tests-m32/ipc_sem.c @@ -20,6 +20,21 @@ # define SEM_STAT_ANY 20 #endif +#undef TEST_SEMCTL_BOGUS_CMD + +/* + * Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882, + * glibc skips semctl syscall invocations and returns EINVAL + * for invalid semctl commands. + */ +#if GLIBC_PREREQ_GE(2, 32) +# define TEST_SEMCTL_BOGUS_CMD 0 +#endif + +#ifndef TEST_SEMCTL_BOGUS_CMD +# define TEST_SEMCTL_BOGUS_CMD 1 +#endif + #if XLAT_RAW # define str_ipc_flags "0xface1e00" # define str_ipc_private "0" @@ -78,13 +93,15 @@ main(void) static const key_t private_key = (key_t) (0xffffffff00000000ULL | IPC_PRIVATE); static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL; - static const int bogus_semid = 0xfdb97531; - static const int bogus_semnum = 0xeca86420; static const int bogus_size = 0xdec0ded1; static const int bogus_flags = 0xface1e55; +#if TEST_SEMCTL_BOGUS_CMD + static const int bogus_semid = 0xfdb97531; + static const int bogus_semnum = 0xeca86420; static const int bogus_cmd = 0xdeadbeef; static const unsigned long bogus_arg = (unsigned long) 0xbadc0dedfffffaceULL; +#endif int rc; union semun un; @@ -102,11 +119,13 @@ main(void) printf("semget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id); atexit(cleanup); +#if TEST_SEMCTL_BOGUS_CMD rc = semctl(bogus_semid, bogus_semnum, bogus_cmd, bogus_arg); -#define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)" +# define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)" printf("semctl\\(%d, %d, (%s\\|)?%s, " SEMCTL_BOGUS_ARG_FMT "\\) = %s\n", bogus_semid, bogus_semnum, str_ipc_64, str_bogus_cmd, bogus_arg, bogus_arg, sprintrc_grep(rc)); +#endif un.buf = &ds; if (semctl(id, 0, IPC_STAT, un)) diff --git a/tests-mx32/ipc_sem.c b/tests-mx32/ipc_sem.c index 7341f72..0351e53 100644 --- a/tests-mx32/ipc_sem.c +++ b/tests-mx32/ipc_sem.c @@ -20,6 +20,21 @@ # define SEM_STAT_ANY 20 #endif +#undef TEST_SEMCTL_BOGUS_CMD + +/* + * Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882, + * glibc skips semctl syscall invocations and returns EINVAL + * for invalid semctl commands. + */ +#if GLIBC_PREREQ_GE(2, 32) +# define TEST_SEMCTL_BOGUS_CMD 0 +#endif + +#ifndef TEST_SEMCTL_BOGUS_CMD +# define TEST_SEMCTL_BOGUS_CMD 1 +#endif + #if XLAT_RAW # define str_ipc_flags "0xface1e00" # define str_ipc_private "0" @@ -78,13 +93,15 @@ main(void) static const key_t private_key = (key_t) (0xffffffff00000000ULL | IPC_PRIVATE); static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL; - static const int bogus_semid = 0xfdb97531; - static const int bogus_semnum = 0xeca86420; static const int bogus_size = 0xdec0ded1; static const int bogus_flags = 0xface1e55; +#if TEST_SEMCTL_BOGUS_CMD + static const int bogus_semid = 0xfdb97531; + static const int bogus_semnum = 0xeca86420; static const int bogus_cmd = 0xdeadbeef; static const unsigned long bogus_arg = (unsigned long) 0xbadc0dedfffffaceULL; +#endif int rc; union semun un; @@ -102,11 +119,13 @@ main(void) printf("semget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id); atexit(cleanup); +#if TEST_SEMCTL_BOGUS_CMD rc = semctl(bogus_semid, bogus_semnum, bogus_cmd, bogus_arg); -#define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)" +# define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)" printf("semctl\\(%d, %d, (%s\\|)?%s, " SEMCTL_BOGUS_ARG_FMT "\\) = %s\n", bogus_semid, bogus_semnum, str_ipc_64, str_bogus_cmd, bogus_arg, bogus_arg, sprintrc_grep(rc)); +#endif un.buf = &ds; if (semctl(id, 0, IPC_STAT, un)) -- 2.1.4