lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202003131607.BA18A88D2F@keescook>
Date:   Fri, 13 Mar 2020 16:07:05 -0700
From:   Kees Cook <keescook@...omium.org>
To:     Christian Brauner <christian.brauner@...ntu.com>
Cc:     gregkh@...uxfoundation.org, tkjos@...roid.com,
        linux-kernel@...r.kernel.org, ard.biesheuvel@...aro.org,
        ardb@...nel.org, arve@...roid.com, hridya@...gle.com,
        joel@...lfernandes.org, john.stultz@...aro.org,
        kernel-team@...roid.com, linux-kselftest@...r.kernel.org,
        maco@...roid.com, naresh.kamboju@...aro.org, shuah@...nel.org
Subject: Re: [PATCH v2 1/3] binderfs: port tests to test harness
 infrastructure

On Fri, Mar 13, 2020 at 04:24:18PM +0100, Christian Brauner wrote:
> Makes for nicer output and prepares for additional tests.
> 
> Cc: Kees Cook <keescook@...omium.org>:
> Signed-off-by: Christian Brauner <christian.brauner@...ntu.com>

Reviewed-by: Kees Cook <keescook@...omium.org>

-Kees

> ---
> /* v2 */
> - Kees Cook <keescook@...omium.org>:
>   - Switch to XFAIL() to skip tests.
> ---
>  .../selftests/filesystems/binderfs/Makefile   |  2 ++
>  .../filesystems/binderfs/binderfs_test.c      | 31 +++++++++----------
>  2 files changed, 17 insertions(+), 16 deletions(-)
> 
> diff --git a/tools/testing/selftests/filesystems/binderfs/Makefile b/tools/testing/selftests/filesystems/binderfs/Makefile
> index 58cb659b56b4..75315d9ba7a9 100644
> --- a/tools/testing/selftests/filesystems/binderfs/Makefile
> +++ b/tools/testing/selftests/filesystems/binderfs/Makefile
> @@ -3,4 +3,6 @@
>  CFLAGS += -I../../../../../usr/include/
>  TEST_GEN_PROGS := binderfs_test
>  
> +binderfs_test: binderfs_test.c ../../kselftest.h ../../kselftest_harness.h
> +
>  include ../../lib.mk
> diff --git a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
> index 8c2ed962e1c7..0cfca65e095a 100644
> --- a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
> +++ b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
> @@ -15,7 +15,9 @@
>  #include <unistd.h>
>  #include <linux/android/binder.h>
>  #include <linux/android/binderfs.h>
> +
>  #include "../../kselftest.h"
> +#include "../../kselftest_harness.h"
>  
>  static ssize_t write_nointr(int fd, const void *buf, size_t count)
>  {
> @@ -132,7 +134,7 @@ static void rmdir_protect_errno(const char *dir)
>  	errno = saved_errno;
>  }
>  
> -static void __do_binderfs_test(void)
> +static int __do_binderfs_test(void)
>  {
>  	int fd, ret, saved_errno;
>  	size_t len;
> @@ -160,8 +162,7 @@ static void __do_binderfs_test(void)
>  					   strerror(errno));
>  
>  		keep ? : rmdir_protect_errno("/dev/binderfs");
> -		ksft_exit_skip(
> -			"The Android binderfs filesystem is not available\n");
> +		return 1;
>  	}
>  
>  	/* binderfs mount test passed */
> @@ -250,26 +251,24 @@ static void __do_binderfs_test(void)
>  
>  	/* binderfs unmount test passed */
>  	ksft_inc_pass_cnt();
> +	return 0;
>  }
>  
> -static void binderfs_test_privileged()
> +TEST(binderfs_test_privileged)
>  {
>  	if (geteuid() != 0)
> -		ksft_print_msg(
> -			"Tests are not run as root. Skipping privileged tests\n");
> -	else
> -		__do_binderfs_test();
> +		XFAIL(return, "Tests are not run as root. Skipping privileged tests");
> +
> +	if (__do_binderfs_test() == 1)
> +		XFAIL(return, "The Android binderfs filesystem is not available");
>  }
>  
> -static void binderfs_test_unprivileged()
> +TEST(binderfs_test_unprivileged)
>  {
>  	change_to_userns();
> -	__do_binderfs_test();
> -}
>  
> -int main(int argc, char *argv[])
> -{
> -	binderfs_test_privileged();
> -	binderfs_test_unprivileged();
> -	ksft_exit_pass();
> +	if (__do_binderfs_test() == 1)
> +		XFAIL(return, "The Android binderfs filesystem is not available");
>  }
> +
> +TEST_HARNESS_MAIN
> 
> base-commit: 2c523b344dfa65a3738e7039832044aa133c75fb
> -- 
> 2.25.1
> 

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ