]> git.itanic.dy.fi Git - linux-stable/commitdiff
kaiser: alloc_ldt_struct() use get_zeroed_page()
authorHugh Dickins <hughd@google.com>
Mon, 18 Dec 2017 03:53:01 +0000 (19:53 -0800)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 7 Jan 2018 01:46:50 +0000 (01:46 +0000)
Change the 3.2.96 and 3.18.72 alloc_ldt_struct() to allocate its entries
with get_zeroed_page(), as 4.3 onwards does since f454b4788613 ("x86/ldt:
Fix small LDT allocation for Xen").  This then matches the free_page()
I had misported in __free_ldt_struct(), and fixes the
"BUG: Bad page state in process ldt_gdt_32 ... flags: 0x80(slab)"
reported by Kees Cook and Jiri Kosina, and analysed by Jiri.

Signed-off-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
arch/x86/kernel/ldt.c

index 836a4c2d5cebc20f3bc0424b8804431277834dbe..8d4e15f59b5f6d7b61ba929af4e2d8d63d4e8ca5 100644 (file)
@@ -70,7 +70,7 @@ static struct ldt_struct *alloc_ldt_struct(int size)
        if (alloc_size > PAGE_SIZE)
                new_ldt->entries = vzalloc(alloc_size);
        else
-               new_ldt->entries = kzalloc(PAGE_SIZE, GFP_KERNEL);
+               new_ldt->entries = (void *)get_zeroed_page(GFP_KERNEL);
 
        if (!new_ldt->entries) {
                kfree(new_ldt);