Message ID | 20190326182742.16950-13-matthewgarrett@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-security-module-owner@kernel.org> Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0746413B5 for <patchwork-linux-security-module@patchwork.kernel.org>; Tue, 26 Mar 2019 18:28:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4C2728DD7 for <patchwork-linux-security-module@patchwork.kernel.org>; Tue, 26 Mar 2019 18:28:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6F9928E33; Tue, 26 Mar 2019 18:28:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7488B28DD7 for <patchwork-linux-security-module@patchwork.kernel.org>; Tue, 26 Mar 2019 18:28:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732728AbfCZS21 (ORCPT <rfc822;patchwork-linux-security-module@patchwork.kernel.org>); Tue, 26 Mar 2019 14:28:27 -0400 Received: from mail-yw1-f73.google.com ([209.85.161.73]:42268 "EHLO mail-yw1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732696AbfCZS20 (ORCPT <rfc822;linux-security-module@vger.kernel.org>); Tue, 26 Mar 2019 14:28:26 -0400 Received: by mail-yw1-f73.google.com with SMTP id c74so19779203ywc.9 for <linux-security-module@vger.kernel.org>; Tue, 26 Mar 2019 11:28:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=XYPTV88x6bsM2+0bDxThxX+PqaKMYNT/2nzbQ6HoL14=; b=QSA3jV9BWatdGl7hVSyhHwxLAxTneVkVg14uAJ/VF/6Frih2P7oXfTEv9kMP9G6XvB HEOGTc5uUxEQVWGmCh16CeR2IwnyK1KEWe+pwfhYfgXyj7bxXTdw9tKhsEjRGPG6ArGf qjggUxIgwpRtfAPv2l9cbaEcSWEgwDoxZkkEkMYKJh+bakWOkmpkPFLrGS1LnsvYGQuo Wh2GSZNqJwd+KUkfQlegDvzkqx/b3gLT9LlY1/YbcrJdfresNx4cOhRBgKV40TW1CyVL y8hFknGmWJARHvfiwFgL/XqzMwUY7qIZmWfCXy3Y6k4nk5qc1EVpbSGWzm9iUJ2bhVMd QkwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=XYPTV88x6bsM2+0bDxThxX+PqaKMYNT/2nzbQ6HoL14=; b=ZzBlkSK5jhGA52f7VBW2HOv1jewp5oddkslLqzsvKYFL7C/XfcKkiz3eSY8S7e+/tF o/BnaeeGzjBXizub464W6o7ts7enAp+rjV96aIZl2yw7eBmQ3/0ixXg150Hpw9w+He7k 3CwPg23jmB3VRYrU0nSRYTkY/QHXm/ad45kq0SDth8ZmpnlAe9O3SQdUbuuFZL5WVI0+ 7xmdmYY/WoCGDdVM0wF5X3NPZXN/O2DV0yREKKvtao2X1VuwiNs+HPCLDPxOeQRVQKfJ tRvnbEbk/cGZjqclQB0Ik6aRd++FSuZUVbiouJQBb0IiP7rmCV22tv3zv7dJMGSeFrUu lgig== X-Gm-Message-State: APjAAAVXRPlhv2+A94O7BzhPTV2YHz17j7dz/sUHnnKcgPQIoZnymW+h kt2CKUQWJ0H1DUJcNu1gac06c9GFWwCZ2gjVjfWnDg== X-Google-Smtp-Source: APXvYqwzBhCfjCntQfOahXU56F0snMQq9ElS1KJwPE0d2nevxhWZdfF4MEC3IHuSvBuLMVlduS6O46rzOWmCP057ftS/gA== X-Received: by 2002:a25:1d04:: with SMTP id d4mr2412901ybd.517.1553624905627; Tue, 26 Mar 2019 11:28:25 -0700 (PDT) Date: Tue, 26 Mar 2019 11:27:28 -0700 In-Reply-To: <20190326182742.16950-1-matthewgarrett@google.com> Message-Id: <20190326182742.16950-13-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190326182742.16950-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog Subject: [PATCH V31 12/25] x86/msr: Restrict MSR access when the kernel is locked down From: Matthew Garrett <matthewgarrett@google.com> To: jmorris@namei.org Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, dhowells@redhat.com, linux-api@vger.kernel.org, luto@kernel.org, Matthew Garrett <mjg59@srcf.ucam.org>, Matthew Garrett <mjg59@google.com>, Kees Cook <keescook@chromium.org>, Thomas Gleixner <tglx@linutronix.de>, x86@kernel.org Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: <linux-security-module.vger.kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP |
Series |
Add support for kernel lockdown
|
expand
|
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c index 4588414e2561..731be1be52b6 100644 --- a/arch/x86/kernel/msr.c +++ b/arch/x86/kernel/msr.c @@ -84,6 +84,9 @@ static ssize_t msr_write(struct file *file, const char __user *buf, int err = 0; ssize_t bytes = 0; + if (kernel_is_locked_down("Direct MSR access", LOCKDOWN_INTEGRITY)) + return -EPERM; + if (count % 8) return -EINVAL; /* Invalid chunk size */ @@ -135,6 +138,11 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg) err = -EFAULT; break; } + if (kernel_is_locked_down("Direct MSR access", + LOCKDOWN_INTEGRITY)) { + err = -EPERM; + break; + } err = wrmsr_safe_regs_on_cpu(cpu, regs); if (err) break;