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]
Date:   Wed, 23 Jun 2021 16:41:50 +0300
From:   Jarkko Sakkinen <jarkko@...nel.org>
To:     Dave Hansen <dave.hansen@...ux.intel.com>
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        tim.gardner@...onical.com, reinette.chatre@...el.com,
        shuah@...nel.org, linux-sgx@...r.kernel.org,
        linux-kselftest@...r.kernel.org
Subject: Re: [PATCH] selftests/sgx: remove checks for file execute permissions

On Mon, Jun 21, 2021 at 12:05:56PM -0700, Dave Hansen wrote:
> 
> The SGX selftests can fail for a bunch of non-obvious reasons
> like 'noexec' permissions on /dev (which is the default *EVERYWHERE*
> it seems).
> 
> A new test mistakenly also looked for +x permission on the
> /dev/sgx_enclave.  File execute permissions really only apply to
> the ability of execve() to work on a file, *NOT* on the ability
> for an application to map the file with PROT_EXEC.  SGX needs to
> mmap(PROT_EXEC), but doesn't need to execve() the device file.
> 
> Remove the check.
> 
> Fixes: 4284f7acb78b ("selftests/sgx: Improve error detection and messages")
> Reported-by: Tim Gardner <tim.gardner@...onical.com>
> Cc: Jarkko Sakkinen <jarkko@...nel.org>
> Cc: Reinette Chatre <reinette.chatre@...el.com>
> Cc: Dave Hansen <dave.hansen@...ux.intel.com>
> Cc: Shuah Khan <shuah@...nel.org>
> Cc: linux-sgx@...r.kernel.org
> Cc: linux-kselftest@...r.kernel.org
> Cc: linux-kernel@...r.kernel.org
> 
> ---
> 
>  b/tools/testing/selftests/sgx/load.c |   16 +++-------------
>  1 file changed, 3 insertions(+), 13 deletions(-)
> 
> diff -puN tools/testing/selftests/sgx/load.c~sgx-no-file-exec tools/testing/selftests/sgx/load.c
> --- a/tools/testing/selftests/sgx/load.c~sgx-no-file-exec	2021-06-21 11:48:25.226294281 -0700
> +++ b/tools/testing/selftests/sgx/load.c	2021-06-21 12:03:28.023292029 -0700
> @@ -150,16 +150,6 @@ bool encl_load(const char *path, struct
>  		goto err;
>  	}
>  
> -	/*
> -	 * This just checks if the /dev file has these permission
> -	 * bits set.  It does not check that the current user is
> -	 * the owner or in the owning group.
> -	 */
> -	if (!(sb.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) {
> -		fprintf(stderr, "no execute permissions on device file %s\n", device_path);
> -		goto err;
> -	}
> -
>  	ptr = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, fd, 0);
>  	if (ptr == (void *)-1) {
>  		perror("mmap for read");
> @@ -169,13 +159,13 @@ bool encl_load(const char *path, struct
>  
>  #define ERR_MSG \
>  "mmap() succeeded for PROT_READ, but failed for PROT_EXEC.\n" \
> -" Check that current user has execute permissions on %s and \n" \
> -" that /dev does not have noexec set: mount | grep \"/dev .*noexec\"\n" \
> +" Check that /dev does not have noexec set:\n" \
> +" \tmount | grep \"/dev .*noexec\"\n" \
>  " If so, remount it executable: mount -o remount,exec /dev\n\n"
>  
>  	ptr = mmap(NULL, PAGE_SIZE, PROT_EXEC, MAP_SHARED, fd, 0);
>  	if (ptr == (void *)-1) {
> -		fprintf(stderr, ERR_MSG, device_path);
> +		fprintf(stderr, ERR_MSG);
>  		goto err;
>  	}
>  	munmap(ptr, PAGE_SIZE);
> _
> 



Reviewed-by: Jarkko Sakkinen <jarkko@...nel.org>

/Jarkko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ