kaiser: fix unlikely error in alloc_ldt_struct()
authorHugh Dickins <hughd@google.com>
Tue, 5 Dec 2017 04:13:35 +0000 (20:13 -0800)
committerYves-Alexis Perez <corsac@debian.org>
Thu, 4 Jan 2018 11:12:40 +0000 (11:12 +0000)
An error from kaiser_add_mapping() here is not at all likely, but
Eric Biggers rightly points out that __free_ldt_struct() relies on
new_ldt->size being initialized: move that up.

Signed-off-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Gbp-Pq: Topic features/all/kpti
Gbp-Pq: Name kaiser-fix-unlikely-error-in-alloc_ldt_struct.patch

arch/x86/kernel/ldt.c

index 8331bad03938f5e8e16e8894f0af89b310bd7440..536e6ab783cf0f613978940d459273c09806f5f4 100644 (file)
@@ -78,11 +78,11 @@ static struct ldt_struct *alloc_ldt_struct(int size)
 
        ret = kaiser_add_mapping((unsigned long)new_ldt->entries, alloc_size,
                                 __PAGE_KERNEL);
+       new_ldt->size = size;
        if (ret) {
                __free_ldt_struct(new_ldt);
                return NULL;
        }
-       new_ldt->size = size;
        return new_ldt;
 }