Skip to contentSkip to conversation

kernel/syscall/setrlimit05.c: use a legal bad address for mips

PATCH Superseded Hongzhi.Song 4 participants 8 messages Nov 5, 2018 – Nov 6, 2018

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel/syscall/setrlimit05.c: use a legal bad address for mips

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.

---
 testcases/kernel/syscalls/setrlimit/setrlimit05.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/setrlimit/setrlimit05.c +5 -1
index e716722..57b0b82 100644
@@ -31,9 +31,13 @@ static void verify_setrlimit(void)
 	int status;
 	pid_t pid;
 
+    void *bad_addr;
+
+    bad_addr = tst_get_bad_addr(NULL);
+
 	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);
Signature · 1 line
2.8.1
#1 lore raw

PATCH 1/1 kernel/syscall/setrlimit05.c: use a legal bad address for mips

Quoted 20 lines · Hongzhi.Song

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.

---
  testcases/kernel/syscalls/setrlimit/setrlimit05.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/setrlimit/setrlimit05.c +0 -0
index e716722..57b0b82 100644

testcases/kernel/syscalls/setrlimit/setrlimit05.c static void verify_setrlimit(void) · line 37

Quoted 7 lines
testcases/kernel/syscalls/setrlimit/setrlimit05.c +4 -0
@@ -31,9 +31,13 @@ static void verify_setrlimit(void)
  	int status;
  	pid_t pid;
 
+    void *bad_addr;
+
+    bad_addr = tst_get_bad_addr(NULL);
+

Hi Hongzhi,

Please use tab to do indention instead.
Other than that, it looks good to me.

Best Regards,
Xiao Yang

Quoted 7 lines
testcases/kernel/syscalls/setrlimit/setrlimit05.c +1 -1
  	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);
#2 lore raw

PATCH 1/1 kernel/syscall/setrlimit05.c: use a legal bad address for mips

Quoted 25 lines · Xiao Yang
Quoted 24 lines · Hongzhi.Song

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.

---
  testcases/kernel/syscalls/setrlimit/setrlimit05.c | 6 +++++-

  1 file changed, 5 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/setrlimit/setrlimit05.c +0 -0
index e716722..57b0b82 100644
@@ -31,9 +31,13 @@ static void verify_setrlimit(void)
       int status;
       pid_t pid;
 
Quoted 8 lines

testcases/kernel/syscalls/setrlimit/setrlimit05.c static void verify_setrlimit(void) · line 37

Quoted 4 lines
testcases/kernel/syscalls/setrlimit/setrlimit05.c +4 -0
+    void *bad_addr;
+
+    bad_addr = tst_get_bad_addr(NULL);
+

Hi Hongzhi,

Please use tab to do indention instead.
Other than that, it looks good to me.

Hi Yang,

My tab is set to 4 spaces in vim config. So if you open the file, it will be present as tab.

--Hongzhi

Quoted 14 lines

Best Regards,
Xiao Yang

Quoted 7 lines
testcases/kernel/syscalls/setrlimit/setrlimit05.c +1 -1
       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);
#3 lore raw

PATCH 1/1 kernel/syscall/setrlimit05.c: use a legal bad address for mips

In reply to Hongzhi.Song

Hi!

testcases/kernel/syscalls/setrlimit/setrlimit05.c static void verify_setrlimit(void) · line 36

Quoted 11 lines
testcases/kernel/syscalls/setrlimit/setrlimit05.c +3 -0
index e716722..57b0b82 100644
@@ -31,9 +31,13 @@ static void verify_setrlimit(void)
 	int status;
 	pid_t pid;
 
+    void *bad_addr;
+
+    bad_addr = tst_get_bad_addr(NULL);

It would be better if we called this only once in the test setup() function as the function actually maps a page of memory, the test may fail if we pass large enough -i parameter.

Quoted 13 lines
testcases/kernel/syscalls/setrlimit/setrlimit05.c +1 -1
 	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);
Signature · 5 lines
2.8.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis
[email protected]
#4 lore raw

PATCH 1/1 kernel/syscall/setrlimit05.c: use a legal bad address for mips

Quoted 9 lines · Cyril Hrubis

Hi!

Quoted 8 lines
testcases/kernel/syscalls/setrlimit/setrlimit05.c +0 -0
index e716722..57b0b82 100644
@@ -31,9 +31,13 @@ static void verify_setrlimit(void)
  	int status;
  	pid_t pid;
 
Quoted 6 lines

testcases/kernel/syscalls/setrlimit/setrlimit05.c static void verify_setrlimit(void) · line 36

Quoted 3 lines
testcases/kernel/syscalls/setrlimit/setrlimit05.c +3 -0
+    void *bad_addr;
+
+    bad_addr = tst_get_bad_addr(NULL);

It would be better if we called this only once in the test setup() function as the function actually maps a page of memory, the test may fail if we pass large enough -i parameter.

This case just runs one time. But I still send V2 with using setup() to apply memory.

--Hongzhi

Quoted 14 lines
Quoted 14 lines
testcases/kernel/syscalls/setrlimit/setrlimit05.c +1 -1
  	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);
Signature · 5 lines
2.8.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

PATCH 1/1 kernel/syscall/setrlimit05.c: use a legal bad address for mips

Hi!

Quoted 6 lines
Quoted 3 lines

It would be better if we called this only once in the test setup() function as the function actually maps a page of memory, the test may fail if we pass large enough -i parameter.

This case just runs one time. But I still send V2 with using setup() to apply memory.

All tests have command line parameters and one of them is -i which can be used to execute the test in a loop.

Signature · 2 lines
Cyril Hrubis
[email protected]
#6 lore raw

PATCH 1/1 kernel/syscall/setrlimit05.c: use a legal bad address for mips

In reply to Hongzhi.Song

Hi Hongzhi,

Do you try to build CONFIG_SYSCTL_SYSCALL and run sysctl04 on mips32? It seems that (void *) -1 is used in sysctl04.c as well. Perhaps, you can fix
the issue together if sysctl04 gets the same error on mips32. :-)

Best Regards,
Xiao Yang

Quoted 34 lines · Hongzhi.Song

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.

---
  testcases/kernel/syscalls/setrlimit/setrlimit05.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/setrlimit/setrlimit05.c +5 -1
index e716722..57b0b82 100644
@@ -31,9 +31,13 @@ static void verify_setrlimit(void)
  	int status;
  	pid_t pid;
 
+    void *bad_addr;
+
+    bad_addr = tst_get_bad_addr(NULL);
+
  	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);
#7 lore raw

PATCH 1/1 kernel/syscall/setrlimit05.c: use a legal bad address for mips

Quoted 6 lines · Xiao Yang

Hi Hongzhi,

Do you try to build CONFIG_SYSCTL_SYSCALL and run sysctl04 on mips32? It seems that (void *) -1 is used in sysctl04.c as well.  Perhaps, you can fix
the issue together if sysctl04 gets the same error on mips32. :-)

Thank you for your help.
I find that there is no glibc wrapper for syscall() but other syscall APIs do.

Sometimes, glibc converts struct32 to struct64, this behavior maybe has an effect on result.

--Hongzhi

Quoted 43 lines

Best Regards,
Xiao Yang

Quoted 35 lines · Hongzhi.Song

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.

---
  testcases/kernel/syscalls/setrlimit/setrlimit05.c | 6 +++++-

  1 file changed, 5 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/setrlimit/setrlimit05.c +5 -1
index e716722..57b0b82 100644
@@ -31,9 +31,13 @@ static void verify_setrlimit(void)
       int status;
       pid_t pid;
 
+    void *bad_addr;
+
+    bad_addr = tst_get_bad_addr(NULL);
+
       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);