* [LTP] [PATCH V2] setrlimit05: Use another method to get bad address
@ 2018-11-06 7:09 Hongzhi.Song
2018-11-06 7:09 ` [LTP] [PATCH V2] kernel/syscall/setrlimit05.c: use a legal bad address for mips Hongzhi.Song
0 siblings, 1 reply; 3+ messages in thread
From: Hongzhi.Song @ 2018-11-06 7:09 UTC (permalink / raw)
To: ltp
V2:
put tst_get_bad_add() to setup();
Hongzhi.Song (1):
kernel/syscall/setrlimit05.c: use a legal bad address for mips
testcases/kernel/syscalls/setrlimit/setrlimit05.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
--
2.8.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [LTP] [PATCH V2] kernel/syscall/setrlimit05.c: use a legal bad address for mips
2018-11-06 7:09 [LTP] [PATCH V2] setrlimit05: Use another method to get bad address Hongzhi.Song
@ 2018-11-06 7:09 ` Hongzhi.Song
2018-11-06 12:20 ` Cyril Hrubis
0 siblings, 1 reply; 3+ messages in thread
From: Hongzhi.Song @ 2018-11-06 7:09 UTC (permalink / raw)
To: ltp
This testcase fails on mips32. The process is killed by SIGBUS which
doesn't return EFAULT as expect.
This is because:
((void *)-1) is not a legal bad address which causes the process
killed by SIGBUG on mips.
'tst_get_bad_addr()' returns an address that should work on mips
and other arches.
Signed-off-by: Hongzhi.Song <hongzhi.song@windriver.com>
---
testcases/kernel/syscalls/setrlimit/setrlimit05.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/setrlimit/setrlimit05.c b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
index e716722..92ff33c 100644
--- a/testcases/kernel/syscalls/setrlimit/setrlimit05.c
+++ b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
@@ -26,6 +26,8 @@
#include "tst_test.h"
+static void *bad_addr;
+
static void verify_setrlimit(void)
{
int status;
@@ -33,7 +35,7 @@ static void verify_setrlimit(void)
pid = SAFE_FORK();
if (!pid) {
- TEST(setrlimit(RLIMIT_NOFILE, (void *) -1));
+ TEST(setrlimit(RLIMIT_NOFILE, (struct rlimit *)bad_addr));
if (TST_RET != -1) {
tst_res(TFAIL, "setrlimit() succeeded unexpectedly");
exit(0);
@@ -67,7 +69,13 @@ static void verify_setrlimit(void)
tst_res(TBROK, "child %s", tst_strstatus(status));
}
+static void setup(void)
+{
+ bad_addr = tst_get_bad_addr(NULL);
+}
+
static struct tst_test test = {
.test_all = verify_setrlimit,
.forks_child = 1,
+ .setup = setup,
};
--
2.8.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [LTP] [PATCH V2] kernel/syscall/setrlimit05.c: use a legal bad address for mips
2018-11-06 7:09 ` [LTP] [PATCH V2] kernel/syscall/setrlimit05.c: use a legal bad address for mips Hongzhi.Song
@ 2018-11-06 12:20 ` Cyril Hrubis
0 siblings, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2018-11-06 12:20 UTC (permalink / raw)
To: ltp
Hi!
> This testcase fails on mips32. The process is killed by SIGBUS which
> doesn't return EFAULT as expect.
>
> This is because:
> ((void *)-1) is not a legal bad address which causes the process
> killed by SIGBUG on mips.
>
> 'tst_get_bad_addr()' returns an address that should work on mips
> and other arches.
Generally looks good, minor nits pointed out below.
> Signed-off-by: Hongzhi.Song <hongzhi.song@windriver.com>
> ---
> testcases/kernel/syscalls/setrlimit/setrlimit05.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/testcases/kernel/syscalls/setrlimit/setrlimit05.c b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
> index e716722..92ff33c 100644
> --- a/testcases/kernel/syscalls/setrlimit/setrlimit05.c
> +++ b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
> @@ -26,6 +26,8 @@
>
> #include "tst_test.h"
>
> +static void *bad_addr;
> +
> static void verify_setrlimit(void)
> {
> int status;
> @@ -33,7 +35,7 @@ static void verify_setrlimit(void)
>
> pid = SAFE_FORK();
> if (!pid) {
> - TEST(setrlimit(RLIMIT_NOFILE, (void *) -1));
> + TEST(setrlimit(RLIMIT_NOFILE, (struct rlimit *)bad_addr));
^
This cast is not
needed, in C void *
pointer is converted
to any other pointer
automatically.
> if (TST_RET != -1) {
> tst_res(TFAIL, "setrlimit() succeeded unexpectedly");
> exit(0);
> @@ -67,7 +69,13 @@ static void verify_setrlimit(void)
> tst_res(TBROK, "child %s", tst_strstatus(status));
> }
>
> +static void setup(void)
> +{
> + bad_addr = tst_get_bad_addr(NULL);
You really should use tabs instead of spaces for indentation.
> +}
> +
> static struct tst_test test = {
> .test_all = verify_setrlimit,
> .forks_child = 1,
> + .setup = setup,
Here as well.
> };
> --
> 2.8.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-06 12:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-06 7:09 [LTP] [PATCH V2] setrlimit05: Use another method to get bad address Hongzhi.Song
2018-11-06 7:09 ` [LTP] [PATCH V2] kernel/syscall/setrlimit05.c: use a legal bad address for mips Hongzhi.Song
2018-11-06 12:20 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox