Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3950745pxb; Tue, 2 Mar 2021 02:50:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRw7TdEptohYpe1GNDTrolIxHKWSixX0Yj0qwFSR9yhLe75WkqFvDQ65EjarEv86jSfIiS X-Received: by 2002:a17:906:271b:: with SMTP id z27mr19897490ejc.313.1614682245928; Tue, 02 Mar 2021 02:50:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614682245; cv=none; d=google.com; s=arc-20160816; b=0F9bIMvIOOvw5SGTLUvEg5gzVM5njV7xrec5iwyRpz+ohGjmtHt1zVs77Mlr1o7gq8 hlDTdBbPUTBUigSTUbhzImihqBsgONckJwmMevF8n1XGgNyl3yDzRWJQpflJOMuQFxsE ICPipZSC4pcoqDlt5CXy7MAhA4v/njQWzTBJO3Mj8O/9WKtc59ypzNPHgBv4oxUREpn3 vmSc6wcSEYRh1lhf/5XFOngu9CQbSRtb33i3TrGCnbhp1qcwBmj6uNFvuej5/hZAZuEQ +e7L6Qq2BjV4hFBPtiievTfpGWhMdYph2LY7wfAN8PzgZb3xNQASdEFXKrgPma7RYnjC 9PzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4QHa1Ee71eEq6BJeb0IJgfWjItHGWt1nJaUHkwac06w=; b=z1hNlRkerig7hCSgxbzoQFIXyP5EcKYmWNTYEEJf5GOsoxNyf0e6uCNXyq6icIEaV1 BKAP0YXw9EGCXlT7Xikr4UHAKi8UBeBVYvU/5YkbTfpo+G/Bn7kT603wZjVMXpjyHa9Y YZdhdK6rw8ohcBUug9uMbo1my6d7Npg0PeV+4Dl5ic9jCjyG51Un3NHOIDXATM6qiDIM Z6huXiNcmWAUZoqJDNQv9Cj39eIwlhaeTkolK1ousIYWL9rtTkvGZggVEx4zvdNdPVff TAcdVQkTcnemAo1g5jtXlRsHD0c02F6qHtsqS0yGYZ/tP2D2R1ConG3A9CSpNVon+4hw pCNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HNXzJpR5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n16si5760200edo.395.2021.03.02.02.50.22; Tue, 02 Mar 2021 02:50:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HNXzJpR5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380243AbhCBBtf (ORCPT + 99 others); Mon, 1 Mar 2021 20:49:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:48630 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241536AbhCAT0p (ORCPT ); Mon, 1 Mar 2021 14:26:45 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A63665177; Mon, 1 Mar 2021 17:07:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614618466; bh=ZxYl6ktqcOjs+mbTKfyHdPzK2plTyuCgvD4A8+rngdA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HNXzJpR5dl5m+2MrXfss63YItihzAfa5t8MMZmPOg/zWs/I52xmdDALPzuVDoKZNd IYXyHH7MS+7U7eOOn2H1t/P25uXKaidHbwcol8igaGFGqIwz3o9xQ95EwE/lbbBMvR YL6DGj03ePdIykHj7GBqO+9G7E1WerXzt2j4Tk70= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Misono Tomohiro , Borislav Petkov , Sasha Levin Subject: [PATCH 5.10 067/663] x86/MSR: Filter MSR writes through X86_IOC_WRMSR_REGS ioctl too Date: Mon, 1 Mar 2021 17:05:15 +0100 Message-Id: <20210301161145.048760354@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Misono Tomohiro [ Upstream commit 02a16aa13574c8526beadfc9ae8cc9b66315fa2d ] Commit a7e1f67ed29f ("x86/msr: Filter MSR writes") introduced a module parameter to disable writing to the MSR device file and tainted the kernel upon writing. As MSR registers can be written by the X86_IOC_WRMSR_REGS ioctl too, the same filtering and tainting should be applied to the ioctl as well. [ bp: Massage commit message and space out statements. ] Fixes: a7e1f67ed29f ("x86/msr: Filter MSR writes") Signed-off-by: Misono Tomohiro Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20210127122456.13939-1-misono.tomohiro@jp.fujitsu.com Signed-off-by: Sasha Levin --- arch/x86/kernel/msr.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c index c0d4098106589..79f900ffde4c5 100644 --- a/arch/x86/kernel/msr.c +++ b/arch/x86/kernel/msr.c @@ -184,6 +184,13 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg) err = security_locked_down(LOCKDOWN_MSR); if (err) break; + + err = filter_write(regs[1]); + if (err) + return err; + + add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK); + err = wrmsr_safe_regs_on_cpu(cpu, regs); if (err) break; -- 2.27.0