Skip to content

Commit

Permalink
acct01: add EFAULT errno check
Browse files Browse the repository at this point in the history
Add EFAULT errno check in acct01 testcase.

Link: https://lore.kernel.org/ltp/[email protected]/
Reviewed-by: Petr Vorel <[email protected]>
Signed-off-by: lufei <[email protected]>
  • Loading branch information
lufy90 authored and pevik committed Jul 29, 2024
1 parent 9c63908 commit aaa210b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions testcases/kernel/syscalls/acct/acct01.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#define FILE_TMPFILE "./tmpfile"
#define FILE_ELOOP "test_file_eloop1"
#define FILE_EROFS "ro_mntpoint/file"
#define FILE_EFAULT "invalid/file/name"

static struct passwd *ltpuser;

Expand All @@ -46,6 +47,7 @@ static char *file_eloop;
static char *file_enametoolong;
static char *file_erofs;
static char *file_null;
static char *file_efault;

static void setup_euid(void)
{
Expand All @@ -57,6 +59,16 @@ static void cleanup_euid(void)
SAFE_SETEUID(0);
}

static void setup_emem(void)
{
file_efault = SAFE_MMAP(NULL, 1, PROT_NONE,
MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
}
static void cleanup_emem(void)
{
SAFE_MUNMAP(file_efault, 1);
}

static struct test_case {
char **filename;
char *desc;
Expand All @@ -73,6 +85,7 @@ static struct test_case {
{&file_eloop, FILE_ELOOP, ELOOP, NULL, NULL},
{&file_enametoolong, "aaaa...", ENAMETOOLONG, NULL, NULL},
{&file_erofs, FILE_EROFS, EROFS, NULL, NULL},
{&file_efault, "Invalid address", EFAULT, setup_emem, cleanup_emem},
};

static void setup(void)
Expand Down

0 comments on commit aaa210b

Please sign in to comment.