Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6089577ybh; Wed, 7 Aug 2019 17:09:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhX9wJXbG7lmxRFmp2+NfBlbKZAPe0m0dtnQQB2irVyX/zjmDS7jCY2VxT1D7WfX8J7tkW X-Received: by 2002:a17:902:bf07:: with SMTP id bi7mr10880408plb.167.1565222982530; Wed, 07 Aug 2019 17:09:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565222982; cv=none; d=google.com; s=arc-20160816; b=Slnkzb5Bb9O4eZPjvk3JylqM+NK52jXixLW9Qq+WTGGgebXycGqjuqO+yHqiEdIN0E 6ajXvK++cS8Piw7xsL5ES+Gpc2Xv4Gpr+iFwyQ0eZW+bCaIol7G0mMsbs+n/I+lcfndP x86J90+mlGy96HBNjH79fQ3Xn7iM42yiTNxaCfAxI70gAuVLvNvYyf2xe9zYVYIY6yis jRKfy1enHzjuE5WXBplBXth0lshSJfNQY6GUmJ4nAs1u0Rt82fxYYZTR9enjL4crr4gW Mk39BtOhY78ypizhfAg3gGEgn+RtGCRFv3PZJmN2IivwhAll/5YtGjULFnlzvTCCFn16 9i/w== 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=FIo2fvd2ZRzAOCkOenwujWvUsEXtgcv+etTkEkyg1xI=; b=fMszYa0aFTvwxxWyi0Cq49epI7qROjJ6e3h+nGipdLs78Nq5TebpTFO14IWO6XFkpV in8Et2SN9mD1WRwq2xRZr6aYLLntKzy5JNQtScOXRnA3zZq9Tshpp9rZRhTMT3mtsLxl jIoXFtUSn8ulnxBROGAs1lAYPaBxoPEdBeJb0LIF4rGSr9c7Y0oZOXOjzjKTwZM6lRkM Hnqcpal+9ucftWI0hEmspfkSMBUur51Z3YlREAvT0gybEXMI4gEbNlrZGwGNpr8/Vcal ZuyLifQBlAsJ2+8lrL43YIdVU4LnMheX7j3qbmd+qZHUZkz4vB9FCXriDnY9Ls9du2w0 qsug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=HlI7Rts+; 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 p10si45228687plk.9.2019.08.07.17.09.27; Wed, 07 Aug 2019 17:09:42 -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=HlI7Rts+; 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 S2389722AbfHHAIW (ORCPT + 99 others); Wed, 7 Aug 2019 20:08:22 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:51112 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389711AbfHHAIT (ORCPT ); Wed, 7 Aug 2019 20:08:19 -0400 Received: by mail-pl1-f202.google.com with SMTP id d6so54327453pls.17 for ; Wed, 07 Aug 2019 17:08:19 -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=FIo2fvd2ZRzAOCkOenwujWvUsEXtgcv+etTkEkyg1xI=; b=HlI7Rts+QtzRW4GLuPztGKD87kPYSJpcD3OcKSF7X6Jeb+mS7V0K0o+ODF2M0pKW/6 hoY6BTWys59pq3J8kngkIEDoJ8ojECUgkCBjrcuXzU5T8AXEKSmWLwFa4Jy7mn/EcZ4u RRE/0qOmbsCIC3kJ9SRcwCm+0BZFq2evgpl7Mmuc9q6iwW2hNjJ7riryL9Hzqmp6OuAs GesRAMU2i91ckfgz34XqnR1B+65GbI2mHCxbduG2FfQqEFUm1sOXOXwTRYeKAkJS8Sp7 mqVoQHjMSHglXCEX3tU0WQnI3P/41LOjRdnHyq5Unv+q0EPR+Ej9jiXyD0QsqXXsMK6c QTZA== 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=FIo2fvd2ZRzAOCkOenwujWvUsEXtgcv+etTkEkyg1xI=; b=UehL4fiYTWLvWYkS1PXxX4aEWgOXTvnKrtIYFEN+TrB31m/mrOZgfPmNT+m/zLykIA OY5gAygzAsWHFMp5Otmd72R//DQaddBY0+FcTq80/I+vyGqETuEjII7YLV+BfEkmwakp BCiFjFyiGGIK4w2u/EQNHN4cvVrG8nVMw4WMV+RU2iuh4mQVueyDxpajCx1CSgkVtIbH CglMyeOcSyt6068p1H2Yk66U6C4unjkBA6WiUAa/SgFnyDHWdN+I8j9Z1I6oxn+T11da dRxUGRi+fKlWgi3B8mG9iKzVc6NE39pftU/1O+jrLAFANrK9hv5+JDNgCgdjFfXln8x/ 5LTQ== X-Gm-Message-State: APjAAAUq2+hcF/f3cDxuFzvKT6o7daMgwgeVTUKdcPsNchW2Q4R8yRL+ DD9yU2xgZcZgXNEfq5unOpVnniM4UXiWMnAc1kT9Fg== X-Received: by 2002:a65:458d:: with SMTP id o13mr9885716pgq.34.1565222898530; Wed, 07 Aug 2019 17:08:18 -0700 (PDT) Date: Wed, 7 Aug 2019 17:07:13 -0700 In-Reply-To: <20190808000721.124691-1-matthewgarrett@google.com> Message-Id: <20190808000721.124691-22-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190808000721.124691-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.22.0.770.g0f2c4a37fd-goog Subject: [PATCH V38 21/29] Lock down /proc/kcore From: Matthew Garrett To: jmorris@namei.org Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, David Howells , Matthew Garrett , Kees Cook 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 Disallow access to /proc/kcore when the kernel is locked down to prevent access to cryptographic data. This is limited to lockdown confidentiality mode and is still permitted in integrity mode. Signed-off-by: David Howells Signed-off-by: Matthew Garrett Reviewed-by: Kees Cook --- fs/proc/kcore.c | 5 +++++ include/linux/security.h | 1 + security/lockdown/lockdown.c | 1 + 3 files changed, 7 insertions(+) diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index f5834488b67d..ee2c576cc94e 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include "internal.h" @@ -545,6 +546,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) static int open_kcore(struct inode *inode, struct file *filp) { + int ret = security_locked_down(LOCKDOWN_KCORE); + + if (ret) + return ret; if (!capable(CAP_SYS_RAWIO)) return -EPERM; diff --git a/include/linux/security.h b/include/linux/security.h index 3f7b6a4cd65a..f0cffd0977d3 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -116,6 +116,7 @@ enum lockdown_reason { LOCKDOWN_MODULE_PARAMETERS, LOCKDOWN_MMIOTRACE, LOCKDOWN_INTEGRITY_MAX, + LOCKDOWN_KCORE, LOCKDOWN_CONFIDENTIALITY_MAX, }; diff --git a/security/lockdown/lockdown.c b/security/lockdown/lockdown.c index 37b7d7e50474..c050b82c7f9f 100644 --- a/security/lockdown/lockdown.c +++ b/security/lockdown/lockdown.c @@ -31,6 +31,7 @@ static char *lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1] = { [LOCKDOWN_MODULE_PARAMETERS] = "unsafe module parameters", [LOCKDOWN_MMIOTRACE] = "unsafe mmio", [LOCKDOWN_INTEGRITY_MAX] = "integrity", + [LOCKDOWN_KCORE] = "/proc/kcore access", [LOCKDOWN_CONFIDENTIALITY_MAX] = "confidentiality", }; -- 2.22.0.770.g0f2c4a37fd-goog