Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3354937ybl; Mon, 19 Aug 2019 17:21:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjryj4I6HOSoY8eJECZID/dy6irjFo4MAU4OSsS/nAfRbaFs8TaKNmzkNUxvRiITFI2tHX X-Received: by 2002:a65:65c5:: with SMTP id y5mr22048690pgv.342.1566260506088; Mon, 19 Aug 2019 17:21:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566260506; cv=none; d=google.com; s=arc-20160816; b=u/3lJyPSi1DoxINBcSHX7l2SKXdq47SiwV+Exw9hc+U4aLaN+CV/ez5BTI73V2D4lY XTeOWpbW8fD6j0NjfTvU0HIHVLiBrG0cS4+JjDBL5GnkXr/Q8GeRztLYZAfG8/0926Jc RQfb6zeKb34OU0j+DYmTFQWfM/pvXMH5Lx3fqTQZnW7UgI+ep2sJ53mw3eCwsCdf1lKd brV21luFToXtlOS7/B/3b1OyZxgxNRh2b3QsArUFRv5bjekU+xaPCot/UNhc1E/s4cdH HyDR+Uv6fSPjfQcVpDE+OPooP93FO8kc9dNt2+t2lgAM1puRVaCCnzHUrFU+tfON4wus Y0aw== 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=QVXgaTwVG9VreaH3kje2rc/wKurD8V4CNVZ/noHYMMk=; b=ms9h2vXmjg6byqfx6rEUlLbTGarFk8y46gLsGO9KWkClhzM2fXdxTC9R67PNB8+MTT KCM33EhwkYbqf2fd4S4v++r2Z58pr5mLpH8wLA9p/8/arIs+tdERe8bx1KPzagpXqpNb z6l28wATtIdcp0HOjCaWH1QYtPY05aui+1I1u3EA738ulA/jMnROjdouTUJN6oojQFRM XOtlAALKs3etNqehPypZiX3Upgi2+TbxtKk6ATXjH0iApT7tTIw+KOCd5tqsCiHsinvE ZTK3HKJhIE+gQ4tp09w/GoIb1ZKJMl4bnERknYFu4C76RF5aGzz20hcvg0NXP+HfaRG4 5iCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bj7lFYyj; 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 s13si11736129pfe.140.2019.08.19.17.21.30; Mon, 19 Aug 2019 17:21:46 -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=bj7lFYyj; 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 S1729141AbfHTATI (ORCPT + 99 others); Mon, 19 Aug 2019 20:19:08 -0400 Received: from mail-vk1-f202.google.com ([209.85.221.202]:45034 "EHLO mail-vk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729134AbfHTATG (ORCPT ); Mon, 19 Aug 2019 20:19:06 -0400 Received: by mail-vk1-f202.google.com with SMTP id a5so2368103vki.11 for ; Mon, 19 Aug 2019 17:19:05 -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=QVXgaTwVG9VreaH3kje2rc/wKurD8V4CNVZ/noHYMMk=; b=bj7lFYyjZn020SZbZOk33R7A56KuaUFVTe2noLL8QdE7HgZxuAhxLaUSgMCukpx3vn jvYHzDrs6UZ+J8cEPlybtgzi1a4GcjbDQKj91Fxmq838IZuuR1o01r26YEk81pj8tU4u F62FzJH9nZ+M3/4CpkH1ed7675JPtKKC/L3+HwSvIge7LZEdpDlGPnbl0dSL34+lPro0 e19bCC2w0bloNUoPXX0F3Ow5/Yb0M/32OU5P0qvxdNLrBw0DxhsYs5hAPDuhxvob+LE3 keTHnblpb76cieqWg1IhWeobmLv4+1YH8q1Yv6SsJ3p7OLDyh54wMAVyugFGEyqVzf8o EClA== 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=QVXgaTwVG9VreaH3kje2rc/wKurD8V4CNVZ/noHYMMk=; b=SImyplJkXwPXyP0aZrCcwb3kml4wUohAUXyYQkPaxtLJlYRQT9IA/aeuZAdatLyMvL C/MOn+qcTw95n2eMTYnrQrcITSEZR91hY7wwmyvvDrSFdPDJe2cQC6qlFmkH810itlhv 4xGYCcjquf0x2IX7i/FvMpRRqkeo3gQqgwHyJXm8g8MUwBpHMt04QZK2V1etKP4ocRdL uh5/azffKOKFbElyYDG2QdoR0oyepaMBvsZpHYPONyMxY1reUK0DA7BsrFysKpOlQizx a2BdomhQZlUBhYU4GQFeKp3GEZ5Sv9PdMEDuImg3WOsD7Elwp8zGhkqRPRvyIkzO/XC4 Ff8g== X-Gm-Message-State: APjAAAWMzQ91OR9P9kTTR6oZusYKgVftSRugZE9rkIdbVqM6F0sL0Nqj S8pyBoKmhRZQhBBz6SyeXyCVPBYHSlRkfXiyGvkOqA== X-Received: by 2002:a67:d11d:: with SMTP id u29mr15922362vsi.147.1566260344913; Mon, 19 Aug 2019 17:19:04 -0700 (PDT) Date: Mon, 19 Aug 2019 17:17:57 -0700 In-Reply-To: <20190820001805.241928-1-matthewgarrett@google.com> Message-Id: <20190820001805.241928-22-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190820001805.241928-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.23.0.rc1.153.gdeed80330f-goog Subject: [PATCH V40 21/29] lockdown: 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 Signed-off-by: James Morris --- 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 d8db7ea4c4bf..669e8de5299d 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 2eadbe0667e7..403b30357f75 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.23.0.rc1.153.gdeed80330f-goog