From patchwork Thu Jan 25 09:41:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juerg Haefliger X-Patchwork-Id: 865802 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3zRxrx2DXKz9sNV; Thu, 25 Jan 2018 20:42:09 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1eee2h-0002uX-DA; Thu, 25 Jan 2018 09:41:59 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1eee2g-0002uR-3J for kernel-team@lists.ubuntu.com; Thu, 25 Jan 2018 09:41:58 +0000 Received: from mail-wm0-f69.google.com ([74.125.82.69]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1eee2f-0005bV-Sk for kernel-team@lists.ubuntu.com; Thu, 25 Jan 2018 09:41:57 +0000 Received: by mail-wm0-f69.google.com with SMTP id 17so12645945wma.1 for ; Thu, 25 Jan 2018 01:41:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=LaJWeGrMGDIYo+dWBr6mD3lJrWLNWRHHE8Hi301ku2E=; b=B2gNgf7ZPIMlINt8XaCVGcSJvigp7RHsEaENhCl34T70EvTwH24EiFxke+vbmaP+LQ HrTU4RGtLOREe8B2N7DhPmbb70DTbd7y5CXX7xw4m3mdILjVKSxlcPuKTA0Z6CEYQPzc njM7G14qY41iezLo+UXYAvNZPLh/6xPmXvS+lPOcrVgYiypYznNQFNdqv+XXvXA3djIt CEquhY0umZKRD8WR5GtkfgcVN1Y62AiEKqFr1oO9fd9IYJ7WmkOJJF8se37w97WUs1Ze iaLyZ985UJAs+8b1ExFkxsPE/xyB+T/RutbrqKg+XL2gU25sfYfiGgbOmgRS2bw/qzZa Au/g== X-Gm-Message-State: AKwxytefwhWRdor4POMvnoDMuNQZvmM4ycJmbTJPgcyGF09lenGzG9Lk SUn28jGqOSQtNBjT24hq3jTXbUxLBwmslnUqFTpGxIdY2Ikj+GOP6B0IoCVuB0gissnZctcEGc1 F/7mE9OCiqT9wi4PbEm6W96stCHUWbtFK8QOeW526XA== X-Received: by 10.80.182.203 with SMTP id f11mr28264045ede.157.1516873317424; Thu, 25 Jan 2018 01:41:57 -0800 (PST) X-Google-Smtp-Source: AH8x226QRzDt99eb0dSxpEKrOaar3SAuPcYieIaYdVPJjkFJhuGz+qMYxSrV5EijAgg8wg8ged4f5g== X-Received: by 10.80.182.203 with SMTP id f11mr28264031ede.157.1516873317212; Thu, 25 Jan 2018 01:41:57 -0800 (PST) Received: from gollum.fritz.box ([81.221.205.149]) by smtp.gmail.com with ESMTPSA id h1sm1024032edc.57.2018.01.25.01.41.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jan 2018 01:41:56 -0800 (PST) From: Juerg Haefliger To: kernel-team@lists.ubuntu.com Subject: [SRU][Trusty][PATCH] x86/asm/msr: Make wrmsrl_safe() a function Date: Thu, 25 Jan 2018 10:41:55 +0100 Message-Id: <20180125094155.31241-1-juerg.haefliger@canonical.com> X-Mailer: git-send-email 2.14.1 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Andy Lutomirski 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 Cc: Cc: Andrew Morton Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner [ Applied small improvements. ] Signed-off-by: Ingo Molnar (cherry picked from commit cf991de2f614f454b3cb2a300c06ecdf69f3a70d) Signed-off-by: Juerg Haefliger Acked-by: Colin Ian King Acked-by: Khalid Elmously --- 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))