Skip to contentSkip to conversation

stress-shm-sysv: exercise shmat with invalid flags

PATCH In review Piyush Goyal 2 participants 4 messages Sep 22, 2020 Arm MediaTek

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 stress-shm-sysv: exercise shmat with invalid flags

Exercise shmat syscall with invalid flags resulting in more kernel coverage.

---
 stress-shm-sysv.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
stress-shm-sysv.c +14 -0
index aa03d718..5a3e0cc1 100644
@@ -128,6 +128,19 @@ static int stress_shm_sysv_check(
 	return 0;
 }
 
+/*
+ *  exercise_shmat()
+ *	exercise shmat syscall with all possible values of arguments
+ */
+static void exercise_shmat(int shm_id)
+{
+	void *addr;
+
+	/* Exercise shmat syscall with invalid flags */
+	addr = shmat(shm_id, NULL, ~0);
+	(void)addr;
+}
+
 #if defined(__linux__)
 /*
  *  stress_shm_get_procinfo()
@@ -337,6 +350,7 @@ static int stress_shm_sysv_child(
 				goto reap;
 			}
 
+			exercise_shmat(shm_id);
 			addr = shmat(shm_id, NULL, 0);
 			if (addr == (char *) -1) {
 				ok = false;
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/3 stress-shm-sysv: exercise shmat with all possible flags

Exercise shmat syscall with all possible flags resulting in more kernel coverage.

---
 stress-shm-sysv.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
stress-shm-sysv.c +10 -0
index 5a3e0cc1..9efaa091 100644
@@ -139,6 +139,16 @@ static void exercise_shmat(int shm_id)
 	/* Exercise shmat syscall with invalid flags */
 	addr = shmat(shm_id, NULL, ~0);
 	(void)addr;
+
+	/* Exercise shmat with all possible values of flags */
+	addr = shmat(shm_id, NULL, SHM_RDONLY);
+	(void)addr;
+
+	addr = shmat(shm_id, NULL, SHM_EXEC);
+	(void)addr;
+
+	addr = shmat(shm_id, NULL, SHM_RND);
+	(void)addr;
 }
 
 #if defined(__linux__)
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/3 stress-shmsysv: exercise shmat with SHM_REMAP flag on NULL address

In reply to Piyush Goyal

Exercise shmat syscall with SHM_REMAP flag on NULL address resulting in EINVAL error and more kernel coverage.

---
 stress-shm-sysv.c | 4 ++++
 1 file changed, 4 insertions(+)
stress-shm-sysv.c +4 -0
index 9efaa091..e2aff788 100644
@@ -149,6 +149,10 @@ static void exercise_shmat(int shm_id)
 
 	addr = shmat(shm_id, NULL, SHM_RND);
 	(void)addr;
+
+	/* Exercise shmat with SHM_REMAP flag on NULL address */
+	addr = shmat(shm_id, NULL, SHM_REMAP);
+	(void)addr;
 }
 
 #if defined(__linux__)
Signature · 1 line
2.25.1
#3 lore raw
In reply to Piyush Goyal

I believe these patches should have gone directly to me and not various other folk.

Colin

Quoted 41 lines · Piyush Goyal

Exercise shmat syscall with invalid flags resulting in more kernel coverage.

---
 stress-shm-sysv.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
stress-shm-sysv.c +14 -0
index aa03d718..5a3e0cc1 100644
@@ -128,6 +128,19 @@ static int stress_shm_sysv_check(
 	return 0;
 }
 
+/*
+ *  exercise_shmat()
+ *	exercise shmat syscall with all possible values of arguments
+ */
+static void exercise_shmat(int shm_id)
+{
+	void *addr;
+
+	/* Exercise shmat syscall with invalid flags */
+	addr = shmat(shm_id, NULL, ~0);
+	(void)addr;
+}
+
 #if defined(__linux__)
 /*
  *  stress_shm_get_procinfo()
@@ -337,6 +350,7 @@ static int stress_shm_sysv_child(
 				goto reap;
 			}
 
+			exercise_shmat(shm_id);
 			addr = shmat(shm_id, NULL, 0);
 			if (addr == (char *) -1) {
 				ok = false;