ACK: [SRU][Trusty][PATCH] x86/asm/msr: Make wrmsrl_safe() a function
Khaled Elmously
khalid.elmously at canonical.com
Wed Jan 31 07:28:43 UTC 2018
On 2018-01-25 10:41:55 , Juerg Haefliger wrote:
> From: Andy Lutomirski <luto at kernel.org>
>
> CVE-2017-5753
> CVE-2017-5715
>
> The wrmsrl_safe macro performs invalid shifts if the value
> argument is 32 bits. This makes it unnecessarily awkward to
> write code that puts an unsigned long into an MSR.
>
> Convert it to a real inline function.
>
> For inspiration, see:
>
> 7c74d5b7b7b6 ("x86/asm/entry/64: Fix MSR_IA32_SYSENTER_CS MSR value").
>
> Signed-off-by: Andy Lutomirski <luto at kernel.org>
> Cc: <linux-kernel at vger.kernel.org>
> Cc: Andrew Morton <akpm at linux-foundation.org>
> Cc: H. Peter Anvin <hpa at zytor.com>
> Cc: Linus Torvalds <torvalds at linux-foundation.org>
> Cc: Peter Zijlstra <peterz at infradead.org>
> Cc: Thomas Gleixner <tglx at linutronix.de>
> [ Applied small improvements. ]
> Signed-off-by: Ingo Molnar <mingo at kernel.org>
> (cherry picked from commit cf991de2f614f454b3cb2a300c06ecdf69f3a70d)
> Signed-off-by: Juerg Haefliger <juerg.haefliger at canonical.com>
> ---
> arch/x86/include/asm/msr.h | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
> index de36f22eb0b9..13bf576c401d 100644
> --- a/arch/x86/include/asm/msr.h
> +++ b/arch/x86/include/asm/msr.h
> @@ -205,8 +205,13 @@ do { \
>
> #endif /* !CONFIG_PARAVIRT */
>
> -#define wrmsrl_safe(msr, val) wrmsr_safe((msr), (u32)(val), \
> - (u32)((val) >> 32))
> +/*
> + * 64-bit version of wrmsr_safe():
> + */
> +static inline int wrmsrl_safe(u32 msr, u64 val)
> +{
> + return wrmsr_safe(msr, (u32)val, (u32)(val >> 32));
> +}
>
> #define write_tsc(low, high) wrmsr(MSR_IA32_TSC, (low), (high))
>
Please disregard my earlier "probably NACK".
Acked-by: Khalid Elmously <khalid.elmously at canonical.com>
More information about the kernel-team
mailing list