From bdf4517d48ce440b06f4715d732c6e424b77c3da Mon Sep 17 00:00:00 2001 From: Ma Xinjian via ltp Date: Tue, 9 Jul 2024 17:50:45 +0800 Subject: [PATCH] sigsuspend: Add testcase for EFAULT Add a testcase with the mask parameter points to an invalid address. Signed-off-by: Ma Xinjian Reviewed-by: Cyril Hrubis --- 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 diff --git a/runtest/syscalls b/runtest/syscalls index 1be313507a6..02e721df9c2 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1528,6 +1528,7 @@ sigprocmask01 sigprocmask01 sigrelse01 sigrelse01 sigsuspend01 sigsuspend01 +sigsuspend02 sigsuspend02 sigtimedwait01 sigtimedwait01 diff --git a/testcases/kernel/syscalls/sigsuspend/.gitignore b/testcases/kernel/syscalls/sigsuspend/.gitignore index 46ea52f739f..926b735714f 100644 --- a/testcases/kernel/syscalls/sigsuspend/.gitignore +++ b/testcases/kernel/syscalls/sigsuspend/.gitignore @@ -1 +1,2 @@ /sigsuspend01 +/sigsuspend02 diff --git a/testcases/kernel/syscalls/sigsuspend/sigsuspend02.c b/testcases/kernel/syscalls/sigsuspend/sigsuspend02.c new file mode 100644 index 00000000000..1b3904044d4 --- /dev/null +++ b/testcases/kernel/syscalls/sigsuspend/sigsuspend02.c @@ -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 + */ + +/*\ + * [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, +};