Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4545296img; Tue, 26 Mar 2019 11:30:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPcaWnBFlpt/nsCBNAtvNKCmdmGNrKD8BEsllPQyc/crdhgtfMqf6VkrrcbTmBiMdMyC8q X-Received: by 2002:a17:902:f302:: with SMTP id gb2mr33434108plb.51.1553625045175; Tue, 26 Mar 2019 11:30:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553625045; cv=none; d=google.com; s=arc-20160816; b=00wmtms4lLnXJcm8lZBCJZFWxPkp6eidz2VCUHdfcktMX0NGDacqgnHOtZpP08MMP2 nmezaoYgEkc6BGZxruIyJwSoVEL1oMivseOk9hniZtbH8p624+zjIOlvgr46RwMcVFxJ TMoyqAF/Wi0E1rtAhQA70inmxbfHMAAdEiZPajU2voI4qL+V+yxP2NlIoWLRA8Ov1I88 iWeY+x5V9peBRSB6Yexm/Eg9zHy/BzYfZDcApV1oioAZiWXhhbaDECwAnRMBUsmr6lW4 XzBurVKLTITDoFBQzl0mUbJVzkTpyO9ot0rpbZh9+RN7HM1BrHoQEFi3hSSqrPa6kXji J4FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=CCajKTRONhdynt5B0tRKLHYn7gScHVmkVEVnwB9DKOM=; b=O4Uv9LOfmVoDyenjfPYuwHYMmshf6ciKNbsWp+9LwtCbcXc8FMboP9w3LPLoXS/dl1 MaNzC2+aCCKP1TKvK/HUacF11tkED8aHa/tx1+OMXY/HuWbAGObL5iFUvOqC5lqLbT+r 1chIhFh3BmgxSH90gPo86i2M38b5IgKZXg0mvWzwhKZU2TQKsohWP3p5zdWSvbAS85c9 I5e/TEeu8GcFZDQ3CKHYLbWzeso9E/LJGDSF+0DCdnW5mwEJuoAtlO5Yk3cyq3lAItHG pHpB20Iq64H2VqnIWke4P/Og6ZFs66jk8DQls+LffJ3sTO7vBb2mbHID2I4pQ/Q6VmQd MNcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=f1UEVtxL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si16299445pgm.355.2019.03.26.11.30.29; Tue, 26 Mar 2019 11:30:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=f1UEVtxL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732936AbfCZS30 (ORCPT + 99 others); Tue, 26 Mar 2019 14:29:26 -0400 Received: from mail-vk1-f201.google.com ([209.85.221.201]:50190 "EHLO mail-vk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732804AbfCZS2o (ORCPT ); Tue, 26 Mar 2019 14:28:44 -0400 Received: by mail-vk1-f201.google.com with SMTP id k78so5823904vkk.17 for ; Tue, 26 Mar 2019 11:28:43 -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=CCajKTRONhdynt5B0tRKLHYn7gScHVmkVEVnwB9DKOM=; b=f1UEVtxL0EVlbPLDdmHVG79aucAXc1fBqJUwg7tt7fSA+AaesqY3P1p2ZfzU8cEB3n 03bsTL9VAsQne/n8Nhvw1sWnpcWum4Nqv3Yd9wb0ciIhqZ81AcSWIwiSc4FpvQcIXzja GBTM5kZH/0zi5Ne9dZ+ikq9lnF2Q32FFRZvvpt9YRkY75BhFAUNRNgck5+N1zyk4f1qA vMNtUXdf9cac4ri6xntmYw06VGoUUZsq8lxd2e2TecdKei4KeSsc3xhm0MGSU87S8/FC RxRKWWq47aOtlEK1k4qA6SDhvIGzXiN34T2kO23uj22gg09sBp27vGRNkphNud+PLe70 YX9g== 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=CCajKTRONhdynt5B0tRKLHYn7gScHVmkVEVnwB9DKOM=; b=FP/+rvX6Pv1P+gBjYi4dMP0dJpkBz3QxMOzttK+Krk+/ZriewOvhWYrHZbuej6hifS Tez18sgMm/gyRx07fQMgIYV0wlfYUtkEfR7JEndJW+INdcQ3XNZAG/xQKY/ObmNRLivY LbGBhOjcQFURZaOBg01cT5XJc1ZPGc0/7+qbQda5b6XQro9sLqbDtXGepJ6E3Xj6r/dQ m/1uEkNi2+YN3d65N0yUnav0SdB1qsJ7V8oNJlux59jQk2/A5rXNCetUjWBn4aHgTS2b 4m0EJbGG7uWNKUO1dNbCCsV9fnpAN24N63uIoMZ4U3cDYHI4Y4/yL/Jh+ZYI573ghDEZ akfQ== X-Gm-Message-State: APjAAAXDsdZCFyzcs3BMirRDjOhFRcRYn0BXfYQNqbP4o/3Z0vhJPuaS ArFAbvDE+x5l03hs4fIJW1F1dQoVp1ry/Dr5Y75wZw== X-Received: by 2002:a67:e405:: with SMTP id d5mr11689528vsf.236.1553624922695; Tue, 26 Mar 2019 11:28:42 -0700 (PDT) Date: Tue, 26 Mar 2019 11:27:35 -0700 In-Reply-To: <20190326182742.16950-1-matthewgarrett@google.com> Message-Id: <20190326182742.16950-20-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 19/25] x86/mmiotrace: Lock down the testmmiotrace module From: Matthew Garrett 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, Thomas Gleixner , Matthew Garrett , Steven Rostedt , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Howells The testmmiotrace module shouldn't be permitted when the kernel is locked down as it can be used to arbitrarily read and write MMIO space. This is a runtime check rather than buildtime in order to allow configurations where the same kernel may be run in both locked down or permissive modes depending on local policy. Suggested-by: Thomas Gleixner Signed-off-by: David Howells cc: Thomas Gleixner cc: Steven Rostedt cc: Ingo Molnar cc: "H. Peter Anvin" cc: x86@kernel.org --- arch/x86/mm/testmmiotrace.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/mm/testmmiotrace.c b/arch/x86/mm/testmmiotrace.c index f6ae6830b341..9e8ad665f354 100644 --- a/arch/x86/mm/testmmiotrace.c +++ b/arch/x86/mm/testmmiotrace.c @@ -115,6 +115,9 @@ static int __init init(void) { unsigned long size = (read_far) ? (8 << 20) : (16 << 10); + if (kernel_is_locked_down("MMIO trace testing", LOCKDOWN_INTEGRITY)) + return -EPERM; + if (mmio_address == 0) { pr_err("you have to use the module argument mmio_address.\n"); pr_err("DO NOT LOAD THIS MODULE UNLESS YOU REALLY KNOW WHAT YOU ARE DOING!\n"); -- 2.21.0.392.gf8f6787159e-goog