Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp850601ybd; Sat, 22 Jun 2019 17:06:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4T44+96u/WZt9Zv9WUJnWjE+EyTCPp216dU/GL5YTvLJcMuJNmggiosagM4ErirY4FbzT X-Received: by 2002:a17:902:2ac1:: with SMTP id j59mr67057394plb.156.1561248411485; Sat, 22 Jun 2019 17:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561248411; cv=none; d=google.com; s=arc-20160816; b=SPSPIpjtd2inuyxm5jsvpwbCOhkmWl88JD6K9hRP0hWWCBWAiZcqe6eB03A8VTQsy4 VjOt6+DpSb3xvpD3rYDklXFnq0AujxTnrQHNfq7gfgB4Hf2PGD8SHGB/837PTvOwNATU mUrd40LuzWuW1MjkWdZ3FgxgB+sGqM/VBssPTjrY5NeV+HQSjv6gAQA5d6dZOHTtBEak o9FZSQxLXufLFwD5C3qu6wPLdvR/tfMJQozOmT5sruoMNID2N4UVeHokwhod0igBL0Y6 7vL0cf6JXrlUBCKDJfPYMojb9wG2LCl6dbfBY2dVwKoKsoHJBQG2okGVJeBbZ4uAeJ9v Zl8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=JYs3mm0s/xwXUGMs+rQmFBeqA9dl2+moMKBPlLJXjCs=; b=kHG2GSi0fYf0S5txsFBp98s5fwo+7FHbRMhYSKMqESUnYPa6UWN5pYFMYe1bA2V3TW gTHoFBMqWR6mDulO78ENbqWFJPHWKlvre2Ev2E5l3J/vza2dx+nCmch7Fq401kvqJnN5 cLpoYbY+l61l0W5VewdOuEuaUMdzBCA6eHxVSSL0z4N4eY4nimLHVBec/ZBmQ3XASeD3 KeQOgM2b6vsbFNiaya+UUQeT3QDde5EIHeZU+BJ5lX/w+jLz7LF0c3PDgmuSsY2ek0Uw qzp0YMiXOfuSlVN2beuAPll2tAEznGQHyw5yCzRY+gyxafVHWWR6Jny8vewuIoDJicoR Y1Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=P2xRTaZE; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x82si3429921pgx.416.2019.06.22.17.06.35; Sat, 22 Jun 2019 17:06:51 -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=@chromium.org header.s=google header.b=P2xRTaZE; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726567AbfFWAFb (ORCPT + 99 others); Sat, 22 Jun 2019 20:05:31 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:46145 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726494AbfFWAFb (ORCPT ); Sat, 22 Jun 2019 20:05:31 -0400 Received: by mail-pf1-f194.google.com with SMTP id 81so5412507pfy.13 for ; Sat, 22 Jun 2019 17:05:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=JYs3mm0s/xwXUGMs+rQmFBeqA9dl2+moMKBPlLJXjCs=; b=P2xRTaZEatViMGnZFrsPjXXIGcXrS98FshMXalHklW4xwdU5PUC1ergvUUukU0xbPW 3DNVBwZiUJJq393aQA5ThqaecsTM3bV14AVfSNVq8yix9QRrC+yCuux3WoDxgYtsddGb 4vxr1YxTGxKH9qOsKGQgO/W6WJiK+K+2kyTyU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JYs3mm0s/xwXUGMs+rQmFBeqA9dl2+moMKBPlLJXjCs=; b=gS81XhrUA0ihETFQ1nSx+2uA9MaENZD3Ky725Yzh14/bzWlrT+I106m8z6VMaEAjyB 2l4f9iCHPR843sXazk22dCxVe7Qr3GefOpOny16pRXR0TnW80VDUs7Y0t26QZi37vi7G vNXhpNQN73JYmL26d0Kw65FoKEma/FvpVGhVlaDzccJbTueS1Bf1uxfnMkogi0Tagejj yOvPe65kUWsM6LuZ3f6R+g5jnLjcf2RxsfHciIayvU9Cq0FbUznDBKugIKNMYKdg7Nr3 tIc+3uOKLiysIMB36pQxmFGH2Ue5tHIg9XNEaAUnneASZLxIIKmaKXx6plrpPBxX9YZ9 aPHQ== X-Gm-Message-State: APjAAAU/Qn/k/MxJHKbZMpXfMHqxNwObmWFs2ugPM7UGbxHyx6h73OSn RRGbNapaBsHB41HhCdl6gwcMpA== X-Received: by 2002:a17:90a:d3c3:: with SMTP id d3mr15916386pjw.17.1561248330850; Sat, 22 Jun 2019 17:05:30 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id y22sm6912804pfm.70.2019.06.22.17.05.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 22 Jun 2019 17:05:30 -0700 (PDT) Date: Sat, 22 Jun 2019 17:05:29 -0700 From: Kees Cook To: Matthew Garrett Cc: jmorris@namei.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, David Howells , Matthew Garrett Subject: Re: [PATCH V34 21/29] Lock down /proc/kcore Message-ID: <201906221705.258B22D1@keescook> References: <20190622000358.19895-1-matthewgarrett@google.com> <20190622000358.19895-22-matthewgarrett@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190622000358.19895-22-matthewgarrett@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 21, 2019 at 05:03:50PM -0700, Matthew Garrett wrote: > 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 > --- > 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 d29d869abec1..4e95edb1e282 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; Another capable() check ordering fix needed. With that: Reviewed-by: Kees Cook -Kees > > diff --git a/include/linux/security.h b/include/linux/security.h > index c649cb91e762..3875f6df2ecc 100644 > --- a/include/linux/security.h > +++ b/include/linux/security.h > @@ -95,6 +95,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 cd86ed9f4d4b..4c9b324dfc55 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.410.gd8fdbe21b5-goog > -- Kees Cook