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

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