From: Hugh Dickins Date: Tue, 5 Dec 2017 04:13:35 +0000 (-0800) Subject: kaiser: fix unlikely error in alloc_ldt_struct() X-Git-Tag: v4.1.12-124.31.3~1323 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=cc8fb8855add6a5c536b312c9e6ce70b68d69969;p=users%2Fjedix%2Flinux-maple.git kaiser: fix unlikely error in alloc_ldt_struct() 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 Acked-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 500943e57db8d3e298e98f595f835c5b613e843b) Orabug: 27333760 CVE: CVE-2017-5754 Signed-off-by: Pavel Tatashin Signed-off-by: Kirtikar Kashyap --- diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c index c388247e0353..5797d437710d 100644 --- a/arch/x86/kernel/ldt.c +++ b/arch/x86/kernel/ldt.c @@ -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; }