]> Git Repo - linux.git/commitdiff
x86/mm/ident_map: Check for errors from ident_pud_init()
authorArvind Sankar <[email protected]>
Tue, 27 Oct 2020 23:06:48 +0000 (19:06 -0400)
committerBorislav Petkov <[email protected]>
Wed, 28 Oct 2020 13:48:30 +0000 (14:48 +0100)
Commit

  ea3b5e60ce80 ("x86/mm/ident_map: Add 5-level paging support")

added ident_p4d_init() to support 5-level paging, but this function
doesn't check and return errors from ident_pud_init().

For example, the decompressor stub uses this code to create an identity
mapping. If it runs out of pages while trying to allocate a PMD
pagetable, the error will be currently ignored.

Fix this to propagate errors.

 [ bp: Space out statements for better readability. ]

Fixes: ea3b5e60ce80 ("x86/mm/ident_map: Add 5-level paging support")
Signed-off-by: Arvind Sankar <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Reviewed-by: Joerg Roedel <[email protected]>
Acked-by: Kirill A. Shutemov <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
arch/x86/mm/ident_map.c

index fe7a12599d8eb8a73a58324a143b781a69213260..968d7005f4a72454ccf8678967f040fe06f36ad6 100644 (file)
@@ -62,6 +62,7 @@ static int ident_p4d_init(struct x86_mapping_info *info, p4d_t *p4d_page,
                          unsigned long addr, unsigned long end)
 {
        unsigned long next;
+       int result;
 
        for (; addr < end; addr = next) {
                p4d_t *p4d = p4d_page + p4d_index(addr);
@@ -73,13 +74,20 @@ static int ident_p4d_init(struct x86_mapping_info *info, p4d_t *p4d_page,
 
                if (p4d_present(*p4d)) {
                        pud = pud_offset(p4d, 0);
-                       ident_pud_init(info, pud, addr, next);
+                       result = ident_pud_init(info, pud, addr, next);
+                       if (result)
+                               return result;
+
                        continue;
                }
                pud = (pud_t *)info->alloc_pgt_page(info->context);
                if (!pud)
                        return -ENOMEM;
-               ident_pud_init(info, pud, addr, next);
+
+               result = ident_pud_init(info, pud, addr, next);
+               if (result)
+                       return result;
+
                set_p4d(p4d, __p4d(__pa(pud) | info->kernpg_flag));
        }
 
This page took 0.051576 seconds and 4 git commands to generate.