|
|
deef8a |
From 8c1a84778bb05a3becc493698b215681bf7249b3 Mon Sep 17 00:00:00 2001
|
|
|
deef8a |
From: "Dmitry V. Levin" <ldv@altlinux.org>
|
|
|
deef8a |
Date: Sat, 19 Sep 2020 08:00:00 +0000
|
|
|
deef8a |
Subject: [PATCH 160/162] tests: disable shmctl IPC_STAT test with a bogus
|
|
|
deef8a |
address on glibc >= 2.32
|
|
|
deef8a |
|
|
|
deef8a |
Starting with commit glibc-2.32~80, on every 32-bit architecture where
|
|
|
deef8a |
32-bit time_t support is enabled, glibc tries to retrieve the data
|
|
|
deef8a |
provided in the third argument of shmctl call. This results to
|
|
|
deef8a |
segfaults inside glibc when shmctl is called with a bogus address.
|
|
|
deef8a |
|
|
|
deef8a |
* tests/ipc_shm.c [GLIBC_PREREQ_GE(2, 32) && __TIMESIZE != 64]
|
|
|
deef8a |
(TEST_SHMCTL_BOGUS_ADDR): Define to 0.
|
|
|
deef8a |
(main): Conditionalize on TEST_SHMCTL_BOGUS_ADDR the shmctl IPC_STAT
|
|
|
deef8a |
invocation with a bogus address.
|
|
|
deef8a |
---
|
|
|
deef8a |
tests/ipc_shm.c | 19 +++++++++++++++++++
|
|
|
deef8a |
1 file changed, 19 insertions(+)
|
|
|
deef8a |
|
|
|
deef8a |
diff --git a/tests/ipc_shm.c b/tests/ipc_shm.c
|
|
|
deef8a |
index 5cd414e..695fd94 100644
|
|
|
deef8a |
--- a/tests/ipc_shm.c
|
|
|
deef8a |
+++ b/tests/ipc_shm.c
|
|
|
deef8a |
@@ -73,6 +73,21 @@
|
|
|
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 |
@@ -92,7 +107,9 @@ main(void)
|
|
|
deef8a |
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
|
|
|
deef8a |
static const int bogus_id = 0xdefaced1;
|
|
|
deef8a |
static const int bogus_cmd = 0xdefaced2;
|
|
|
deef8a |
+#if TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
static void * const bogus_addr = (void *) -1L;
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
static const size_t bogus_size =
|
|
|
deef8a |
/*
|
|
|
deef8a |
* musl sets size to SIZE_MAX if size argument is greater than
|
|
|
deef8a |
@@ -160,10 +177,12 @@ main(void)
|
|
|
deef8a |
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
|
|
|
deef8a |
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
|
|
|
deef8a |
|
|
|
deef8a |
+#if TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
|
|
|
deef8a |
printf("shmctl\\(%d, (%s\\|)?%s, %p\\) = %s\n",
|
|
|
deef8a |
bogus_id, str_ipc_64, str_ipc_stat, bogus_addr,
|
|
|
deef8a |
sprintrc_grep(rc));
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
|
|
|
deef8a |
if (shmctl(id, IPC_STAT, &ds))
|
|
|
deef8a |
perror_msg_and_skip("shmctl IPC_STAT");
|
|
|
deef8a |
diff --git a/tests-m32/ipc_shm.c b/tests-m32/ipc_shm.c
|
|
|
deef8a |
index 5cd414e..695fd94 100644
|
|
|
deef8a |
--- a/tests-m32/ipc_shm.c
|
|
|
deef8a |
+++ b/tests-m32/ipc_shm.c
|
|
|
deef8a |
@@ -73,6 +73,21 @@
|
|
|
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 |
@@ -92,7 +107,9 @@ main(void)
|
|
|
deef8a |
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
|
|
|
deef8a |
static const int bogus_id = 0xdefaced1;
|
|
|
deef8a |
static const int bogus_cmd = 0xdefaced2;
|
|
|
deef8a |
+#if TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
static void * const bogus_addr = (void *) -1L;
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
static const size_t bogus_size =
|
|
|
deef8a |
/*
|
|
|
deef8a |
* musl sets size to SIZE_MAX if size argument is greater than
|
|
|
deef8a |
@@ -160,10 +177,12 @@ main(void)
|
|
|
deef8a |
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
|
|
|
deef8a |
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
|
|
|
deef8a |
|
|
|
deef8a |
+#if TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
|
|
|
deef8a |
printf("shmctl\\(%d, (%s\\|)?%s, %p\\) = %s\n",
|
|
|
deef8a |
bogus_id, str_ipc_64, str_ipc_stat, bogus_addr,
|
|
|
deef8a |
sprintrc_grep(rc));
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
|
|
|
deef8a |
if (shmctl(id, IPC_STAT, &ds))
|
|
|
deef8a |
perror_msg_and_skip("shmctl IPC_STAT");
|
|
|
deef8a |
diff --git a/tests-mx32/ipc_shm.c b/tests-mx32/ipc_shm.c
|
|
|
deef8a |
index 5cd414e..695fd94 100644
|
|
|
deef8a |
--- a/tests-mx32/ipc_shm.c
|
|
|
deef8a |
+++ b/tests-mx32/ipc_shm.c
|
|
|
deef8a |
@@ -73,6 +73,21 @@
|
|
|
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 |
@@ -92,7 +107,9 @@ main(void)
|
|
|
deef8a |
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
|
|
|
deef8a |
static const int bogus_id = 0xdefaced1;
|
|
|
deef8a |
static const int bogus_cmd = 0xdefaced2;
|
|
|
deef8a |
+#if TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
static void * const bogus_addr = (void *) -1L;
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
static const size_t bogus_size =
|
|
|
deef8a |
/*
|
|
|
deef8a |
* musl sets size to SIZE_MAX if size argument is greater than
|
|
|
deef8a |
@@ -160,10 +177,12 @@ main(void)
|
|
|
deef8a |
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
|
|
|
deef8a |
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
|
|
|
deef8a |
|
|
|
deef8a |
+#if TEST_SHMCTL_BOGUS_ADDR
|
|
|
deef8a |
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
|
|
|
deef8a |
printf("shmctl\\(%d, (%s\\|)?%s, %p\\) = %s\n",
|
|
|
deef8a |
bogus_id, str_ipc_64, str_ipc_stat, bogus_addr,
|
|
|
deef8a |
sprintrc_grep(rc));
|
|
|
deef8a |
+#endif
|
|
|
deef8a |
|
|
|
deef8a |
if (shmctl(id, IPC_STAT, &ds))
|
|
|
deef8a |
perror_msg_and_skip("shmctl IPC_STAT");
|
|
|
deef8a |
--
|
|
|
deef8a |
2.1.4
|
|
|
deef8a |
|