Skip to content

Commit

Permalink
sigsuspend: Add testcase for EFAULT
Browse files Browse the repository at this point in the history
Add a testcase with the mask parameter points to an invalid address.

Signed-off-by: Ma Xinjian <[email protected]>
Reviewed-by: Cyril Hrubis <[email protected]>
  • Loading branch information
Ma Xinjian via ltp authored and metan-ucw committed Sep 17, 2024
1 parent 8edbd21 commit bdf4517
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions runtest/syscalls
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,7 @@ sigprocmask01 sigprocmask01
sigrelse01 sigrelse01

sigsuspend01 sigsuspend01
sigsuspend02 sigsuspend02

sigtimedwait01 sigtimedwait01

Expand Down
1 change: 1 addition & 0 deletions testcases/kernel/syscalls/sigsuspend/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/sigsuspend01
/sigsuspend02
34 changes: 34 additions & 0 deletions testcases/kernel/syscalls/sigsuspend/sigsuspend02.c
Original file line number Diff line number Diff line change
@@ -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,
};

0 comments on commit bdf4517

Please sign in to comment.