Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/sgx: remove checks for file execute permissions

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@canonical.com>
Cc: Jarkko Sakkinen <jarkko@kernel.org>
Cc: Reinette Chatre <reinette.chatre@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: linux-sgx@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Tested-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Dave Hansen and committed by
Shuah Khan
4896df9d 07b60713

+3 -13
+3 -13
tools/testing/selftests/sgx/load.c
··· 150 150 goto err; 151 151 } 152 152 153 - /* 154 - * This just checks if the /dev file has these permission 155 - * bits set. It does not check that the current user is 156 - * the owner or in the owning group. 157 - */ 158 - if (!(sb.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) { 159 - fprintf(stderr, "no execute permissions on device file %s\n", device_path); 160 - goto err; 161 - } 162 - 163 153 ptr = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, fd, 0); 164 154 if (ptr == (void *)-1) { 165 155 perror("mmap for read"); ··· 159 169 160 170 #define ERR_MSG \ 161 171 "mmap() succeeded for PROT_READ, but failed for PROT_EXEC.\n" \ 162 - " Check that current user has execute permissions on %s and \n" \ 163 - " that /dev does not have noexec set: mount | grep \"/dev .*noexec\"\n" \ 172 + " Check that /dev does not have noexec set:\n" \ 173 + " \tmount | grep \"/dev .*noexec\"\n" \ 164 174 " If so, remount it executable: mount -o remount,exec /dev\n\n" 165 175 166 176 ptr = mmap(NULL, PAGE_SIZE, PROT_EXEC, MAP_SHARED, fd, 0); 167 177 if (ptr == (void *)-1) { 168 - fprintf(stderr, ERR_MSG, device_path); 178 + fprintf(stderr, ERR_MSG); 169 179 goto err; 170 180 } 171 181 munmap(ptr, PAGE_SIZE);