|
|
deef8a |
From 268b9341ef6397cc337f612563af88ccb5752ca7 Mon Sep 17 00:00:00 2001
|
|
|
deef8a |
From: "Dmitry V. Levin" <ldv@altlinux.org>
|
|
|
deef8a |
Date: Sun, 6 Dec 2020 08:00:00 +0000
|
|
|
deef8a |
Subject: [PATCH 161/162] tests: disable tests for invalid shmctl commands on
|
|
|
deef8a |
glibc >= 2.32
|
|
|
deef8a |
|
|
|
deef8a |
Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
|
|
|
deef8a |
glibc skips shmctl syscall invocations and returns EINVAL
|
|
|
deef8a |
for invalid shmctl commands.
|
|
|
deef8a |
|
|
|
deef8a |
* tests/ipc_shm.c [GLIBC_PREREQ_GE(2, 32)] (TEST_SHMCTL_BOGUS_CMD):
|
|
|
deef8a |
Define to 0.
|
|
|
deef8a |
[!TEST_SHMCTL_BOGUS_CMD] (TEST_SHMCTL_BOGUS_CMD): Define to 1.
|
|
|
deef8a |
(main) [!TEST_SHMCTL_BOGUS_CMD] (bogus_cmd): Do not define and do not
|
|
|
deef8a |
use.
|
|
|
deef8a |
---
|
|
|
deef8a |
tests/ipc_shm.c | 49 ++++++++++++++++++++++++++++++++++---------------
|
|
|
deef8a |
1 file changed, 34 insertions(+), 15 deletions(-)
|
|
|
deef8a |
|
|
|
deef8a |
diff --git a/tests/ipc_shm.c b/tests/ipc_shm.c
|
|
|
deef8a |
index 695fd94..350bde5 100644
|
|
|
deef8a |
--- a/tests/ipc_shm.c
|
|
|
deef8a |
+++ b/tests/ipc_shm.c
|
|
|
deef8a |
@@ -29,6 +29,34 @@
|
|
|
deef8a |
# define SHM_NORESERVE 010000
|
|
|
deef8a |
#endif
|
|
|
deef8a |
|
|
|
deef8a |
+#undef TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
+#undef TEST_SHMCTL_BOGUS_CMD
|
|
|
deef8a |
+
|
|
|
deef8a |
+/*
|
|
|
deef8a |
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
|
|
|
deef8a |
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
|
|
|
deef8a |
+ * the data provided in the third argument of shmctl call.
|
|
|
deef8a |
+ */
|
|
|
deef8a |
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
|
|
deef8a |
+# define TEST_SHMCTL_BOGUS_ADDR 0
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
+
|
|
|
deef8a |
+/*
|
|
|
deef8a |
+ * Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
|
|
|
deef8a |
+ * glibc skips shmctl syscall invocations and returns EINVAL
|
|
|
deef8a |
+ * for invalid shmctl commands.
|
|
|
deef8a |
+ */
|
|
|
deef8a |
+#if GLIBC_PREREQ_GE(2, 32)
|
|
|
deef8a |
+# define TEST_SHMCTL_BOGUS_CMD 0
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
+
|
|
|
deef8a |
+#ifndef TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
+# define TEST_SHMCTL_BOGUS_ADDR 1
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
+#ifndef TEST_SHMCTL_BOGUS_CMD
|
|
|
deef8a |
+# define TEST_SHMCTL_BOGUS_CMD 1
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
+
|
|
|
deef8a |
#include "xlat.h"
|
|
|
deef8a |
#include "xlat/shm_resource_flags.h"
|
|
|
deef8a |
|
|
|
deef8a |
@@ -73,21 +101,6 @@
|
|
|
deef8a |
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
|
|
|
deef8a |
#endif
|
|
|
deef8a |
|
|
|
deef8a |
-#undef TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
-
|
|
|
deef8a |
-/*
|
|
|
deef8a |
- * Starting with commit glibc-2.32~80, on every 32-bit architecture
|
|
|
deef8a |
- * where 32-bit time_t support is enabled, glibc tries to retrieve
|
|
|
deef8a |
- * the data provided in the third argument of shmctl call.
|
|
|
deef8a |
- */
|
|
|
deef8a |
-#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
|
|
deef8a |
-# define TEST_SHMCTL_BOGUS_ADDR 0
|
|
|
deef8a |
-#endif
|
|
|
deef8a |
-
|
|
|
deef8a |
-#ifndef TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
-# define TEST_SHMCTL_BOGUS_ADDR 1
|
|
|
deef8a |
-#endif
|
|
|
deef8a |
-
|
|
|
deef8a |
static int id = -1;
|
|
|
deef8a |
|
|
|
deef8a |
static void
|
|
|
deef8a |
@@ -105,8 +118,12 @@ main(void)
|
|
|
deef8a |
static const key_t private_key =
|
|
|
deef8a |
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
|
|
|
deef8a |
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
|
|
|
deef8a |
+#if TEST_SHMCTL_BOGUS_CMD || TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
static const int bogus_id = 0xdefaced1;
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
+#if TEST_SHMCTL_BOGUS_CMD
|
|
|
deef8a |
static const int bogus_cmd = 0xdefaced2;
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
#if TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
static void * const bogus_addr = (void *) -1L;
|
|
|
deef8a |
#endif
|
|
|
deef8a |
@@ -173,9 +190,11 @@ main(void)
|
|
|
deef8a |
printf("shmget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
|
|
|
deef8a |
atexit(cleanup);
|
|
|
deef8a |
|
|
|
deef8a |
+#if TEST_SHMCTL_BOGUS_CMD
|
|
|
deef8a |
rc = shmctl(bogus_id, bogus_cmd, NULL);
|
|
|
deef8a |
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
|
|
|
deef8a |
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
|
|
|
deef8a |
#if TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
|
|
|
deef8a |
diff --git a/tests-m32/ipc_shm.c b/tests-m32/ipc_shm.c
|
|
|
deef8a |
index 695fd94..350bde5 100644
|
|
|
deef8a |
--- a/tests-m32/ipc_shm.c
|
|
|
deef8a |
+++ b/tests-m32/ipc_shm.c
|
|
|
deef8a |
@@ -29,6 +29,34 @@
|
|
|
deef8a |
# define SHM_NORESERVE 010000
|
|
|
deef8a |
#endif
|
|
|
deef8a |
|
|
|
deef8a |
+#undef TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
+#undef TEST_SHMCTL_BOGUS_CMD
|
|
|
deef8a |
+
|
|
|
deef8a |
+/*
|
|
|
deef8a |
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
|
|
|
deef8a |
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
|
|
|
deef8a |
+ * the data provided in the third argument of shmctl call.
|
|
|
deef8a |
+ */
|
|
|
deef8a |
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
|
|
deef8a |
+# define TEST_SHMCTL_BOGUS_ADDR 0
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
+
|
|
|
deef8a |
+/*
|
|
|
deef8a |
+ * Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
|
|
|
deef8a |
+ * glibc skips shmctl syscall invocations and returns EINVAL
|
|
|
deef8a |
+ * for invalid shmctl commands.
|
|
|
deef8a |
+ */
|
|
|
deef8a |
+#if GLIBC_PREREQ_GE(2, 32)
|
|
|
deef8a |
+# define TEST_SHMCTL_BOGUS_CMD 0
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
+
|
|
|
deef8a |
+#ifndef TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
+# define TEST_SHMCTL_BOGUS_ADDR 1
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
+#ifndef TEST_SHMCTL_BOGUS_CMD
|
|
|
deef8a |
+# define TEST_SHMCTL_BOGUS_CMD 1
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
+
|
|
|
deef8a |
#include "xlat.h"
|
|
|
deef8a |
#include "xlat/shm_resource_flags.h"
|
|
|
deef8a |
|
|
|
deef8a |
@@ -73,21 +101,6 @@
|
|
|
deef8a |
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
|
|
|
deef8a |
#endif
|
|
|
deef8a |
|
|
|
deef8a |
-#undef TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
-
|
|
|
deef8a |
-/*
|
|
|
deef8a |
- * Starting with commit glibc-2.32~80, on every 32-bit architecture
|
|
|
deef8a |
- * where 32-bit time_t support is enabled, glibc tries to retrieve
|
|
|
deef8a |
- * the data provided in the third argument of shmctl call.
|
|
|
deef8a |
- */
|
|
|
deef8a |
-#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
|
|
deef8a |
-# define TEST_SHMCTL_BOGUS_ADDR 0
|
|
|
deef8a |
-#endif
|
|
|
deef8a |
-
|
|
|
deef8a |
-#ifndef TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
-# define TEST_SHMCTL_BOGUS_ADDR 1
|
|
|
deef8a |
-#endif
|
|
|
deef8a |
-
|
|
|
deef8a |
static int id = -1;
|
|
|
deef8a |
|
|
|
deef8a |
static void
|
|
|
deef8a |
@@ -105,8 +118,12 @@ main(void)
|
|
|
deef8a |
static const key_t private_key =
|
|
|
deef8a |
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
|
|
|
deef8a |
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
|
|
|
deef8a |
+#if TEST_SHMCTL_BOGUS_CMD || TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
static const int bogus_id = 0xdefaced1;
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
+#if TEST_SHMCTL_BOGUS_CMD
|
|
|
deef8a |
static const int bogus_cmd = 0xdefaced2;
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
#if TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
static void * const bogus_addr = (void *) -1L;
|
|
|
deef8a |
#endif
|
|
|
deef8a |
@@ -173,9 +190,11 @@ main(void)
|
|
|
deef8a |
printf("shmget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
|
|
|
deef8a |
atexit(cleanup);
|
|
|
deef8a |
|
|
|
deef8a |
+#if TEST_SHMCTL_BOGUS_CMD
|
|
|
deef8a |
rc = shmctl(bogus_id, bogus_cmd, NULL);
|
|
|
deef8a |
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
|
|
|
deef8a |
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
|
|
|
deef8a |
#if TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
|
|
|
deef8a |
diff --git a/tests-mx32/ipc_shm.c b/tests-mx32/ipc_shm.c
|
|
|
deef8a |
index 695fd94..350bde5 100644
|
|
|
deef8a |
--- a/tests-mx32/ipc_shm.c
|
|
|
deef8a |
+++ b/tests-mx32/ipc_shm.c
|
|
|
deef8a |
@@ -29,6 +29,34 @@
|
|
|
deef8a |
# define SHM_NORESERVE 010000
|
|
|
deef8a |
#endif
|
|
|
deef8a |
|
|
|
deef8a |
+#undef TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
+#undef TEST_SHMCTL_BOGUS_CMD
|
|
|
deef8a |
+
|
|
|
deef8a |
+/*
|
|
|
deef8a |
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
|
|
|
deef8a |
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
|
|
|
deef8a |
+ * the data provided in the third argument of shmctl call.
|
|
|
deef8a |
+ */
|
|
|
deef8a |
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
|
|
deef8a |
+# define TEST_SHMCTL_BOGUS_ADDR 0
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
+
|
|
|
deef8a |
+/*
|
|
|
deef8a |
+ * Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
|
|
|
deef8a |
+ * glibc skips shmctl syscall invocations and returns EINVAL
|
|
|
deef8a |
+ * for invalid shmctl commands.
|
|
|
deef8a |
+ */
|
|
|
deef8a |
+#if GLIBC_PREREQ_GE(2, 32)
|
|
|
deef8a |
+# define TEST_SHMCTL_BOGUS_CMD 0
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
+
|
|
|
deef8a |
+#ifndef TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
+# define TEST_SHMCTL_BOGUS_ADDR 1
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
+#ifndef TEST_SHMCTL_BOGUS_CMD
|
|
|
deef8a |
+# define TEST_SHMCTL_BOGUS_CMD 1
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
+
|
|
|
deef8a |
#include "xlat.h"
|
|
|
deef8a |
#include "xlat/shm_resource_flags.h"
|
|
|
deef8a |
|
|
|
deef8a |
@@ -73,21 +101,6 @@
|
|
|
deef8a |
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
|
|
|
deef8a |
#endif
|
|
|
deef8a |
|
|
|
deef8a |
-#undef TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
-
|
|
|
deef8a |
-/*
|
|
|
deef8a |
- * Starting with commit glibc-2.32~80, on every 32-bit architecture
|
|
|
deef8a |
- * where 32-bit time_t support is enabled, glibc tries to retrieve
|
|
|
deef8a |
- * the data provided in the third argument of shmctl call.
|
|
|
deef8a |
- */
|
|
|
deef8a |
-#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
|
|
deef8a |
-# define TEST_SHMCTL_BOGUS_ADDR 0
|
|
|
deef8a |
-#endif
|
|
|
deef8a |
-
|
|
|
deef8a |
-#ifndef TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
-# define TEST_SHMCTL_BOGUS_ADDR 1
|
|
|
deef8a |
-#endif
|
|
|
deef8a |
-
|
|
|
deef8a |
static int id = -1;
|
|
|
deef8a |
|
|
|
deef8a |
static void
|
|
|
deef8a |
@@ -105,8 +118,12 @@ main(void)
|
|
|
deef8a |
static const key_t private_key =
|
|
|
deef8a |
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
|
|
|
deef8a |
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
|
|
|
deef8a |
+#if TEST_SHMCTL_BOGUS_CMD || TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
static const int bogus_id = 0xdefaced1;
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
+#if TEST_SHMCTL_BOGUS_CMD
|
|
|
deef8a |
static const int bogus_cmd = 0xdefaced2;
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
#if TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
static void * const bogus_addr = (void *) -1L;
|
|
|
deef8a |
#endif
|
|
|
deef8a |
@@ -173,9 +190,11 @@ main(void)
|
|
|
deef8a |
printf("shmget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
|
|
|
deef8a |
atexit(cleanup);
|
|
|
deef8a |
|
|
|
deef8a |
+#if TEST_SHMCTL_BOGUS_CMD
|
|
|
deef8a |
rc = shmctl(bogus_id, bogus_cmd, NULL);
|
|
|
deef8a |
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
|
|
|
deef8a |
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
|
|
|
deef8a |
#if TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
|
|
|
deef8a |
--
|
|
|
deef8a |
2.1.4
|
|
|
deef8a |
|