Commit 68d3fa23 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'efi-urgent-for-v5.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull EFI fixes from Borislav Petkov:
 "Forwarded EFI fixes from Ard Biesheuvel:

   - fix memory leak in efivarfs driver

   - fix HYP mode issue in 32-bit ARM version of the EFI stub when built
     in Thumb2 mode

   - avoid leaking EFI pgd pages on allocation failure"

* tag 'efi-urgent-for-v5.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  efi/x86: Free efi_pgd with free_pages()
  efivarfs: fix memory leak in efivarfs_create()
  efi/arm: set HSCTLR Thumb2 bit correctly for HVC calls from HYP
parents 7d53be55 c2fe61d8
...@@ -1472,6 +1472,9 @@ ENTRY(efi_enter_kernel) ...@@ -1472,6 +1472,9 @@ ENTRY(efi_enter_kernel)
@ issued from HYP mode take us to the correct handler code. We @ issued from HYP mode take us to the correct handler code. We
@ will disable the MMU before jumping to the kernel proper. @ will disable the MMU before jumping to the kernel proper.
@ @
ARM( bic r1, r1, #(1 << 30) ) @ clear HSCTLR.TE
THUMB( orr r1, r1, #(1 << 30) ) @ set HSCTLR.TE
mcr p15, 4, r1, c1, c0, 0
adr r0, __hyp_reentry_vectors adr r0, __hyp_reentry_vectors
mcr p15, 4, r0, c12, c0, 0 @ set HYP vector base (HVBAR) mcr p15, 4, r0, c12, c0, 0 @ set HYP vector base (HVBAR)
isb isb
......
...@@ -78,28 +78,30 @@ int __init efi_alloc_page_tables(void) ...@@ -78,28 +78,30 @@ int __init efi_alloc_page_tables(void)
gfp_mask = GFP_KERNEL | __GFP_ZERO; gfp_mask = GFP_KERNEL | __GFP_ZERO;
efi_pgd = (pgd_t *)__get_free_pages(gfp_mask, PGD_ALLOCATION_ORDER); efi_pgd = (pgd_t *)__get_free_pages(gfp_mask, PGD_ALLOCATION_ORDER);
if (!efi_pgd) if (!efi_pgd)
return -ENOMEM; goto fail;
pgd = efi_pgd + pgd_index(EFI_VA_END); pgd = efi_pgd + pgd_index(EFI_VA_END);
p4d = p4d_alloc(&init_mm, pgd, EFI_VA_END); p4d = p4d_alloc(&init_mm, pgd, EFI_VA_END);
if (!p4d) { if (!p4d)
free_page((unsigned long)efi_pgd); goto free_pgd;
return -ENOMEM;
}
pud = pud_alloc(&init_mm, p4d, EFI_VA_END); pud = pud_alloc(&init_mm, p4d, EFI_VA_END);
if (!pud) { if (!pud)
if (pgtable_l5_enabled()) goto free_p4d;
free_page((unsigned long) pgd_page_vaddr(*pgd));
free_pages((unsigned long)efi_pgd, PGD_ALLOCATION_ORDER);
return -ENOMEM;
}
efi_mm.pgd = efi_pgd; efi_mm.pgd = efi_pgd;
mm_init_cpumask(&efi_mm); mm_init_cpumask(&efi_mm);
init_new_context(NULL, &efi_mm); init_new_context(NULL, &efi_mm);
return 0; return 0;
free_p4d:
if (pgtable_l5_enabled())
free_page((unsigned long)pgd_page_vaddr(*pgd));
free_pgd:
free_pages((unsigned long)efi_pgd, PGD_ALLOCATION_ORDER);
fail:
return -ENOMEM;
} }
/* /*
......
...@@ -21,6 +21,7 @@ LIST_HEAD(efivarfs_list); ...@@ -21,6 +21,7 @@ LIST_HEAD(efivarfs_list);
static void efivarfs_evict_inode(struct inode *inode) static void efivarfs_evict_inode(struct inode *inode)
{ {
clear_inode(inode); clear_inode(inode);
kfree(inode->i_private);
} }
static const struct super_operations efivarfs_ops = { static const struct super_operations efivarfs_ops = {
......
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