]> git.baikalelectronics.ru Git - kernel.git/commit
x86/microcode/AMD: Track patch allocation size explicitly
authorKees Cook <keescook@chromium.org>
Thu, 22 Sep 2022 03:10:10 +0000 (20:10 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 11:22:24 +0000 (13:22 +0200)
commit45cec4e9570086e3eaaa13908922dd8b1d0bf059
treed0b7986bd2a433bf66cc7fbc398009df98687244
parent8982d48bfe2ce0d9fd2857b55dfe01018e23dcd8
x86/microcode/AMD: Track patch allocation size explicitly

[ Upstream commit a0ea8b804aa69e8e5a6aa3e26c646aaa51727b45 ]

In preparation for reducing the use of ksize(), record the actual
allocation size for later memcpy(). This avoids copying extra
(uninitialized!) bytes into the patch buffer when the requested
allocation size isn't exactly the size of a kmalloc bucket.
Additionally, fix potential future issues where runtime bounds checking
will notice that the buffer was allocated to a smaller value than
returned by ksize().

Fixes: 4487451a80f5 ("x86, microcode, amd: Early microcode patch loading support for AMD")
Suggested-by: Daniel Micay <danielmicay@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/lkml/CA+DvKQ+bp7Y7gmaVhacjv9uF6Ar-o4tet872h4Q8RPYPJjcJQA@mail.gmail.com/
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/include/asm/microcode.h
arch/x86/kernel/cpu/microcode/amd.c