From patchwork Thu Apr 7 21:22:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Casey Schaufler X-Patchwork-Id: 12805795 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 8F563C43217 for ; Thu, 7 Apr 2022 21:34:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231682AbiDGVgN (ORCPT ); Thu, 7 Apr 2022 17:36:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231678AbiDGVgM (ORCPT ); Thu, 7 Apr 2022 17:36:12 -0400 Received: from sonic310-30.consmr.mail.ne1.yahoo.com (sonic310-30.consmr.mail.ne1.yahoo.com [66.163.186.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EB2A12765 for ; Thu, 7 Apr 2022 14:34:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1649367249; bh=GCzw8AbIKSF767bZWFoiVd6qOcKopRj1eBVPCUHsTtQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=bh1gViHq6KdUKY5pn3WJqU67ts2txK2gb2O3Iry8qUH957u4gMGhSodLVr1HkUzfu3DW514RXDEyRpdasVpI5nIQqw+UocjnR3r3T+khfKCnpJ1Wsmmb47EDDd/quD6l9Vsqm9rPw/zYXdQRR9FXoKLRkDCGDXlB8nNsNw04FfFJ6c19PeX2pXBEFejjE8hfLR+27xLASeWVOY9huugUvMmLiR4yxQr66oANJyQfXHacWpP6UFSM0vUWiX8FGFaIXC/U3rVxaaM50axTHbYfMuQY6n/jUGmX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oQn3Zpl_ZJ4Du x8LALXm.8vxajVl54qj9E518dbdi9AcJLXh.uDVQh1.gGPIy0nPjCEOlAZUuB9v4L_sZexniC.qj dx2DJ04qZavEU11lML5d00ds5kwhdT6ayfpgS_wfcV4Y7kQC4YiE7ACFTh8kAXIMAIUh..ipRERu WQ7oLrGUGIynZ1_AWjiIVgXf.2RQDB_yxHCELeeajzFnmfCtugc7RS3tP5VxdtACu3NfdexX8kEG l0WTKCKXb2CB.2oen11oXDgJSnQUrBWnaH.E1kRs4LFbzILSkyI9JxCVWnHCvTeSkmx9RvHjaleq hAqH8VPec5SBUYHLW4DNfa7wD2oAh1jNg7ulJeUUp2EuBHCKDg2WqiWg0trSmITA90R10WhuREQd QQd20eeiiYFkqEtR9aMkSB2HAM8FBpcgU_SJTUpGKuPThRHNWUbQXNfC5_g_dI6W5fKB7VQeug4X B7rlavBtTWnUdwBzdZ6241JNj_kLTRr_6mFI_FiEfmpvpCoXPtFxEAuBJJ47CfSu7Fv4iIE9vUK1 wxj.5RYdMu0FyYPXO1s0I.6_k66DIzeI3vXpt_LAdxO.gYE.aM.lZQMU0QTf9y4UJzwVYAxu_4zv CWgrNJbFH7HdwHAhWGICb24M2LiQ0W8dKnrIkKNNEN0Tq_fPqhOcRRB17RZfXEAXFy1P8HLyRIz1 nxYnEGYTBrGK7BY4.5vvZ3JPYs.p3NiaGqSl4hVGy8MimrT3lGpQ- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.ne1.yahoo.com with HTTP; Thu, 7 Apr 2022 21:34:09 +0000 Received: by kubenode510.mail-prod1.omega.ne1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 6ea890d0479c56b8723f536561e1f9ea; Thu, 07 Apr 2022 21:34:07 +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, stephen.smalley.work@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH v34 22/29] Audit: Keep multiple LSM data in audit_names Date: Thu, 7 Apr 2022 14:22:23 -0700 Message-Id: <20220407212230.12893-23-casey@schaufler-ca.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220407212230.12893-1-casey@schaufler-ca.com> References: <20220407212230.12893-1-casey@schaufler-ca.com> MIME-Version: 1.0 Precedence: bulk List-ID: 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 316fac62d5f7..4af63e7dde17 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 82aa6049a858..6fe9f2525fc1 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -700,17 +700,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; @@ -1589,13 +1588,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 { @@ -2297,17 +2295,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;