Commit 61e2658e authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'x86_sgx_for_v5.18_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 SGX updates from Borislav Petkov:

 - A couple of fixes and improvements to the SGX selftests

* tag 'x86_sgx_for_v5.18_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  selftests/sgx: Treat CC as one argument
  selftests/x86: Add validity check and allow field splitting
  selftests/sgx: Remove extra newlines in test output
  selftests/sgx: Ensure enclave data available during debug print
  selftests/sgx: Do not attempt enclave build without valid enclave
  selftests/sgx: Fix NULL-pointer-dereference upon early test failure
parents 88f30ac2 6170abb2
...@@ -4,7 +4,7 @@ include ../lib.mk ...@@ -4,7 +4,7 @@ include ../lib.mk
.PHONY: all clean .PHONY: all clean
CAN_BUILD_X86_64 := $(shell ../x86/check_cc.sh $(CC) \ CAN_BUILD_X86_64 := $(shell ../x86/check_cc.sh "$(CC)" \
../x86/trivial_64bit_program.c) ../x86/trivial_64bit_program.c)
ifndef OBJCOPY ifndef OBJCOPY
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
void encl_delete(struct encl *encl) void encl_delete(struct encl *encl)
{ {
struct encl_segment *heap_seg = &encl->segment_tbl[encl->nr_segments - 1]; struct encl_segment *heap_seg;
if (encl->encl_base) if (encl->encl_base)
munmap((void *)encl->encl_base, encl->encl_size); munmap((void *)encl->encl_base, encl->encl_size);
...@@ -32,10 +32,11 @@ void encl_delete(struct encl *encl) ...@@ -32,10 +32,11 @@ void encl_delete(struct encl *encl)
if (encl->fd) if (encl->fd)
close(encl->fd); close(encl->fd);
munmap(heap_seg->src, heap_seg->size); if (encl->segment_tbl) {
heap_seg = &encl->segment_tbl[encl->nr_segments - 1];
if (encl->segment_tbl) munmap(heap_seg->src, heap_seg->size);
free(encl->segment_tbl); free(encl->segment_tbl);
}
memset(encl, 0, sizeof(*encl)); memset(encl, 0, sizeof(*encl));
} }
......
...@@ -146,7 +146,8 @@ static bool setup_test_encl(unsigned long heap_size, struct encl *encl, ...@@ -146,7 +146,8 @@ static bool setup_test_encl(unsigned long heap_size, struct encl *encl,
if (!encl_load("test_encl.elf", encl, heap_size)) { if (!encl_load("test_encl.elf", encl, heap_size)) {
encl_delete(encl); encl_delete(encl);
TH_LOG("Failed to load the test enclave.\n"); TH_LOG("Failed to load the test enclave.");
return false;
} }
if (!encl_measure(encl)) if (!encl_measure(encl))
...@@ -185,8 +186,6 @@ static bool setup_test_encl(unsigned long heap_size, struct encl *encl, ...@@ -185,8 +186,6 @@ static bool setup_test_encl(unsigned long heap_size, struct encl *encl,
return true; return true;
err: err:
encl_delete(encl);
for (i = 0; i < encl->nr_segments; i++) { for (i = 0; i < encl->nr_segments; i++) {
seg = &encl->segment_tbl[i]; seg = &encl->segment_tbl[i];
...@@ -205,7 +204,9 @@ static bool setup_test_encl(unsigned long heap_size, struct encl *encl, ...@@ -205,7 +204,9 @@ static bool setup_test_encl(unsigned long heap_size, struct encl *encl,
fclose(maps_file); fclose(maps_file);
} }
TH_LOG("Failed to initialize the test enclave.\n"); TH_LOG("Failed to initialize the test enclave.");
encl_delete(encl);
return false; return false;
} }
......
...@@ -7,7 +7,7 @@ CC="$1" ...@@ -7,7 +7,7 @@ CC="$1"
TESTPROG="$2" TESTPROG="$2"
shift 2 shift 2
if "$CC" -o /dev/null "$TESTPROG" -O0 "$@" 2>/dev/null; then if [ -n "$CC" ] && $CC -o /dev/null "$TESTPROG" -O0 "$@" 2>/dev/null; then
echo 1 echo 1
else else
echo 0 echo 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment