From patchwork Wed Nov 24 01:43:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Casey Schaufler X-Patchwork-Id: 12635805 X-Patchwork-Delegate: paul@paul-moore.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C54BFC433EF for ; Wed, 24 Nov 2021 02:08:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233805AbhKXCLQ (ORCPT ); Tue, 23 Nov 2021 21:11:16 -0500 Received: from sonic306-28.consmr.mail.ne1.yahoo.com ([66.163.189.90]:34614 "EHLO sonic306-28.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234906AbhKXCLG (ORCPT ); Tue, 23 Nov 2021 21:11:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1637719676; bh=Lvy7RjRBj+rVstpaWkxhmABunUEyo3MdTDjhwV0z1KM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=PE8o57+cOqactK1nImPS9nal5gKQvyF4ECjeDMiHUAdp/ab8trkYWXVrogyXR32P3btZKo3vtPp3+z/z/9+Ct2caPsL1JtnUqCR+GAtfUmfT1QT1xncLVRn/1Vod4Ksl55BTToe1aVNIIo+8ja9957gQsZJBzxZKvYbxVeV14vrnJtWJZRyrdrctIhm8KoHtJPLyboWZ4tlUfgKS1tNnm+SI/HpX4hswcaOlOzL7wmg3Cnh4YST371Sgc9tCs6j3l811QeZCB1fym5aR2ULuTRNfvm7aEL2mXys0g5rcrepPP+xg498/q9lu751ozoKrKpCKtTcIOW53emw3Vg7Efw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/rela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BFAdYliRSy42K0ioOTBYogaO39rHOOfoo3jhjVKSbEH83EJluJ6e 0fmPYcLG8S.56H8A6x1Yoarw19JVuWwErsjLRDRC1OKbsOaqKBZy.gFdVF_wpVf76Hdw.7NQ3Pny waPcc4O_7HS9CN_52dIRRAr54o_cxpxwDFvaWAYGFcmWXeKqDDGho7gs8wb28eQ1PBT8LpKXN4yE ZnxIuhvEPo1ntZyAWyV_8OkYcDrhPME1MmCRWO5ECnmEtkUEjzZ73SsuEaMb7BvX.ULUIev2oKbz 9dTDoO_85gIvdNmmQe9w8SSMXkxDiAEtuMPwBgSj06tlXbQJb9FvLmJ3lba.nTGwr6nrSUfniTaO KrGBNO.xqCY69CpoJ1kOCFeDh9DOak5UxWsDkucS51MeNIREMCDqXIzZal_LEGanbjzoTH2lxJAI cwvblIK0o_whJRHz5UDa6e_M44g43xGt9dcQXAXohRLLd59BlM53F79AwGHPzd3XMP9aHXiY0DrR t49jSFv1kvvSTIcK7YYHKWDDpdLrqTw4fJXXfN74jivkU7NIpxh.4tb5zH_1txYMkV0N72KFVl7P Gi4s0DE71wgVPwLAooL5.TT8YPKUZjTNJsKzY5pw- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.ne1.yahoo.com with HTTP; Wed, 24 Nov 2021 02:07:56 +0000 Received: by kubenode503.mail-prod1.omega.bf1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID d78d12be2dc33b4943994887cd31af7e; Wed, 24 Nov 2021 02:07:51 +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 Subject: [PATCH v30 22/28] Audit: Keep multiple LSM data in audit_names Date: Tue, 23 Nov 2021 17:43:26 -0800 Message-Id: <20211124014332.36128-23-casey@schaufler-ca.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211124014332.36128-1-casey@schaufler-ca.com> References: <20211124014332.36128-1-casey@schaufler-ca.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Replace the osid field in the audit_names structure with a lsmblob structure. This accomodates the use of an lsmblob in security_audit_rule_match() and security_inode_getsecid(). Signed-off-by: Casey Schaufler Acked-by: Paul Moore --- kernel/audit.h | 2 +- kernel/auditsc.c | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/kernel/audit.h b/kernel/audit.h index 527d4c4acb12..a2fca1134519 100644 --- a/kernel/audit.h +++ b/kernel/audit.h @@ -82,7 +82,7 @@ struct audit_names { kuid_t uid; kgid_t gid; dev_t rdev; - u32 osid; + struct lsmblob lsmblob; struct audit_cap_data fcap; unsigned int fcap_ver; unsigned char type; /* record type */ diff --git a/kernel/auditsc.c b/kernel/auditsc.c index ded4e8740fa2..0d0351dc0c52 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -691,17 +691,16 @@ static int audit_filter_rules(struct task_struct *tsk, * lsmblob, which happens later in * this patch set. */ - lsmblob_init(&blob, name->osid); result = security_audit_rule_match( - &blob, + &name->lsmblob, f->type, f->op, &f->lsm_rules); } else if (ctx) { list_for_each_entry(n, &ctx->names_list, list) { - lsmblob_init(&blob, n->osid); if (security_audit_rule_match( - &blob, f->type, f->op, + &n->lsmblob, + f->type, f->op, &f->lsm_rules)) { ++result; break; @@ -1528,13 +1527,12 @@ static void audit_log_name(struct audit_context *context, struct audit_names *n, from_kgid(&init_user_ns, n->gid), MAJOR(n->rdev), MINOR(n->rdev)); - if (n->osid != 0) { - struct lsmblob blob; + if (lsmblob_is_set(&n->lsmblob)) { struct lsmcontext lsmctx; - lsmblob_init(&blob, n->osid); - if (security_secid_to_secctx(&blob, &lsmctx, LSMBLOB_FIRST)) { - audit_log_format(ab, " osid=%u", n->osid); + if (security_secid_to_secctx(&n->lsmblob, &lsmctx, + LSMBLOB_FIRST)) { + audit_log_format(ab, " osid=?"); if (call_panic) *call_panic = 2; } else { @@ -2236,17 +2234,13 @@ 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, &blob); - /* scaffolding until osid is updated */ - name->osid = blob.secid[0]; + security_inode_getsecid(inode, &name->lsmblob); if (flags & AUDIT_INODE_NOEVAL) { name->fcap_ver = -1; return;