selftests/bpf: fix unpriv_disabled check in test_verifier
authorArtem Savkov <asavkov@redhat.com>
Tue, 12 Sep 2023 12:06:31 +0000 (14:06 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 12 Sep 2023 20:17:56 +0000 (13:17 -0700)
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>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20230912120631.213139-1-asavkov@redhat.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/test_verifier.c

index 31f1c93..98107e0 100644 (file)
@@ -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);