aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/ltp/ltp/0001-setrlimit05-Use-another-method-to-get-bad-address.patch
blob: 4bfe2767d8a5063f7c0e855f1be5c37703b50324 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From c4d02b23d12b7136b5739b3075e817fc037e41d4 Mon Sep 17 00:00:00 2001
From: "Hongzhi.Song" <hongzhi.song@windriver.com>
Date: Mon, 19 Nov 2018 23:07:01 -0800
Subject: [PATCH] setrlimit05: Use another method to get bad address

This testcase fails on mips32. The process is killed by SIGBUS which
is not 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 works on mips
and other arches.

Upstream-Status: Accepted [80bed467bc6ab48a6cd88a8ab74ca15d08830cb0]

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 e7167229b4..004a149a65 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, 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.11.0