Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp83056ybi; Thu, 20 Jun 2019 18:20:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzw+wM97flzNaDnw7ObX/9Booe2z3zg78sk7AtO4ursqFLbUmHmBs83sv9PtcazRmAgsWB X-Received: by 2002:a63:1d2:: with SMTP id 201mr9956306pgb.232.1561080024352; Thu, 20 Jun 2019 18:20:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561080024; cv=none; d=google.com; s=arc-20160816; b=UvM91z2rnQFq8NrlHZ4KsfRcZil8pAiekWpLbMjRYM0yocNPB0Ggq1/jTbv+GXaPuE b7CaoebwsT8DSRpvIlmzLG75kDNaR5x9P+0k4jWpao3badvaxfj+gC+iYvwSolvT5xXQ Hpr34poh2yYpgfrGPhbW5LLjGJzn5+kfXP37wu7HrTOqJ5907h07cRp+OaTNHepNfTd5 A0lsA9SdUvYAODhUfC0c6cn4Em/edBB+Skb8BPQUgEbHnt31PI1jlKvM767gLHxcZJKv MImbesvCw5+kFfY6kZYC6x8wwSMzJzY2R/1Abcx2OjA7RBv75wdjZZsQS28a4DtEbR+J t8Og== 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=rLHZlHKZcfbaxVt+EZWYgUOfoYBVDdWFXT/fQo3GFRs=; b=r7vy/3pjvUcjUvnfBy04ZWfIoP6qPKR+N1BAr6IqZ2haHnr+QrJNVyrsmog0GxumI4 LHRe0vX1SDq3j3atru+HL6FKXW869mnxLwbBIFm8RLNhpnzzDos9IhvnsDNEhanPd2wi hq6NsGhJbxF98E2NiZaD2TqVVg6nKqYzGI0helq5zflMKyjUyib7smH9ZQpJ8NBYj7ps 77xI0q5Kn85SspzWW1YPek9RohhjzbeF1pml5T1cFqpEmgme2zpIgKPioeCmyiZo/e5+ nVw8wywGgJVMrl4Xwm7s25h3r6swwf//WiodeQw/yAz1niMKv5DzHa+OS+zjfq3H7hpa M1qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=AJS9vmKE; 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 g94si1185775plb.142.2019.06.20.18.20.09; Thu, 20 Jun 2019 18:20:24 -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=AJS9vmKE; 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 S1726326AbfFUBT4 (ORCPT + 99 others); Thu, 20 Jun 2019 21:19:56 -0400 Received: from mail-qt1-f202.google.com ([209.85.160.202]:45848 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726220AbfFUBTw (ORCPT ); Thu, 20 Jun 2019 21:19:52 -0400 Received: by mail-qt1-f202.google.com with SMTP id k8so6067476qtb.12 for ; Thu, 20 Jun 2019 18:19:52 -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=rLHZlHKZcfbaxVt+EZWYgUOfoYBVDdWFXT/fQo3GFRs=; b=AJS9vmKEqoRGrskfpv1ZR/l4YY3R5i1qXYpImrhmSLfic+tVJ7fyxJ0V/2RWzvULhC 6nnwMuapG8U/xu8WMwR4GZrZP1tMILBBNe9Ar9qfMOoJvAAcrc+MCzx1OafPT3IL92Bl SnDt5GKVBU/BIPD6JCy24cNUh0tHmlUcV+I+TwgfRWdP/0AOtyIiYu7fmvFFDqD6xxe5 VIhJ7oIVDfpoN+kY4sLMfmeO8zOseGMyYgQYFfI8TmdE3REOolSTzT2vNkNUT3jOA2Uk sPb8eJWssFndY2Kh/MUG/ZPl7eGDrF3e6BGecIDcM2qVMEhSLy5HrI0ZzvmWoSYaGJ2U wCqw== 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=rLHZlHKZcfbaxVt+EZWYgUOfoYBVDdWFXT/fQo3GFRs=; b=khUhg7GyZb2dLjGtGBb1fCNd94th9s5XlzvlCnNSj1uEpIzo61ikpS6OHy1mn+1SNM X+ZMR21zCZB62EqtpeGBsU5SiD/LGqfz5ePXUuG4PxhjwhJ88aXwLySPoT6sE2ohiZ3y iFrT5pvqvhSmgkq3sI4tuvTds8FJGOt4r+CoobBIAsDZpNy99Bi7HE6dgUGTJu6sqVYq OJb7hFLLJKS6evS4kmSJDMFWkKTYMg0jzG3lf5icWDZsxw1WM2YmsN/6wdqFwhIDpU3m zkkrq4BHkye30f0Le4sdBMu2t6YVJKRtgRi6+TLH5N+LHoFg7lAEB0foiBps0lH8mSa2 Khgw== X-Gm-Message-State: APjAAAVEiHUGFMbpWfNFEr6VdLjsY4J7lBS4v/ZKyWQMinkLYrNmfHbo sqragaAnNQIdXrDqUBVUCIpqPfmPqlJpXb7E4H6NQQ== X-Received: by 2002:ae9:f101:: with SMTP id k1mr9349090qkg.337.1561079991648; Thu, 20 Jun 2019 18:19:51 -0700 (PDT) Date: Thu, 20 Jun 2019 18:19:13 -0700 In-Reply-To: <20190621011941.186255-1-matthewgarrett@google.com> Message-Id: <20190621011941.186255-3-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190621011941.186255-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH V33 02/30] security: Add a "locked down" LSM hook From: Matthew Garrett To: jmorris@namei.org Cc: linux-security@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Matthew Garrett , Matthew Garrett 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 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 --- 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..b75941c811e6 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_is_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_is_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 2a6672c9e72f..17c17d4d8552 100644 --- a/security/security.c +++ b/security/security.c @@ -2378,3 +2378,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_is_locked_down(enum lockdown_reason what) +{ + return call_int_hook(locked_down, 0, what); +} +EXPORT_SYMBOL(security_is_locked_down); -- 2.22.0.410.gd8fdbe21b5-goog