From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6846CC76195 for ; Thu, 18 Jul 2019 19:45:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4134A21849 for ; Thu, 18 Jul 2019 19:45:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vodmcAMn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404021AbfGRTpP (ORCPT ); Thu, 18 Jul 2019 15:45:15 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:43749 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404007AbfGRTpN (ORCPT ); Thu, 18 Jul 2019 15:45:13 -0400 Received: by mail-pl1-f202.google.com with SMTP id t2so14458070plo.10 for ; Thu, 18 Jul 2019 12:45:13 -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=mT71xXVMH/YHXOSXzvPL0YxfKiIdabN6lyP5dpCrImQ=; b=vodmcAMnUh0hMddJHJka9lcA79+EsuKYh9jQ/nRDimpHP2j8dNS8ZkNSHnz15Zmqxx 8T5PpWkIyrO0Ihi3lsLVJAiZ97yw/aI99IUsFCTgFUHjyHhUXbNSNcTg9QWvbAzg/tNt L0PHpzxXoK70mVorxkpV8am65v+xyxN+KJAg3OvNkHdHIRddY3OJPlIZqkHhPdmzVq91 ltHihVyene7ZHPNesB5qECUzVqNVMvBNHmTKBQA2VOJBmbaUJKj9vBz4inT8xG7TzG/S HB7ijyroYoriT/1w/4121SWUE7G78gYZB+0NUbyp6tIzdK2uWXRNVrrNFKG1qVdw25Lx fKlw== 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=mT71xXVMH/YHXOSXzvPL0YxfKiIdabN6lyP5dpCrImQ=; b=tynFaxCJ42U9Xu7JCLO5W/6965MhsPSo/mT/fxhSoM1TWJqVFoLAMIgWScLoIhB9MX 6JajPkKy62gzY7KZ47YFM7tJ2b5yh48vUc0bOWFkH3gBle1i8i0tSBvYWXbHlsA+EKqD LRZAYADenXolbxwyrRy83W9+1BznZQCZ1flAbNJrLErXqWNZhN+gacTjN95sjgZIDD5f G5es7CncOmdDfRAWQbs2l2GVO1qrk4k3n6XREyXx3TDcrBgEzFDDRQ8G+hguEgg9l51n b/gmrckQFtAWZL0PG2W7HQxAHa8+OS40FVawo+jqXjifGir9HScGzNn6MWXflKxI2Ugv hgGA== X-Gm-Message-State: APjAAAUfouiDvPLQ1adz1Q43uly7JyQw39XesFxV88l9A5ZshgfW15IN 0GFYQjkWkCSex/U3+x8GK1bgpAh7bnUoRagJxaNDUg== X-Google-Smtp-Source: APXvYqzvoYeByMb8GuABYxGSZRPpcq3M3gaVftP8ooVueZdKIuBRQTXo4VTviDY8kkeRKzQJJaR/UejRFk1iKrC5nLfDZw== X-Received: by 2002:a65:5304:: with SMTP id m4mr48981605pgq.126.1563479112898; Thu, 18 Jul 2019 12:45:12 -0700 (PDT) Date: Thu, 18 Jul 2019 12:44:07 -0700 In-Reply-To: <20190718194415.108476-1-matthewgarrett@google.com> Message-Id: <20190718194415.108476-22-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190718194415.108476-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a-goog Subject: [PATCH V36 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.510.g264f2c817a-goog