Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6480300ybi; Wed, 31 Jul 2019 15:23:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnKkrceOx0Vutf+vtbzMldINGWqHVoupL21LxnFdCIEsSWwr6EfkCjN/sNGmDodzLN8+ZN X-Received: by 2002:a65:5c4b:: with SMTP id v11mr73304702pgr.62.1564611782069; Wed, 31 Jul 2019 15:23:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564611782; cv=none; d=google.com; s=arc-20160816; b=skADpCQL+sM5pdE0ixQf2jVCnSWmZzG02w8SJcNbCc7FxePIKFlLwJkS0MQysGKlMA eeM7WRaMetQwcb1rnXf7arhacg9xzQw+udDlrDQD8LEN0qp2EIBzkZXc9zNLWtGEtiDN L/DmAM9danMhcgQRz+Lz1NxmTg7MMwT2WTqs42co1dB7yr/ztdqq4ETWs4qSQmwDqTTP jn9GIm1Bg4yqSO9TZaVAtE1ZNA9ys6qZZkAaZWcicrCTaAx6VfjmTUW8rnP9ke+t4jtu 13SxAX19X9p2PUWAj+kbcrP4C5ZntzmWkhIGhgdmM36TeI88BMeV9Dv/Z9pN0uWcO4Ux 4JzQ== 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=QJEk48aAre4nFyPx3XmoVCa/KLXaJF1Nnuh2M1x2fUYQLNYlSSEWZnXyPH/0njfUzk V66AE2kA/vuC94mwelAfQ+CBeB20iI/8mDYHNQ0Wa2fvCz0hodkCx21b+aCrddoppSJ1 dFlz5wJetDuGn553e6s8ua/yrxGnJyYv9gFnc46/uUHrBULfnQh5cdI5oLujl9cgnA82 RYdXzCgOLDAgBNaeE+A5ukVhYYVBy0ZyfwxYJrx1BRHS1blgq1ZWL3NqrmdnDLHGyCGq Y+xLVvjJrr9BcTz7lfkLapVi4DCEOCRNU/4GPf/ulUlQu3f4v+o25IsMNraQuy/Dvwx/ 12RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZhaBOeUn; 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 p8si29325412plq.53.2019.07.31.15.22.47; Wed, 31 Jul 2019 15:23:02 -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=ZhaBOeUn; 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 S1731351AbfGaWSu (ORCPT + 99 others); Wed, 31 Jul 2019 18:18:50 -0400 Received: from mail-qk1-f201.google.com ([209.85.222.201]:50558 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731352AbfGaWRU (ORCPT ); Wed, 31 Jul 2019 18:17:20 -0400 Received: by mail-qk1-f201.google.com with SMTP id e18so59266839qkl.17 for ; Wed, 31 Jul 2019 15:17:20 -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=ZhaBOeUn+nS6E4T1+sBKPnygtWezzpdPerEqfA5uqkD0XE7ajx1N3BtNS+gYIFvTMv m5/OTl8rt5TML9cNVvxzr00+WM4rpnQh6KtnkCsy852F9N/KziU4WPdi4AoTxbrZOIGD ZOFwSYsTuejxhPisUAE8hIyWXaA2sjlt5OXBzdmnDWJ5pncwcDuVfcYf0NntTSKlpQjp rKKZtgFGHKjLXws/EcubYglXFByM0y93MDCDhUiun16sMe93nN1WtD4on0KReHoc1RCd b6udBfRpp4S+HJiB9HNdkFhA4hO9S++7vB0TtCj9NlX8THX3Qm4rDqKyBqdn1siC5g4u RUoA== 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=iZkLM1o7x4yjFZuvwmRvmCh2R6RmRPz0nIv7dGBdRkZnw1vu/BR1pTcunvntuUAJTy QurXsZnQz+UJWdx72ufwhks5FbJGMheSB0nEwJY86AXkBcEEEiPUhfkhs2mzjFqFRFNx tdT2ES2Y77xqqOxwLqRDq7o9ky/9pxOpCNILnMuipRmdnt3Wm2U4b/2gnpf5mzomriOe zD1kNcE1E4WLlF1FNis+/NY0HTJswWVk1ejEn/nn1C48Sd59QQUMm0DqyYBXp4nhuhMO qP41ABDWDFfJ3WeHBkMZs7jlC+sPMEuF5AUtoGoquSNvpxRrTZWv9BFkbJYXC3TJHdFR 6hHw== X-Gm-Message-State: APjAAAX4n9mhr1TF9EBC6VNibfS73RSfq9sB/25arkzXK5zHYuElDT04 sTC15J2HTM3a5gSLyK66FvrmDKgsTvsZcuWTlCZzbw== X-Received: by 2002:a0c:8690:: with SMTP id 16mr91555482qvf.228.1564611439834; Wed, 31 Jul 2019 15:17:19 -0700 (PDT) Date: Wed, 31 Jul 2019 15:16:09 -0700 In-Reply-To: <20190731221617.234725-1-matthewgarrett@google.com> Message-Id: <20190731221617.234725-22-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190731221617.234725-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.22.0.770.g0f2c4a37fd-goog Subject: [PATCH V37 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