Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp833320ybd; Sat, 22 Jun 2019 16:38:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwicTgygg/Md6BxdTWfAH4BJravxxXkzTbcxX4UlwKog3Jpl73qYhx1iFd4kpaCD+dwG9SP X-Received: by 2002:a17:90a:24e4:: with SMTP id i91mr16172665pje.9.1561246689942; Sat, 22 Jun 2019 16:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561246689; cv=none; d=google.com; s=arc-20160816; b=L1DMsn4NsZr7QPj3D/nIheBjjzbIJAeuHO+5fom3ehU7LUEku2tGydd9561Vs1JpqO E7uCLR6VuBgbV6ZGBwIixefZPxMAJ4EO/eEONytHEHWZuwBOU1bjuvFd2gAkMf62JbJ6 rhoed3v0lJ+xYZlZVYJbAu4+odf7FLs3ai07swxvbZ/t0p8t54hllZbdEvTTegxrRQIx KP/5FXzQHmd8qc/lepY/vYOU5wklPNHWV1Mf7tAxlR4UorAr+jdCwlijeW4MODR6c8DU TaDxV36htlMvYc6TMow8gQf7LBe6Lk/SW1sUXqNe8NSHDHAnbzye9hbV6OqfbJl95Jsm 48dg== 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=Ga+65wOE2v+5vkEnchUJiNgdze0ocJDvwZHNFQdh7wE=; b=hf7fsLJekAt3TpjbYAw/Mpqcny1KwrDHTkxTFRry4gomwrr2jLC0pbxJ8qCypmcf27 lC8tV2LwWHjiwIRyEafj7QWDEKA2/zxtYlP5SbJ1n1ikwpCFm6ZqAChWaDSwuV5zhnMA vUldKVkKvNb4x3vVVfVN6fOgfd4ka2PA97dFAn9wNgQqAGSSXCYnhHj6TTrqf2VJfQke YVeHBc/xZcxxaweGIJMfd/g+Gtxqt+1WgJhFyBcbmy+7pTxYI/CmglAXwNQxRqBHSZIT XSEmjXWjhywTjjkCUWOjnuKWwRYLy8iNjB8ikNgpS2a5kGC1rF+CPkrGgukdjO8aJb7i Qs4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dQVF0BNt; 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 a17si6142686pgl.192.2019.06.22.16.37.52; Sat, 22 Jun 2019 16:38:09 -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=dQVF0BNt; 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 S1726413AbfFVXhT (ORCPT + 99 others); Sat, 22 Jun 2019 19:37:19 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:44860 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726342AbfFVXhS (ORCPT ); Sat, 22 Jun 2019 19:37:18 -0400 Received: by mail-pl1-f193.google.com with SMTP id t7so4776298plr.11 for ; Sat, 22 Jun 2019 16:37:18 -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=Ga+65wOE2v+5vkEnchUJiNgdze0ocJDvwZHNFQdh7wE=; b=dQVF0BNtnW9kQjstMvhfMpNuTtoavNH6PNuEeUU9ApBqzXlhuDaKzI3Cw/0oZ6oMks 0sQAp2VUwExiSUq8TrzDk5tRg0Zpdxl1OxAWkVwLf2jQkM5xI+jq/s+6dt8B7z7wcHd6 HosjfGZewbg85sitHoEVP3JMMtcOMhyuS1tNU= 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=Ga+65wOE2v+5vkEnchUJiNgdze0ocJDvwZHNFQdh7wE=; b=ofba7KVER3IWqwYu3OYKzAxwIjJzWmNpf4/d/3wOBDudp/f1GMd+VQhOoVt8hd921+ HFwTGGMWXxfGzc+FUldXWGEjPnynj7/wAJkbDwLbyBdLZNI29OsblQW01XXYmuDZO/V4 6+YvbITRda/MmVteazHlunaKg/wNjc1bQspW7qEOxZ8ST/ZBLU/DpjqPaHbYF1zWBMMY 2gJBdtkUPB43V5viCSYIE5Yw+e/pkm1KDLQmI/S2r16BN1/VPNYQaeeBND+61iWKyPN4 XfQ9bto57yJU6YkgTNi0RBlGwddJP8xQ/5XYCAtccZowO7A7C62q071pn96c/bTjup+u c6+w== X-Gm-Message-State: APjAAAUFTzNfTey8OmgLkPScTjEiIIVePKET7j4UWcbvb6z59cMBi0c3 TDFG7BMHCvaKFhGGgc9tBFAIwA== X-Received: by 2002:a17:902:42a5:: with SMTP id h34mr103840994pld.16.1561246637986; Sat, 22 Jun 2019 16:37:17 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id w4sm6921685pfw.97.2019.06.22.16.37.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 22 Jun 2019 16:37:17 -0700 (PDT) Date: Sat, 22 Jun 2019 16:37:16 -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, Matthew Garrett Subject: Re: [PATCH V34 02/29] security: Add a "locked down" LSM hook Message-ID: <201906221637.6BEE8F7@keescook> References: <20190622000358.19895-1-matthewgarrett@google.com> <20190622000358.19895-3-matthewgarrett@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190622000358.19895-3-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:31PM -0700, Matthew Garrett wrote: > Add a mechanism to allow LSMs to make a policy decision around whether > kernel functionality that would allow tampering with or examining the > runtime state of the kernel should be permitted. > > Signed-off-by: Matthew Garrett Acked-by: Kees Cook -Kees > --- > include/linux/lsm_hooks.h | 2 ++ > include/linux/security.h | 11 +++++++++++ > security/security.c | 6 ++++++ > 3 files changed, 19 insertions(+) > > diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h > index 66fd1eac7a32..df2aebc99838 100644 > --- a/include/linux/lsm_hooks.h > +++ b/include/linux/lsm_hooks.h > @@ -1790,6 +1790,7 @@ union security_list_options { > int (*bpf_prog_alloc_security)(struct bpf_prog_aux *aux); > void (*bpf_prog_free_security)(struct bpf_prog_aux *aux); > #endif /* CONFIG_BPF_SYSCALL */ > + int (*locked_down)(enum lockdown_reason what); > }; > > struct security_hook_heads { > @@ -2027,6 +2028,7 @@ struct security_hook_heads { > struct hlist_head bpf_prog_alloc_security; > struct hlist_head bpf_prog_free_security; > #endif /* CONFIG_BPF_SYSCALL */ > + struct hlist_head locked_down; > } __randomize_layout; > > /* > diff --git a/include/linux/security.h b/include/linux/security.h > index 1bb6fb2f1523..9eaf02e70707 100644 > --- a/include/linux/security.h > +++ b/include/linux/security.h > @@ -76,6 +76,12 @@ enum lsm_event { > LSM_POLICY_CHANGE, > }; > > +enum lockdown_reason { > + LOCKDOWN_NONE, > + LOCKDOWN_INTEGRITY_MAX, > + LOCKDOWN_CONFIDENTIALITY_MAX, > +}; > + > /* These functions are in security/commoncap.c */ > extern int cap_capable(const struct cred *cred, struct user_namespace *ns, > int cap, unsigned int opts); > @@ -389,6 +395,7 @@ void security_inode_invalidate_secctx(struct inode *inode); > int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen); > int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen); > int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen); > +int security_locked_down(enum lockdown_reason what); > #else /* CONFIG_SECURITY */ > > static inline int call_lsm_notifier(enum lsm_event event, void *data) > @@ -1189,6 +1196,10 @@ static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 > { > return -EOPNOTSUPP; > } > +static inline int security_locked_down(enum lockdown_reason what) > +{ > + return 0; > +} > #endif /* CONFIG_SECURITY */ > > #ifdef CONFIG_SECURITY_NETWORK > diff --git a/security/security.c b/security/security.c > index 487e1f3eb2df..553f50e9a106 100644 > --- a/security/security.c > +++ b/security/security.c > @@ -2382,3 +2382,9 @@ void security_bpf_prog_free(struct bpf_prog_aux *aux) > call_void_hook(bpf_prog_free_security, aux); > } > #endif /* CONFIG_BPF_SYSCALL */ > + > +int security_locked_down(enum lockdown_reason what) > +{ > + return call_int_hook(locked_down, 0, what); > +} > +EXPORT_SYMBOL(security_locked_down); > -- > 2.22.0.410.gd8fdbe21b5-goog > -- Kees Cook