public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: lufei <lufei@uniontech.com>
To: ltp@lists.linux.it
Cc: lufei <lufei@uniontech.com>
Subject: [LTP] [PATCH] acct01: add EFAULT errno check.
Date: Mon, 24 Jun 2024 09:52:45 +0800	[thread overview]
Message-ID: <20240624015245.54968-2-lufei@uniontech.com> (raw)
In-Reply-To: <20240624015245.54968-1-lufei@uniontech.com>

Add EFAULT errno check in acct01 testcase.

Signed-off-by: lufei <lufei@uniontech.com>
---
 testcases/kernel/syscalls/acct/acct01.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/testcases/kernel/syscalls/acct/acct01.c b/testcases/kernel/syscalls/acct/acct01.c
index 1b53a32f2..ed1817bc5 100644
--- a/testcases/kernel/syscalls/acct/acct01.c
+++ b/testcases/kernel/syscalls/acct/acct01.c
@@ -33,6 +33,7 @@
 #define FILE_TMPFILE		"./tmpfile"
 #define FILE_ELOOP		"test_file_eloop1"
 #define FILE_EROFS		"ro_mntpoint/file"
+#define FILE_EFAULT		"/tmp/invalid/file/name"
 
 static struct passwd *ltpuser;
 
@@ -45,6 +46,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)
 {
@@ -56,6 +58,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;
@@ -72,6 +84,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,	FILE_EFAULT,  EFAULT,  setup_emem, cleanup_emem},
 };
 
 static void setup(void)
-- 
2.39.3


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

  parent reply	other threads:[~2024-06-24  1:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-06  6:55 [LTP] [PATCH] acct01: add EFAULT errno check lufei
2024-06-21 12:00 ` Petr Vorel
     [not found] ` <20240624015245.54968-1-lufei@uniontech.com>
2024-06-24  1:52   ` lufei [this message]
2024-07-08  4:23     ` Petr Vorel
2024-07-08  5:31       ` 路斐
2024-07-08  8:54         ` Petr Vorel
2024-07-29 22:44           ` Petr Vorel
2024-06-24  1:54 ` [LTP] [PATCH] acct: fix make check errors: using .needs_kconfigs lufei
2024-07-04 13:29 ` [LTP] [PATCH] acct01: add EFAULT errno check Cyril Hrubis
2024-07-05  2:02   ` 路斐
2024-07-08  8:56     ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240624015245.54968-2-lufei@uniontech.com \
    --to=lufei@uniontech.com \
    --cc=ltp@lists.linux.it \
    --cc=pvorel@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox