Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp270238pxb; Wed, 4 Nov 2020 22:28:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+lKLStOOQV/+Ip7EUZMHlXK+L0ikG4GUAZ6GhN4MndUqM6lCRUASiWncbJgT0xgB/HqpI X-Received: by 2002:a50:9fcb:: with SMTP id c69mr1019140edf.289.1604557721819; Wed, 04 Nov 2020 22:28:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604557721; cv=none; d=google.com; s=arc-20160816; b=TfFXLBTx+1HtKT5mv91YhGXkhxOXqWcHAva6Ecz6ziCINLZSobgZjMf5GsNjErYqzW Q45EML1Vqc67KWNodWtJPaJ6t1GZY/jU98YMoAbWuMzl13HIQjIEwiRGWKTFn0CjeoeN Q8DB8Q/9Bk2TYBj6RUOKhLePkmmouYTy0iLrJShkSboiM3HR73BD1KIu1RsMj4ic1YdU RXp6106jHxXZam/NYcm+yKTeZygauWnhvj4QwVaj5gICh0gubsUP2UUqvxWZEcMejAs5 /Wl/x4VKTLmFEt71TKVb0jDqnvt48ljjYfcY8qOSLJyD6RClNSt/osQaqWjVxjIwO5LF /byw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kp4dWfdwZR3/duFNL35a57sdXSJgVd0rWpqs628JXTI=; b=RZC0ASmE/wdUBSCB1ZUI9Fv5t6qsbu5MUduJKIl4PPY//Qgrpl061OxKBqsZR2IPs5 KEBsCK7EdW+L1elQKuS0F5Q+OZRz3yms5GZuEDp31bHQhumNSNVw2cjW1lO8Q+LMZLPU KFmcZktOUiyL4zc7XIapfBZ0Y1ZEZenzm2pu+cMbsnwXwM6Z9aPhy8ERojKfk48arr5K 1KUugffSMVk5mVkqjpcXuGsseXxxMU03T9G0P15+yinlJlspNX4/THeY/wWE6taHIiIn 0HT9TVIsrDOty+jOKkljcqRYwNQECv9Bi7UoWpJhAnRywq0A30BjL7xfPlTLkrkwYENu l/RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=M57DjVQk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r3si516240eda.352.2020.11.04.22.28.19; Wed, 04 Nov 2020 22:28:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=M57DjVQk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387972AbgKEBAG (ORCPT + 99 others); Wed, 4 Nov 2020 20:00:06 -0500 Received: from sonic301-36.consmr.mail.ne1.yahoo.com ([66.163.184.205]:38725 "EHLO sonic301-36.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387967AbgKEBAF (ORCPT ); Wed, 4 Nov 2020 20:00:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1604538003; bh=kp4dWfdwZR3/duFNL35a57sdXSJgVd0rWpqs628JXTI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject; b=M57DjVQkaepIMMogIIO5Ipx8xGSulg7nWaBk07oVhEFTC/BXum5c762FDvH+T/ynUGGomYnP2S96uwlrUnbW2yIECDaZCgECLiaEg6fG8bkWi7gKfufW0NkZVE1Z3uoqdLk+oOxYeKVntOGxkl1ToNUy3XrBLj2Xaff533aE1/fZUj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QK3rtC9ntO8OIq.jX6QGdwRIAZ1jAi3MGAr 73Sd7hBX41CLKl5a0YCno_vo8nLaWOXhjN1x6WUkfEuSUWTLtSCnsH.pXxwSNESV1JaH2jkcBDz4 thhljf40fvPtHatFn0I3DFjCkq9IrtqiwW3MJac39zHfZwU7RyaGJugrnsFrtQYgtv1XJzPAZOZh WObQy3qUvj6YoIH3MaqaoEu2dv0ES7.SdnY_B_5JS5EJevsFCeUtC5OyDvVNsTL2khaIGSe0Ow3q xs0judpwdsNXqF6lrpTdvfFwukHtBc3b6LCNqqR06Ue9Bez_d3lqrZ94L.Cuq1XkexB_ELcY2lcm 87EtSA1AMULyKpSZPiZ.JdQ3FlLaavo5KseZ8nVrwTXIJPfbnW9zviotQPoLnAxC.B8yt_gF639k dNLCchouoNLIFF.zjAPNfO4QDrJUCgtd9w1BX36erG42vChLjBz.QG7XdtCAA2zAX25AEDD1cTOB bAPaJsGNs4T4IEvouaY3UnyXlYLRA44sh5DP.UV7OhICqroKG_.BZTnykQR4tZViKgFYHp4Id.GL vEe3tA00f5yPD.AwRB1L3HgZY1.TPsxPvCqtz2WBTYU.0SF8KpNvE.2ocSVIUZOjgxhF7g8wgZmL aKppON4DUc4ym_s.ugKQGc.rlz8MVR12x6xBfte237t2An5s8fxoeN1nLp8N6a4REqeisTm_wcEr AuChv3ZCug0cP4UeuCAi4d5_.72J111hEzIBZ.FAmqV6r8priC3WjAVUx41UWqeuVFQyJyzpL2iw sKARHbK1r5vfwj62K8s3SxcVSL340nLH1WdzSuIkYoNCgpP3SVwaX4Em2BqSduHBlFLBmGcxJJna xNgj0UogCT2dViZptTgcoypKL4Xu9ONPE1hwX3Gs8RZ65RoeiNYCTu9HRqD5K9QZzniGf3KUQ2Vk C Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.ne1.yahoo.com with HTTP; Thu, 5 Nov 2020 01:00:03 +0000 Received: by smtp415.mail.gq1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 600cc41e751f00dcc1b00da4b488352d; Thu, 05 Nov 2020 00:59:58 +0000 (UTC) From: Casey Schaufler To: casey.schaufler@intel.com, jmorris@namei.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org Cc: casey@schaufler-ca.com, linux-audit@redhat.com, keescook@chromium.org, john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp, paul@paul-moore.com, sds@tycho.nsa.gov, linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org Subject: [PATCH v22 09/23] LSM: Use lsmblob in security_inode_getsecid Date: Wed, 4 Nov 2020 16:49:10 -0800 Message-Id: <20201105004924.11651-10-casey@schaufler-ca.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20201105004924.11651-1-casey@schaufler-ca.com> References: <20201105004924.11651-1-casey@schaufler-ca.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Length: 4534 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Change the security_inode_getsecid() interface to fill in a lsmblob structure instead of a u32 secid. This allows for its callers to gather data from all registered LSMs. Data is provided for IMA and audit. Reviewed-by: Kees Cook Reviewed-by: John Johansen Acked-by: Stephen Smalley Acked-by: Paul Moore Signed-off-by: Casey Schaufler Cc: linux-integrity@vger.kernel.org Cc: linux-audit@redhat.com --- include/linux/security.h | 7 ++++--- kernel/auditsc.c | 6 +++++- security/integrity/ima/ima_policy.c | 4 +--- security/security.c | 11 +++++++++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/include/linux/security.h b/include/linux/security.h index 6b9e3571960d..a7968dde27c6 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -436,7 +436,7 @@ int security_inode_killpriv(struct dentry *dentry); int security_inode_getsecurity(struct inode *inode, const char *name, void **buffer, bool alloc); int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags); int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size); -void security_inode_getsecid(struct inode *inode, u32 *secid); +void security_inode_getsecid(struct inode *inode, struct lsmblob *blob); int security_inode_copy_up(struct dentry *src, struct cred **new); int security_inode_copy_up_xattr(const char *name); int security_kernfs_init_security(struct kernfs_node *kn_dir, @@ -963,9 +963,10 @@ static inline int security_inode_listsecurity(struct inode *inode, char *buffer, return 0; } -static inline void security_inode_getsecid(struct inode *inode, u32 *secid) +static inline void security_inode_getsecid(struct inode *inode, + struct lsmblob *blob) { - *secid = 0; + lsmblob_init(blob, 0); } static inline int security_inode_copy_up(struct dentry *src, struct cred **new) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 8916a13406c3..b58b0048702a 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -1980,13 +1980,17 @@ static void audit_copy_inode(struct audit_names *name, const struct dentry *dentry, struct inode *inode, unsigned int flags) { + struct lsmblob blob; + name->ino = inode->i_ino; name->dev = inode->i_sb->s_dev; name->mode = inode->i_mode; name->uid = inode->i_uid; name->gid = inode->i_gid; name->rdev = inode->i_rdev; - security_inode_getsecid(inode, &name->osid); + security_inode_getsecid(inode, &blob); + /* scaffolding until osid is updated */ + name->osid = blob.secid[0]; if (flags & AUDIT_INODE_NOEVAL) { name->fcap_ver = -1; return; diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index 3e47cc9b7400..bbf9fa79740a 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -561,7 +561,6 @@ static bool ima_match_rules(struct ima_rule_entry *rule, struct inode *inode, return false; for (i = 0; i < MAX_LSM_RULES; i++) { int rc = 0; - u32 osid; struct lsmblob lsmdata; if (!ima_lsm_isset(rule->lsm[i].rules)) { @@ -574,8 +573,7 @@ static bool ima_match_rules(struct ima_rule_entry *rule, struct inode *inode, case LSM_OBJ_USER: case LSM_OBJ_ROLE: case LSM_OBJ_TYPE: - security_inode_getsecid(inode, &osid); - lsmblob_init(&lsmdata, osid); + security_inode_getsecid(inode, &lsmdata); rc = ima_filter_rule_match(&lsmdata, rule->lsm[i].type, Audit_equal, rule->lsm[i].rules); diff --git a/security/security.c b/security/security.c index 421ff85015da..f3f6caae392f 100644 --- a/security/security.c +++ b/security/security.c @@ -1443,9 +1443,16 @@ int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer } EXPORT_SYMBOL(security_inode_listsecurity); -void security_inode_getsecid(struct inode *inode, u32 *secid) +void security_inode_getsecid(struct inode *inode, struct lsmblob *blob) { - call_void_hook(inode_getsecid, inode, secid); + struct security_hook_list *hp; + + lsmblob_init(blob, 0); + hlist_for_each_entry(hp, &security_hook_heads.inode_getsecid, list) { + if (WARN_ON(hp->lsmid->slot < 0 || hp->lsmid->slot >= lsm_slot)) + continue; + hp->hook.inode_getsecid(inode, &blob->secid[hp->lsmid->slot]); + } } int security_inode_copy_up(struct dentry *src, struct cred **new) -- 2.24.1