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: <alpine.LRH.2.21.1904251530010.26472@namei.org>
Date:   Thu, 25 Apr 2019 15:30:07 +1000 (AEST)
From:   James Morris <jmorris@...ei.org>
To:     Kees Cook <keescook@...omium.org>
cc:     Tycho Andersen <tycho@...ho.ws>, stable@...r.kernel.org,
        Andy Lutomirski <luto@...capital.net>,
        Will Drewry <wad@...omium.org>,
        linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] selftests/seccomp: Prepare for exclusive seccomp
 flags

On Wed, 24 Apr 2019, Kees Cook wrote:

> Some seccomp flags will become exclusive, so the selftest needs to
> be adjusted to mask those out and test them individually for the "all
> flags" tests.
> 
> Cc: stable@...r.kernel.org # v5.0+
> Signed-off-by: Kees Cook <keescook@...omium.org>


Acked-by: James Morris <jamorris@...ux.microsoft.com>

> ---
>  tools/testing/selftests/seccomp/seccomp_bpf.c | 34 ++++++++++++++-----
>  1 file changed, 25 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
> index f69d2ee29742..5019cdae5d0b 100644
> --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
> +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
> @@ -2166,11 +2166,14 @@ TEST(detect_seccomp_filter_flags)
>  				 SECCOMP_FILTER_FLAG_LOG,
>  				 SECCOMP_FILTER_FLAG_SPEC_ALLOW,
>  				 SECCOMP_FILTER_FLAG_NEW_LISTENER };
> -	unsigned int flag, all_flags;
> +	unsigned int exclusive[] = {
> +				SECCOMP_FILTER_FLAG_TSYNC,
> +				SECCOMP_FILTER_FLAG_NEW_LISTENER };
> +	unsigned int flag, all_flags, exclusive_mask;
>  	int i;
>  	long ret;
>  
> -	/* Test detection of known-good filter flags */
> +	/* Test detection of individual known-good filter flags */
>  	for (i = 0, all_flags = 0; i < ARRAY_SIZE(flags); i++) {
>  		int bits = 0;
>  
> @@ -2197,16 +2200,29 @@ TEST(detect_seccomp_filter_flags)
>  		all_flags |= flag;
>  	}
>  
> -	/* Test detection of all known-good filter flags */
> -	ret = seccomp(SECCOMP_SET_MODE_FILTER, all_flags, NULL);
> -	EXPECT_EQ(-1, ret);
> -	EXPECT_EQ(EFAULT, errno) {
> -		TH_LOG("Failed to detect that all known-good filter flags (0x%X) are supported!",
> -		       all_flags);
> +	/*
> +	 * Test detection of all known-good filter flags combined. But
> +	 * for the exclusive flags we need to mask them out and try them
> +	 * individually for the "all flags" testing.
> +	 */
> +	exclusive_mask = 0;
> +	for (i = 0; i < ARRAY_SIZE(exclusive); i++)
> +		exclusive_mask |= exclusive[i];
> +	for (i = 0; i < ARRAY_SIZE(exclusive); i++) {
> +		flag = all_flags & ~exclusive_mask;
> +		flag |= exclusive[i];
> +
> +		ret = seccomp(SECCOMP_SET_MODE_FILTER, flag, NULL);
> +		EXPECT_EQ(-1, ret);
> +		EXPECT_EQ(EFAULT, errno) {
> +			TH_LOG("Failed to detect that all known-good filter flags (0x%X) are supported!",
> +			       flag);
> +		}
>  	}
>  
> -	/* Test detection of an unknown filter flag */
> +	/* Test detection of an unknown filter flags, without exclusives. */
>  	flag = -1;
> +	flag &= ~exclusive_mask;
>  	ret = seccomp(SECCOMP_SET_MODE_FILTER, flag, NULL);
>  	EXPECT_EQ(-1, ret);
>  	EXPECT_EQ(EINVAL, errno) {
> 

-- 
James Morris
<jmorris@...ei.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ