Patch "efi/x86: Free efi_pgd with free_pages()" has been added to the 5.9-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    efi/x86: Free efi_pgd with free_pages()

to the 5.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     efi-x86-free-efi_pgd-with-free_pages.patch
and it can be found in the queue-5.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 3a5eedf54c083302ff55ae54cb4d69ec8288eedb
Author: Arvind Sankar <nivedita@xxxxxxxxxxxx>
Date:   Tue Nov 10 11:39:19 2020 -0500

    efi/x86: Free efi_pgd with free_pages()
    
    [ Upstream commit c2fe61d8be491ff8188edaf22e838f819999146b ]
    
    Commit
    
      d9e9a6418065 ("x86/mm/pti: Allocate a separate user PGD")
    
    changed the PGD allocation to allocate PGD_ALLOCATION_ORDER pages, so in
    the error path it should be freed using free_pages() rather than
    free_page().
    
    Commit
    
        06ace26f4e6f ("x86/efi: Free efi_pgd with free_pages()")
    
    fixed one instance of this, but missed another.
    
    Move the freeing out-of-line to avoid code duplication and fix this bug.
    
    Fixes: d9e9a6418065 ("x86/mm/pti: Allocate a separate user PGD")
    Link: https://lore.kernel.org/r/20201110163919.1134431-1-nivedita@xxxxxxxxxxxx
    Signed-off-by: Arvind Sankar <nivedita@xxxxxxxxxxxx>
    Signed-off-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index 6af4da1149bac..5ce50adb6fd0c 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -77,28 +77,30 @@ int __init efi_alloc_page_tables(void)
 	gfp_mask = GFP_KERNEL | __GFP_ZERO;
 	efi_pgd = (pgd_t *)__get_free_pages(gfp_mask, PGD_ALLOCATION_ORDER);
 	if (!efi_pgd)
-		return -ENOMEM;
+		goto fail;
 
 	pgd = efi_pgd + pgd_index(EFI_VA_END);
 	p4d = p4d_alloc(&init_mm, pgd, EFI_VA_END);
-	if (!p4d) {
-		free_page((unsigned long)efi_pgd);
-		return -ENOMEM;
-	}
+	if (!p4d)
+		goto free_pgd;
 
 	pud = pud_alloc(&init_mm, p4d, EFI_VA_END);
-	if (!pud) {
-		if (pgtable_l5_enabled())
-			free_page((unsigned long) pgd_page_vaddr(*pgd));
-		free_pages((unsigned long)efi_pgd, PGD_ALLOCATION_ORDER);
-		return -ENOMEM;
-	}
+	if (!pud)
+		goto free_p4d;
 
 	efi_mm.pgd = efi_pgd;
 	mm_init_cpumask(&efi_mm);
 	init_new_context(NULL, &efi_mm);
 
 	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;
 }
 
 /*



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux