Patch "x86/cpuid: Prevent out of bound access in do_clear_cpu_cap()" has been added to the 4.14-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
x86/cpuid: Prevent out of bound access in do_clear_cpu_cap()
to the 4.14-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:
x86-cpuid-prevent-out-of-bound-access-in-do_clear_cpu_cap.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
57b8b1a1856adaa849d02d547411a553a531022bMon Sep 17 00:00:00 2001
From: Thomas Gleixner <[email protected]>
Date: Wed, 18 Oct 2017 19:39:35 +0200
Subject: x86/cpuid: Prevent out of bound access in do_clear_cpu_cap()
From: Thomas Gleixner <[email protected]>
commit 57b8b1a1856adaa849d02d547411a553a531022b upstream.
do_clear_cpu_cap() allocates a bitmap to keep track of disabled feature dependencies. That bitmap is sized NCAPINTS * BITS_PER_INIT. The possible 'features' which can be handed in are larger than this, because after the capabilities the bug 'feature' bits occupy another 32bit. Not really obvious...
So clearing any of the misfeature bits, as 32bit does for the F00F bug, accesses that bitmap out of bounds thereby corrupting the stack.
Size the bitmap proper and add a sanity check to catch accidental out of bound access.
--- arch/x86/kernel/cpu/cpuid-deps.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/cpuid-deps.c +8 -2
@@ -75,11 +75,17 @@ static inline void clear_feature(struct__clear_cpu_cap (c, feature); } +/* Take the capabilities and the BUG bits into account */ +#define MAX_FEATURE_BITS ((NCAPINTS + NBUGINTS) * sizeof(u32) * 8) +static void do_clear_cpu_cap (struct cpuinfo_x86 *c,unsigned int feature) { -bool changed; -DECLARE_BITMAP (disable,NCAPINTS *sizeof (u32) *8 ); +DECLARE_BITMAP (disable,MAX_FEATURE_BITS );const struct cpuid_dep *d; +bool changed; + +if (WARN_ON (feature >=MAX_FEATURE_BITS )) +return ;clear_feature (c, feature);
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/x86-asm-remove-unnecessary-n-t-in-front-of-cc_set-from-asm-templates.patch queue-4.14/x86-cpuid-add-generic-table-for-cpuid-dependencies.patch queue-4.14/objtool-don-t-report-end-of-section-error-after-an-empty-unwind-hint.patch queue-4.14/x86-cpufeatures-enable-new-sse-avx-avx512-cpu-features.patch queue-4.14/x86-cpuid-prevent-out-of-bound-access-in-do_clear_cpu_cap.patch queue-4.14/x86-cpufeatures-re-tabulate-the-x86_feature-definitions.patch queue-4.14/x86-cpuid-replace-set-clear_bit32.patch