[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ca2d792df2e9420090383f1a65a6d99f@AcuMS.aculab.com>
Date: Mon, 1 Apr 2019 14:37:23 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Jann Horn' <jannh@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>
CC: "x86@...nel.org" <x86@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
"Signed-off-by : Qiaowei Ren" <qiaowei.ren@...el.com>
Subject: RE: [PATCH 2/2] x86: fix __user annotations
From: Jann Horn
> Sent: 28 March 2019 21:23
> Fix __user annotations in various places across the x86 tree:
>
...
> - generic_load_microcode() deals with a pointer that can be either a
> kernel pointer or a user pointer; change the code to pass it around as
> a __user pointer, and add explicit casts to convert between __user and
> __kernel
...
> -static int get_ucode_fw(void *to, const void *from, size_t n)
> +static int get_ucode_fw(void *to, const void __user *from, size_t n)
> {
> - memcpy(to, from, n);
> + /* cast paired with request_microcode_fw() */
> + memcpy(to, (const void __force *)from, n);
> return 0;
> }
>
> @@ -993,7 +996,8 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
> return UCODE_NFOUND;
> }
>
> - ret = generic_load_microcode(cpu, (void *)firmware->data,
> + /* cast paired with get_ucode_fw() */
> + ret = generic_load_microcode(cpu, (void __force __user *)firmware->data,
> firmware->size, &get_ucode_fw);
>
> release_firmware(firmware);
> @@ -1001,7 +1005,7 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
> return ret;
> }
>
> -static int get_ucode_user(void *to, const void *from, size_t n)
> +static int get_ucode_user(void *to, const void __user *from, size_t n)
> {
> return copy_from_user(to, from, n);
> }
> @@ -1012,7 +1016,7 @@ request_microcode_user(int cpu, const void __user *buf, size_t size)
> if (is_blacklisted(cpu))
> return UCODE_NFOUND;
>
> - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
> + return generic_load_microcode(cpu, buf, size, &get_ucode_user);
That is all an 'accident waiting to happen' ...
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists