All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] kernel/syscall/setrlimit05.c: use a legal bad address for mips
@ 2018-11-05  7:30 Hongzhi.Song
  2018-11-05  7:51 ` Xiao Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Hongzhi.Song @ 2018-11-05  7:30 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 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/setrlimit/setrlimit05.c b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
index e716722..57b0b82 100644
--- a/testcases/kernel/syscalls/setrlimit/setrlimit05.c
+++ b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
@@ -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);
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] kernel/syscall/setrlimit05.c: use a legal bad address for mips
  2018-11-05  7:30 [LTP] [PATCH] kernel/syscall/setrlimit05.c: use a legal bad address for mips Hongzhi.Song
@ 2018-11-05  7:51 ` Xiao Yang
  2018-11-06  7:07   ` Hongzhi, Song
  2018-11-05 15:22 ` Cyril Hrubis
  2018-11-06  2:01 ` Xiao Yang
  2 siblings, 1 reply; 8+ messages in thread
From: Xiao Yang @ 2018-11-05  7:51 UTC (permalink / raw)
  To: ltp

On 2018/11/05 15:30, Hongzhi.Song wrote:
> 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 | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/testcases/kernel/syscalls/setrlimit/setrlimit05.c b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
> index e716722..57b0b82 100644
> --- a/testcases/kernel/syscalls/setrlimit/setrlimit05.c
> +++ b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
> @@ -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
>   	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);




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] kernel/syscall/setrlimit05.c: use a legal bad address for mips
  2018-11-05  7:30 [LTP] [PATCH] kernel/syscall/setrlimit05.c: use a legal bad address for mips Hongzhi.Song
  2018-11-05  7:51 ` Xiao Yang
@ 2018-11-05 15:22 ` Cyril Hrubis
  2018-11-06  6:36   ` Hongzhi, Song
  2018-11-06  2:01 ` Xiao Yang
  2 siblings, 1 reply; 8+ messages in thread
From: Cyril Hrubis @ 2018-11-05 15:22 UTC (permalink / raw)
  To: ltp

Hi!
> diff --git a/testcases/kernel/syscalls/setrlimit/setrlimit05.c b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
> index e716722..57b0b82 100644
> --- a/testcases/kernel/syscalls/setrlimit/setrlimit05.c
> +++ b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
> @@ -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.

>  	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.8.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] kernel/syscall/setrlimit05.c: use a legal bad address for mips
  2018-11-05  7:30 [LTP] [PATCH] kernel/syscall/setrlimit05.c: use a legal bad address for mips Hongzhi.Song
  2018-11-05  7:51 ` Xiao Yang
  2018-11-05 15:22 ` Cyril Hrubis
@ 2018-11-06  2:01 ` Xiao Yang
  2018-11-06  6:48   ` Hongzhi, Song
  2 siblings, 1 reply; 8+ messages in thread
From: Xiao Yang @ 2018-11-06  2:01 UTC (permalink / raw)
  To: ltp

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
On 2018/11/05 15:30, Hongzhi.Song wrote:
> 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 | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/testcases/kernel/syscalls/setrlimit/setrlimit05.c b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
> index e716722..57b0b82 100644
> --- a/testcases/kernel/syscalls/setrlimit/setrlimit05.c
> +++ b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
> @@ -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);




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] kernel/syscall/setrlimit05.c: use a legal bad address for mips
  2018-11-05 15:22 ` Cyril Hrubis
@ 2018-11-06  6:36   ` Hongzhi, Song
  2018-11-06 16:05     ` Cyril Hrubis
  0 siblings, 1 reply; 8+ messages in thread
From: Hongzhi, Song @ 2018-11-06  6:36 UTC (permalink / raw)
  To: ltp



On 11/05/2018 11:22 PM, Cyril Hrubis wrote:
> Hi!
>> diff --git a/testcases/kernel/syscalls/setrlimit/setrlimit05.c b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
>> index e716722..57b0b82 100644
>> --- a/testcases/kernel/syscalls/setrlimit/setrlimit05.c
>> +++ b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
>> @@ -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.

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

--Hongzhi

>
>>   	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.8.1
>>
>>
>> -- 
>> Mailing list info: https://lists.linux.it/listinfo/ltp


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] kernel/syscall/setrlimit05.c: use a legal bad address for mips
  2018-11-06  2:01 ` Xiao Yang
@ 2018-11-06  6:48   ` Hongzhi, Song
  0 siblings, 0 replies; 8+ messages in thread
From: Hongzhi, Song @ 2018-11-06  6:48 UTC (permalink / raw)
  To: ltp



On 11/06/2018 10:01 AM, Xiao Yang wrote:
> 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

>
> Best Regards,
> Xiao Yang
> On 2018/11/05 15:30, Hongzhi.Song wrote:
>> 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 | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/testcases/kernel/syscalls/setrlimit/setrlimit05.c 
>> b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
>> index e716722..57b0b82 100644
>> --- a/testcases/kernel/syscalls/setrlimit/setrlimit05.c
>> +++ b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
>> @@ -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);
>
>
>
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] kernel/syscall/setrlimit05.c: use a legal bad address for mips
  2018-11-05  7:51 ` Xiao Yang
@ 2018-11-06  7:07   ` Hongzhi, Song
  0 siblings, 0 replies; 8+ messages in thread
From: Hongzhi, Song @ 2018-11-06  7:07 UTC (permalink / raw)
  To: ltp



On 11/05/2018 03:51 PM, Xiao Yang wrote:
> On 2018/11/05 15:30, Hongzhi.Song wrote:
>> 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 | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/testcases/kernel/syscalls/setrlimit/setrlimit05.c 
>> b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
>> index e716722..57b0b82 100644
>> --- a/testcases/kernel/syscalls/setrlimit/setrlimit05.c
>> +++ b/testcases/kernel/syscalls/setrlimit/setrlimit05.c
>> @@ -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.

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

>
> Best Regards,
> Xiao Yang
>>       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);
>
>
>
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] kernel/syscall/setrlimit05.c: use a legal bad address for mips
  2018-11-06  6:36   ` Hongzhi, Song
@ 2018-11-06 16:05     ` Cyril Hrubis
  0 siblings, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2018-11-06 16:05 UTC (permalink / raw)
  To: ltp

Hi!
> > 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.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-11-06 16:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-05  7:30 [LTP] [PATCH] kernel/syscall/setrlimit05.c: use a legal bad address for mips Hongzhi.Song
2018-11-05  7:51 ` Xiao Yang
2018-11-06  7:07   ` Hongzhi, Song
2018-11-05 15:22 ` Cyril Hrubis
2018-11-06  6:36   ` Hongzhi, Song
2018-11-06 16:05     ` Cyril Hrubis
2018-11-06  2:01 ` Xiao Yang
2018-11-06  6:48   ` Hongzhi, Song

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.