Blame SOURCES/0161-tests-disable-tests-for-invalid-shmctl-commands-on-g.patch

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