linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/mm: on-fault-limit: run test without root privileges otherwise skip
@ 2024-02-01  7:13 Muhammad Usama Anjum
  2024-02-01 12:32 ` Muhammad Usama Anjum
  0 siblings, 1 reply; 2+ messages in thread
From: Muhammad Usama Anjum @ 2024-02-01  7:13 UTC (permalink / raw)
  To: Andrew Morton, Shuah Khan, Muhammad Usama Anjum
  Cc: kernel, linux-mm, linux-kselftest, linux-kernel

The mmap() respects rlimit only for normal users. This test should be
run as normal user, without root privileges.

Fixes: b6221771d468 ("selftests/mm: run_vmtests: remove sudo and conform to tap")
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/mm/on-fault-limit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/mm/on-fault-limit.c b/tools/testing/selftests/mm/on-fault-limit.c
index 0ea98ffab3589..431c1277d83a1 100644
--- a/tools/testing/selftests/mm/on-fault-limit.c
+++ b/tools/testing/selftests/mm/on-fault-limit.c
@@ -21,7 +21,7 @@ static void test_limit(void)
 	map = mmap(NULL, 2 * lims.rlim_max, PROT_READ | PROT_WRITE,
 		   MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0);
 
-	ksft_test_result(map == MAP_FAILED, "Failed mmap\n");
+	ksft_test_result(map == MAP_FAILED, "The map failed respecting mlock limits\n");
 
 	if (map != MAP_FAILED)
 		munmap(map, 2 * lims.rlim_max);
@@ -33,8 +33,8 @@ int main(int argc, char **argv)
 	ksft_print_header();
 	ksft_set_plan(1);
 
-	if (getuid())
-		ksft_test_result_skip("Require root privileges to run\n");
+	if (!getuid())
+		ksft_test_result_skip("The test must be run from a normal user\n");
 	else
 		test_limit();
 
-- 
2.42.0



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

* Re: [PATCH] selftests/mm: on-fault-limit: run test without root privileges otherwise skip
  2024-02-01  7:13 [PATCH] selftests/mm: on-fault-limit: run test without root privileges otherwise skip Muhammad Usama Anjum
@ 2024-02-01 12:32 ` Muhammad Usama Anjum
  0 siblings, 0 replies; 2+ messages in thread
From: Muhammad Usama Anjum @ 2024-02-01 12:32 UTC (permalink / raw)
  To: Andrew Morton, Shuah Khan
  Cc: Muhammad Usama Anjum, kernel, linux-mm, linux-kselftest, linux-kernel

Please disregard this patch. I'll send another patch to fix another thing.

On 2/1/24 12:13 PM, Muhammad Usama Anjum wrote:
> The mmap() respects rlimit only for normal users. This test should be
> run as normal user, without root privileges.
> 
> Fixes: b6221771d468 ("selftests/mm: run_vmtests: remove sudo and conform to tap")
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
>  tools/testing/selftests/mm/on-fault-limit.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/on-fault-limit.c b/tools/testing/selftests/mm/on-fault-limit.c
> index 0ea98ffab3589..431c1277d83a1 100644
> --- a/tools/testing/selftests/mm/on-fault-limit.c
> +++ b/tools/testing/selftests/mm/on-fault-limit.c
> @@ -21,7 +21,7 @@ static void test_limit(void)
>  	map = mmap(NULL, 2 * lims.rlim_max, PROT_READ | PROT_WRITE,
>  		   MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0);
>  
> -	ksft_test_result(map == MAP_FAILED, "Failed mmap\n");
> +	ksft_test_result(map == MAP_FAILED, "The map failed respecting mlock limits\n");
>  
>  	if (map != MAP_FAILED)
>  		munmap(map, 2 * lims.rlim_max);
> @@ -33,8 +33,8 @@ int main(int argc, char **argv)
>  	ksft_print_header();
>  	ksft_set_plan(1);
>  
> -	if (getuid())
> -		ksft_test_result_skip("Require root privileges to run\n");
> +	if (!getuid())
> +		ksft_test_result_skip("The test must be run from a normal user\n");
>  	else
>  		test_limit();
>  

-- 
BR,
Muhammad Usama Anjum


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

end of thread, other threads:[~2024-02-01 12:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-01  7:13 [PATCH] selftests/mm: on-fault-limit: run test without root privileges otherwise skip Muhammad Usama Anjum
2024-02-01 12:32 ` Muhammad Usama Anjum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox