* [LTP] [PATCH 0/2] Add test for epoll_pwait{04, 05}
@ 2021-08-10 11:00 Xie Ziyao
2021-08-10 11:00 ` [LTP] [PATCH 1/2] epoll_pwait: Add invalid sigmask test for epoll_pwait04 Xie Ziyao
2021-08-10 11:00 ` [LTP] [PATCH 2/2] epoll_pwait: Add invalid timespec test for epoll_pwait05 Xie Ziyao
0 siblings, 2 replies; 4+ messages in thread
From: Xie Ziyao @ 2021-08-10 11:00 UTC (permalink / raw)
To: ltp
Xie Ziyao (2):
epoll_pwait: Add invalid sigmask test for epoll_pwait04
epoll_pwait: Add invalid timespec test for epoll_pwait05
runtest/syscalls | 2 +
.../kernel/syscalls/epoll_pwait/.gitignore | 2 +
.../syscalls/epoll_pwait/epoll_pwait04.c | 61 ++++++++++++++++
.../syscalls/epoll_pwait/epoll_pwait05.c | 70 +++++++++++++++++++
4 files changed, 135 insertions(+)
create mode 100644 testcases/kernel/syscalls/epoll_pwait/epoll_pwait04.c
create mode 100644 testcases/kernel/syscalls/epoll_pwait/epoll_pwait05.c
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH 1/2] epoll_pwait: Add invalid sigmask test for epoll_pwait04
2021-08-10 11:00 [LTP] [PATCH 0/2] Add test for epoll_pwait{04, 05} Xie Ziyao
@ 2021-08-10 11:00 ` Xie Ziyao
2021-08-11 13:47 ` Cyril Hrubis
2021-08-10 11:00 ` [LTP] [PATCH 2/2] epoll_pwait: Add invalid timespec test for epoll_pwait05 Xie Ziyao
1 sibling, 1 reply; 4+ messages in thread
From: Xie Ziyao @ 2021-08-10 11:00 UTC (permalink / raw)
To: ltp
Verify that, epoll_pwait() and epoll_pwait2() return -1 and set errno to
EFAULT with a sigmask points outside user's accessible address space.
Fixes: #792
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
runtest/syscalls | 1 +
.../kernel/syscalls/epoll_pwait/.gitignore | 1 +
.../syscalls/epoll_pwait/epoll_pwait04.c | 61 +++++++++++++++++++
3 files changed, 63 insertions(+)
create mode 100644 testcases/kernel/syscalls/epoll_pwait/epoll_pwait04.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 9af5aa5c0..206281f6e 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -168,6 +168,7 @@ epoll_wait03 epoll_wait03
epoll_pwait01 epoll_pwait01
epoll_pwait02 epoll_pwait02
epoll_pwait03 epoll_pwait03
+epoll_pwait04 epoll_pwait04
eventfd01 eventfd01
diff --git a/testcases/kernel/syscalls/epoll_pwait/.gitignore b/testcases/kernel/syscalls/epoll_pwait/.gitignore
index 1d16367e6..cdefffa2d 100644
--- a/testcases/kernel/syscalls/epoll_pwait/.gitignore
+++ b/testcases/kernel/syscalls/epoll_pwait/.gitignore
@@ -1,3 +1,4 @@
epoll_pwait01
epoll_pwait02
epoll_pwait03
+epoll_pwait04
diff --git a/testcases/kernel/syscalls/epoll_pwait/epoll_pwait04.c b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait04.c
new file mode 100644
index 000000000..2c855dab6
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait04.c
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
+ * Author: Xie Ziyao <xieziyao@huawei.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Verify that, epoll_pwait() and epoll_pwait2() return -1 and set errno to
+ * EFAULT with a sigmask points outside user's accessible address space.
+ */
+
+#include <sys/epoll.h>
+
+#include "tst_test.h"
+#include "epoll_pwait_var.h"
+
+static int efd, sfd[2];
+static struct epoll_event e;
+
+static void run(void)
+{
+ TST_EXP_FAIL(do_epoll_pwait(efd, &e, 1, -1, tst_get_bad_addr(NULL)),
+ EFAULT, "with an invalid sigmask pointer");
+}
+
+static void setup(void)
+{
+ epoll_pwait_info();
+
+ SAFE_SOCKETPAIR(AF_UNIX, SOCK_STREAM, 0, sfd);
+
+ efd = epoll_create(1);
+ if (efd == -1)
+ tst_brk(TBROK | TERRNO, "epoll_create()");
+
+ e.events = EPOLLIN;
+ if (epoll_ctl(efd, EPOLL_CTL_ADD, sfd[0], &e))
+ tst_brk(TBROK | TERRNO, "epoll_clt(..., EPOLL_CTL_ADD, ...)");
+ SAFE_WRITE(1, sfd[1], "w", 1);
+}
+
+static void cleanup(void)
+{
+ if (efd > 0)
+ SAFE_CLOSE(efd);
+
+ if (sfd[0] > 0)
+ SAFE_CLOSE(sfd[0]);
+
+ if (sfd[1] > 0)
+ SAFE_CLOSE(sfd[1]);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .setup = setup,
+ .cleanup = cleanup,
+ .test_variants = TEST_VARIANTS,
+};
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH 2/2] epoll_pwait: Add invalid timespec test for epoll_pwait05
2021-08-10 11:00 [LTP] [PATCH 0/2] Add test for epoll_pwait{04, 05} Xie Ziyao
2021-08-10 11:00 ` [LTP] [PATCH 1/2] epoll_pwait: Add invalid sigmask test for epoll_pwait04 Xie Ziyao
@ 2021-08-10 11:00 ` Xie Ziyao
1 sibling, 0 replies; 4+ messages in thread
From: Xie Ziyao @ 2021-08-10 11:00 UTC (permalink / raw)
To: ltp
Verify that, epoll_pwait2() return -1 and set errno to EINVAL with an invalid timespec.
Fixes: #792
Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
runtest/syscalls | 1 +
.../kernel/syscalls/epoll_pwait/.gitignore | 1 +
.../syscalls/epoll_pwait/epoll_pwait05.c | 70 +++++++++++++++++++
3 files changed, 72 insertions(+)
create mode 100644 testcases/kernel/syscalls/epoll_pwait/epoll_pwait05.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 206281f6e..d3fc98758 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -169,6 +169,7 @@ epoll_pwait01 epoll_pwait01
epoll_pwait02 epoll_pwait02
epoll_pwait03 epoll_pwait03
epoll_pwait04 epoll_pwait04
+epoll_pwait05 epoll_pwait05
eventfd01 eventfd01
diff --git a/testcases/kernel/syscalls/epoll_pwait/.gitignore b/testcases/kernel/syscalls/epoll_pwait/.gitignore
index cdefffa2d..fafb2d782 100644
--- a/testcases/kernel/syscalls/epoll_pwait/.gitignore
+++ b/testcases/kernel/syscalls/epoll_pwait/.gitignore
@@ -2,3 +2,4 @@ epoll_pwait01
epoll_pwait02
epoll_pwait03
epoll_pwait04
+epoll_pwait05
diff --git a/testcases/kernel/syscalls/epoll_pwait/epoll_pwait05.c b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait05.c
new file mode 100644
index 000000000..1373c36e5
--- /dev/null
+++ b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait05.c
@@ -0,0 +1,70 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
+ * Author: Xie Ziyao <xieziyao@huawei.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Verify that, epoll_pwait2() return -1 and set errno to EINVAL with an
+ * invalid timespec.
+ */
+
+#include <sys/epoll.h>
+
+#include "tst_test.h"
+#include "tst_timer.h"
+#include "lapi/epoll.h"
+
+static int efd, sfd[2];
+static struct epoll_event e;
+
+static struct test_case_t {
+ struct timespec ts;
+ int exp_errno;
+ const char *desc;
+} tc[] = {
+ {{.tv_sec = -1}, EINVAL, "ts.tv_sec < 0"},
+ {{.tv_nsec = -1}, EINVAL, "ts.tv_nsec < 0"},
+ {{.tv_nsec = NSEC_PER_SEC}, EINVAL, "ts.tv_nsec >= NSEC_PER_SEC"},
+};
+
+static void run_all(unsigned int n)
+{
+ TST_EXP_FAIL(epoll_pwait2(efd, &e, 1, &tc[n].ts, NULL),
+ tc[n].exp_errno, "with %s", tc[n].desc);
+}
+
+static void setup(void)
+{
+ SAFE_SOCKETPAIR(AF_UNIX, SOCK_STREAM, 0, sfd);
+
+ efd = epoll_create(1);
+ if (efd == -1)
+ tst_brk(TBROK | TERRNO, "epoll_create()");
+
+ e.events = EPOLLIN;
+ if (epoll_ctl(efd, EPOLL_CTL_ADD, sfd[0], &e))
+ tst_brk(TBROK | TERRNO, "epoll_clt(..., EPOLL_CTL_ADD, ...)");
+ SAFE_WRITE(1, sfd[1], "w", 1);
+}
+
+static void cleanup(void)
+{
+ if (efd > 0)
+ SAFE_CLOSE(efd);
+
+ if (sfd[0] > 0)
+ SAFE_CLOSE(sfd[0]);
+
+ if (sfd[1] > 0)
+ SAFE_CLOSE(sfd[1]);
+}
+
+static struct tst_test test = {
+ .test = run_all,
+ .setup = setup,
+ .cleanup = cleanup,
+ .tcnt = ARRAY_SIZE(tc),
+};
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH 1/2] epoll_pwait: Add invalid sigmask test for epoll_pwait04
2021-08-10 11:00 ` [LTP] [PATCH 1/2] epoll_pwait: Add invalid sigmask test for epoll_pwait04 Xie Ziyao
@ 2021-08-11 13:47 ` Cyril Hrubis
0 siblings, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2021-08-11 13:47 UTC (permalink / raw)
To: ltp
Hi!
> +static void run(void)
> +{
> + TST_EXP_FAIL(do_epoll_pwait(efd, &e, 1, -1, tst_get_bad_addr(NULL)),
> + EFAULT, "with an invalid sigmask pointer");
The tst_get_bad_addr() allocates memory so I've moved it to the test
setup() so that the test does not get out of memory with large enough -i
option.
Patchset pushed, good work, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-08-11 13:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-10 11:00 [LTP] [PATCH 0/2] Add test for epoll_pwait{04, 05} Xie Ziyao
2021-08-10 11:00 ` [LTP] [PATCH 1/2] epoll_pwait: Add invalid sigmask test for epoll_pwait04 Xie Ziyao
2021-08-11 13:47 ` Cyril Hrubis
2021-08-10 11:00 ` [LTP] [PATCH 2/2] epoll_pwait: Add invalid timespec test for epoll_pwait05 Xie Ziyao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox