public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf] selftests/bpf: fix unpriv_disabled check in test_verifier
@ 2023-09-12 12:06 Artem Savkov
  2023-09-12 12:31 ` Eduard Zingerman
  2023-09-12 20:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Artem Savkov @ 2023-09-12 12:06 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, bpf, netdev
  Cc: Eduard Zingerman, linux-kernel, Artem Savkov

Commit 1d56ade032a49 changed the function get_unpriv_disabled() to
return its results as a bool instead of updating a global variable, but
test_verifier was not updated to keep in line with these changes. Thus
unpriv_disabled is always false in test_verifier and unprivileged tests
are not properly skipped on systems with unprivileged bpf disabled.

Fixes: 1d56ade032a49 ("selftests/bpf: Unprivileged tests for test_loader.c")
Signed-off-by: Artem Savkov <asavkov@redhat.com>
---
 tools/testing/selftests/bpf/test_verifier.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 31f1c935cd07d..98107e0452d33 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -1880,7 +1880,7 @@ int main(int argc, char **argv)
 		}
 	}
 
-	get_unpriv_disabled();
+	unpriv_disabled = get_unpriv_disabled();
 	if (unpriv && unpriv_disabled) {
 		printf("Cannot run as unprivileged user with sysctl %s.\n",
 		       UNPRIV_SYSCTL);
-- 
2.41.0


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

* Re: [PATCH bpf] selftests/bpf: fix unpriv_disabled check in test_verifier
  2023-09-12 12:06 [PATCH bpf] selftests/bpf: fix unpriv_disabled check in test_verifier Artem Savkov
@ 2023-09-12 12:31 ` Eduard Zingerman
  2023-09-12 20:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Eduard Zingerman @ 2023-09-12 12:31 UTC (permalink / raw)
  To: Artem Savkov, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, bpf, netdev
  Cc: linux-kernel

On Tue, 2023-09-12 at 14:06 +0200, Artem Savkov wrote:
> Commit 1d56ade032a49 changed the function get_unpriv_disabled() to
> return its results as a bool instead of updating a global variable, but
> test_verifier was not updated to keep in line with these changes. Thus
> unpriv_disabled is always false in test_verifier and unprivileged tests
> are not properly skipped on systems with unprivileged bpf disabled.
> 
> Fixes: 1d56ade032a49 ("selftests/bpf: Unprivileged tests for test_loader.c")
> Signed-off-by: Artem Savkov <asavkov@redhat.com>

Yep, my bad, without this patch test_verifier fails when
/proc/sys/kernel/unprivileged_bpf_disabled is set to 1.
Thank you for fixing it.
Acked-by: Eduard Zingerman <eddyz87@gmail.com>

> ---
>  tools/testing/selftests/bpf/test_verifier.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
> index 31f1c935cd07d..98107e0452d33 100644
> --- a/tools/testing/selftests/bpf/test_verifier.c
> +++ b/tools/testing/selftests/bpf/test_verifier.c
> @@ -1880,7 +1880,7 @@ int main(int argc, char **argv)
>  		}
>  	}
>  
> -	get_unpriv_disabled();
> +	unpriv_disabled = get_unpriv_disabled();
>  	if (unpriv && unpriv_disabled) {
>  		printf("Cannot run as unprivileged user with sysctl %s.\n",
>  		       UNPRIV_SYSCTL);


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

* Re: [PATCH bpf] selftests/bpf: fix unpriv_disabled check in test_verifier
  2023-09-12 12:06 [PATCH bpf] selftests/bpf: fix unpriv_disabled check in test_verifier Artem Savkov
  2023-09-12 12:31 ` Eduard Zingerman
@ 2023-09-12 20:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-09-12 20:20 UTC (permalink / raw)
  To: Artem Savkov; +Cc: ast, daniel, andrii, bpf, netdev, eddyz87, linux-kernel

Hello:

This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Tue, 12 Sep 2023 14:06:31 +0200 you wrote:
> Commit 1d56ade032a49 changed the function get_unpriv_disabled() to
> return its results as a bool instead of updating a global variable, but
> test_verifier was not updated to keep in line with these changes. Thus
> unpriv_disabled is always false in test_verifier and unprivileged tests
> are not properly skipped on systems with unprivileged bpf disabled.
> 
> Fixes: 1d56ade032a49 ("selftests/bpf: Unprivileged tests for test_loader.c")
> Signed-off-by: Artem Savkov <asavkov@redhat.com>
> 
> [...]

Here is the summary with links:
  - [bpf] selftests/bpf: fix unpriv_disabled check in test_verifier
    https://git.kernel.org/bpf/bpf/c/d128860dbb29

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-09-12 20:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-12 12:06 [PATCH bpf] selftests/bpf: fix unpriv_disabled check in test_verifier Artem Savkov
2023-09-12 12:31 ` Eduard Zingerman
2023-09-12 20:20 ` patchwork-bot+netdevbpf

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