Skip to content

Commit c553021

Browse files
committed
Merge tag 'x86_urgent_for_v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Borislav Petkov: "I kinda knew while typing 'I hope this is the last batch of x86/urgent updates' last week, Murphy was reading too and uttered 'Hold my beer!'. So here's more fixes... Thanks Murphy. Anyway, three more x86/urgent fixes for 5.11 final. We should be finally ready (famous last words). :-) - An SGX use after free fix - A fix for the fix to disable CET instrumentation generation for kernel code. We forgot 32-bit, which we seem to do very often nowadays - A Xen PV fix to irqdomain init ordering" * tag 'x86_urgent_for_v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/pci: Create PCI/MSI irqdomain after x86_init.pci.arch_init() x86/build: Disable CET instrumentation in the kernel for 32-bit too x86/sgx: Maintain encl->refcount for each encl->mm_list entry
2 parents 358fece + 70245f8 commit c553021

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

arch/x86/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ export BITS
5050
KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
5151
KBUILD_CFLAGS += $(call cc-option,-mno-avx,)
5252

53+
# Intel CET isn't enabled in the kernel
54+
KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
55+
5356
ifeq ($(CONFIG_X86_32),y)
5457
BITS := 32
5558
UTS_MACHINE := i386
@@ -120,9 +123,6 @@ else
120123

121124
KBUILD_CFLAGS += -mno-red-zone
122125
KBUILD_CFLAGS += -mcmodel=kernel
123-
124-
# Intel CET isn't enabled in the kernel
125-
KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
126126
endif
127127

128128
ifdef CONFIG_X86_X32

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ static int sgx_release(struct inode *inode, struct file *file)
7272
synchronize_srcu(&encl->srcu);
7373
mmu_notifier_unregister(&encl_mm->mmu_notifier, encl_mm->mm);
7474
kfree(encl_mm);
75+
76+
/* 'encl_mm' is gone, put encl_mm->encl reference: */
77+
kref_put(&encl->refcount, sgx_encl_release);
7578
}
7679

7780
kref_put(&encl->refcount, sgx_encl_release);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,9 @@ static void sgx_mmu_notifier_free(struct mmu_notifier *mn)
481481
{
482482
struct sgx_encl_mm *encl_mm = container_of(mn, struct sgx_encl_mm, mmu_notifier);
483483

484+
/* 'encl_mm' is going away, put encl_mm->encl reference: */
485+
kref_put(&encl_mm->encl->refcount, sgx_encl_release);
486+
484487
kfree(encl_mm);
485488
}
486489

@@ -534,6 +537,8 @@ int sgx_encl_mm_add(struct sgx_encl *encl, struct mm_struct *mm)
534537
if (!encl_mm)
535538
return -ENOMEM;
536539

540+
/* Grab a refcount for the encl_mm->encl reference: */
541+
kref_get(&encl->refcount);
537542
encl_mm->encl = encl;
538543
encl_mm->mm = mm;
539544
encl_mm->mmu_notifier.ops = &sgx_mmu_notifier_ops;

arch/x86/pci/init.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,23 @@
99
in the right sequence from here. */
1010
static __init int pci_arch_init(void)
1111
{
12-
int type;
13-
14-
x86_create_pci_msi_domain();
12+
int type, pcbios = 1;
1513

1614
type = pci_direct_probe();
1715

1816
if (!(pci_probe & PCI_PROBE_NOEARLY))
1917
pci_mmcfg_early_init();
2018

21-
if (x86_init.pci.arch_init && !x86_init.pci.arch_init())
19+
if (x86_init.pci.arch_init)
20+
pcbios = x86_init.pci.arch_init();
21+
22+
/*
23+
* Must happen after x86_init.pci.arch_init(). Xen sets up the
24+
* x86_init.irqs.create_pci_msi_domain there.
25+
*/
26+
x86_create_pci_msi_domain();
27+
28+
if (!pcbios)
2229
return 0;
2330

2431
pci_pcbios_init();

0 commit comments

Comments
 (0)