Skip to contentSkip to conversation

sigsuspend: Add testcase for EFAULT

PATCH In review Ma Xinjian via ltp 2 participants 3 messages Jul 9, 2024 – Sep 17, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sigsuspend: Add testcase for EFAULT

Add a testcase with the mask parameter points to an invalid address.

---
 runtest/syscalls                              |  1 +
 .../kernel/syscalls/sigsuspend/.gitignore     |  1 +
 .../kernel/syscalls/sigsuspend/sigsuspend02.c | 34 +++++++++++++++++++
 3 files changed, 36 insertions(+)
 create mode 100644 testcases/kernel/syscalls/sigsuspend/sigsuspend02.c
runtest/syscalls +1 -0
index b6cadb2df..373f4d2e6 100644
@@ -1496,6 +1496,7 @@ sigprocmask01 sigprocmask01
 sigrelse01 sigrelse01
 
 sigsuspend01 sigsuspend01
+sigsuspend02 sigsuspend02
 
 sigtimedwait01 sigtimedwait01
 
testcases/kernel/syscalls/sigsuspend/.gitignore +1 -0
index 46ea52f73..926b73571 100644
@@ -1 +1,2 @@
 /sigsuspend01
+/sigsuspend02
testcases/kernel/syscalls/sigsuspend/sigsuspend02.c new file +34 -0
new file mode 100644
index 000000000..5bfed9d2d
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2024 FUJITSU LIMITED. All Rights Reserved.
+ * Copyright (c) Linux Test Project, 2024
+ * Author: Ma Xinjian <[email protected]>
+
+/*\
+ * [Description]
+ *
+ * Verify that sigsuspend(2) fails with
+ *
+ * - EFAULT mask points to memory which is not a valid part of the
+ *          process address space.
+ */
+
+#include "tst_test.h"
+
+static void *invalid_mask;
+
+static void setup(void)
+{
+        invalid_mask = tst_get_bad_addr(NULL);
+}
+
+static void verify_sigsuspend(void)
+{
+        TST_EXP_FAIL(sigsuspend(invalid_mask), EFAULT);
+}
+
+static struct tst_test test = {
+        .test_all = verify_sigsuspend,
+        .setup = setup,
+};
+
Signature · 4 lines
2.18.1

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

testcases/kernel/syscalls/sigsuspend/sigsuspend02.c line 6

Quoted 5 lines
testcases/kernel/syscalls/sigsuspend/sigsuspend02.c new file +5 -0
+/*
+ * Copyright (c) 2024 FUJITSU LIMITED. All Rights Reserved.
+ * Copyright (c) Linux Test Project, 2024
+ * Author: Ma Xinjian <[email protected]>
+

I've added */ here to end the first comment and pushed, thanks.

Quoted 8 lines

+/*\
+ * [Description]
+ *
+ * Verify that sigsuspend(2) fails with
+ *
+ * - EFAULT mask points to memory which is not a valid part of the
+ * process address space.
+ */

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hi!
And also replaced spaces with tabs.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp