* [PATCH] x86/microcode/AMD: fix read of uninitialized data
@ 2018-04-10 13:41 Colin King
2018-04-10 14:22 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2018-04-10 13:41 UTC (permalink / raw)
To: Borislav Petkov, Thomas Gleixner, Ingo Molnar, H . Peter Anvin, x86
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently function __load_ucode_amd can assign an uninitialized cp to *ret
if get_builtin_microcode returns false. This could cause function
load_ucode_amd_bsp to attempt to apply the microcode if the garbage data in
cp is non-zero. Fix this by moving the zero'ing of cp from function
load_ucode_amd_bsp to __load_ucode_amd.
Detected by CoverityScan, CID#1398332 ("Uninitialized scalar variable")
Fixes: 69f5f983001f ("x86/microcode/AMD: Remove AP scanning optimization")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
arch/x86/kernel/cpu/microcode/amd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 0624957aa068..745135699233 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -254,7 +254,7 @@ static bool get_builtin_microcode(struct cpio_data *cp, unsigned int family)
static void __load_ucode_amd(unsigned int cpuid_1_eax, struct cpio_data *ret)
{
struct ucode_cpu_info *uci;
- struct cpio_data cp;
+ struct cpio_data cp = { };
const char *path;
bool use_pa;
@@ -279,7 +279,7 @@ static void __load_ucode_amd(unsigned int cpuid_1_eax, struct cpio_data *ret)
void __init load_ucode_amd_bsp(unsigned int cpuid_1_eax)
{
- struct cpio_data cp = { };
+ struct cpio_data cp;
__load_ucode_amd(cpuid_1_eax, &cp);
if (!(cp.data && cp.size))
--
2.15.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] x86/microcode/AMD: fix read of uninitialized data
2018-04-10 13:41 [PATCH] x86/microcode/AMD: fix read of uninitialized data Colin King
@ 2018-04-10 14:22 ` Dan Carpenter
2018-04-10 15:35 ` Colin Ian King
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2018-04-10 14:22 UTC (permalink / raw)
To: Colin King
Cc: Borislav Petkov, Thomas Gleixner, Ingo Molnar, H . Peter Anvin,
x86, kernel-janitors, linux-kernel
On Tue, Apr 10, 2018 at 02:41:23PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently function __load_ucode_amd can assign an uninitialized cp to *ret
> if get_builtin_microcode returns false.
What are you looking at? Here is how it looks in linux-next:
270
271 if (!get_builtin_microcode(&cp, x86_family(cpuid_1_eax)))
272 cp = find_microcode_in_initrd(path, use_pa);
273
If get_builtin_microcode() returns false, then cp is initialized on the
next line.
Maybe the issue is that cp.name is uninitialized. It doesn't cause an
issue but it would be understandable for a static checker to warn about
it when we do "*ret = cp;".
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/microcode/AMD: fix read of uninitialized data
2018-04-10 14:22 ` Dan Carpenter
@ 2018-04-10 15:35 ` Colin Ian King
0 siblings, 0 replies; 3+ messages in thread
From: Colin Ian King @ 2018-04-10 15:35 UTC (permalink / raw)
To: Dan Carpenter
Cc: Borislav Petkov, Thomas Gleixner, Ingo Molnar, H . Peter Anvin,
x86, kernel-janitors, linux-kernel
On 10/04/18 15:22, Dan Carpenter wrote:
> On Tue, Apr 10, 2018 at 02:41:23PM +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Currently function __load_ucode_amd can assign an uninitialized cp to *ret
>> if get_builtin_microcode returns false.
>
> What are you looking at? Here is how it looks in linux-next:
>
> 270
> 271 if (!get_builtin_microcode(&cp, x86_family(cpuid_1_eax)))
> 272 cp = find_microcode_in_initrd(path, use_pa);
> 273
>
>
> If get_builtin_microcode() returns false, then cp is initialized on the
> next line.
>
> Maybe the issue is that cp.name is uninitialized. It doesn't cause an
> issue but it would be understandable for a static checker to warn about
> it when we do "*ret = cp;".
Oh, oops, you are totally correct on that. My bad.
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-10 15:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-10 13:41 [PATCH] x86/microcode/AMD: fix read of uninitialized data Colin King
2018-04-10 14:22 ` Dan Carpenter
2018-04-10 15:35 ` Colin Ian King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®