Skip to content

Commit bbd9c36

Browse files
committed
Merge tag 'x86_sgx_for_6.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull Intel software guard extension (SGX) updates from Dave Hansen: "A couple of x86/sgx changes. The first one is a no-brainer to use the (simple) SHA-256 library. For the second one, some folks doing testing noticed that SGX systems under memory pressure were inducing fatal machine checks at pretty unnerving rates, despite the SGX code having _some_ awareness of memory poison. It turns out that the SGX reclaim path was not checking for poison _and_ it always accesses memory to copy it around. Make sure that poisoned pages are not reclaimed" * tag 'x86_sgx_for_6.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/sgx: Prevent attempts to reclaim poisoned pages x86/sgx: Use SHA-256 library API instead of crypto_shash API
2 parents b78f129 + ed16618 commit bbd9c36

File tree

4 files changed

+5
-31
lines changed

4 files changed

+5
-31
lines changed

arch/x86/Kconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,8 +1858,7 @@ endchoice
18581858
config X86_SGX
18591859
bool "Software Guard eXtensions (SGX)"
18601860
depends on X86_64 && CPU_SUP_INTEL && X86_X2APIC
1861-
depends on CRYPTO=y
1862-
depends on CRYPTO_SHA256=y
1861+
select CRYPTO_LIB_SHA256
18631862
select MMU_NOTIFIER
18641863
select NUMA_KEEP_MEMINFO if NUMA
18651864
select XARRAY_MULTI

arch/x86/kernel/cpu/sgx/driver.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#ifndef __ARCH_SGX_DRIVER_H__
33
#define __ARCH_SGX_DRIVER_H__
44

5-
#include <crypto/hash.h>
65
#include <linux/kref.h>
76
#include <linux/mmu_notifier.h>
87
#include <linux/radix-tree.h>

arch/x86/kernel/cpu/sgx/ioctl.c

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <asm/mman.h>
55
#include <asm/sgx.h>
6+
#include <crypto/sha2.h>
67
#include <linux/mman.h>
78
#include <linux/delay.h>
89
#include <linux/file.h>
@@ -463,31 +464,6 @@ static long sgx_ioc_enclave_add_pages(struct sgx_encl *encl, void __user *arg)
463464
return ret;
464465
}
465466

466-
static int __sgx_get_key_hash(struct crypto_shash *tfm, const void *modulus,
467-
void *hash)
468-
{
469-
SHASH_DESC_ON_STACK(shash, tfm);
470-
471-
shash->tfm = tfm;
472-
473-
return crypto_shash_digest(shash, modulus, SGX_MODULUS_SIZE, hash);
474-
}
475-
476-
static int sgx_get_key_hash(const void *modulus, void *hash)
477-
{
478-
struct crypto_shash *tfm;
479-
int ret;
480-
481-
tfm = crypto_alloc_shash("sha256", 0, CRYPTO_ALG_ASYNC);
482-
if (IS_ERR(tfm))
483-
return PTR_ERR(tfm);
484-
485-
ret = __sgx_get_key_hash(tfm, modulus, hash);
486-
487-
crypto_free_shash(tfm);
488-
return ret;
489-
}
490-
491467
static int sgx_encl_init(struct sgx_encl *encl, struct sgx_sigstruct *sigstruct,
492468
void *token)
493469
{
@@ -523,9 +499,7 @@ static int sgx_encl_init(struct sgx_encl *encl, struct sgx_sigstruct *sigstruct,
523499
sgx_xfrm_reserved_mask)
524500
return -EINVAL;
525501

526-
ret = sgx_get_key_hash(sigstruct->modulus, mrsigner);
527-
if (ret)
528-
return ret;
502+
sha256(sigstruct->modulus, SGX_MODULUS_SIZE, (u8 *)mrsigner);
529503

530504
mutex_lock(&encl->lock);
531505

arch/x86/kernel/cpu/sgx/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,8 @@ int arch_memory_failure(unsigned long pfn, int flags)
720720
goto out;
721721
}
722722

723+
sgx_unmark_page_reclaimable(page);
724+
723725
/*
724726
* TBD: Add additional plumbing to enable pre-emptive
725727
* action for asynchronous poison notification. Until

0 commit comments

Comments
 (0)