Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp98277pxh; Thu, 7 Apr 2022 15:13:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxv6e3StlqEMGgQloYT1shTfL+t9aWozYoYG6rcjoYjLB8mfOQnJMO4VhgscOk5+wFsgj3S X-Received: by 2002:a17:902:9b98:b0:156:52b1:b100 with SMTP id y24-20020a1709029b9800b0015652b1b100mr16137754plp.174.1649369590335; Thu, 07 Apr 2022 15:13:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649369590; cv=none; d=google.com; s=arc-20160816; b=pytkYjL5nb78phQTVtKIbuZViqo5Gljfbb/s5gXfaEuH8/N+2Q6ky8y0bmqQ5KbilZ v6z+x9JyA4W+QjwnNVecTcmceixTLUKCDakWuP4IEoXJIEhATmnFp9Jl2He2uS5Bejg2 J/JjY5KgwZku74jMEEG6MZQWXDJFZwk4bkf5xj5FWyQ/hjlX2lnq2SFew5ciEI16LcqT XyBPy/9r6XSZCzm0cFHeXO6YT0ZXvrikRSQ6XwvdSl8N+yo+N1KpgHECepCk+KCWHEX5 sCscWlgAAjIRrzFIWPM/w1IdeFeqiZbVUqb1AmPSVdv/x0U9aUVg2h52iUPyXCejphg0 8BTg== 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=GCzw8AbIKSF767bZWFoiVd6qOcKopRj1eBVPCUHsTtQ=; b=HghafhJSQo2xtb5PjQOJ28RN784xqgxtBJECoPlA99J4v1vaTIK4yvTsz+vuHo+8v9 i15dpZqIF/P3HvmGe+DA9du/SMvku+eTUH9Bx1+2BkLAILeEJfZ4K0zyw4xwzPGHQtvY Vz/CFNfd03njCNNHJOxAuIqkgDCqTPhpLEHlkSasrs2sYzfGjS7vyOd80ayEKTzvyqFz +89XBkQZakWVygBuzdUuvKI6r8keSAorM++l78OaPiowS0DghZzsuv2xcXaYxEl7UxX3 I3cg+xwRdveRHZ0CKZIEGsgmu1UOf7pR3fj20VcvxsN4zm1CkU2eNv3wuOz4br6V2rzl oYbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=bh1gViHq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d188-20020a6368c5000000b0039cd48c788dsi2187306pgc.169.2022.04.07.15.13.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 15:13:10 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=bh1gViHq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C2024176D10; Thu, 7 Apr 2022 14:34:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231674AbiDGVgT (ORCPT + 99 others); Thu, 7 Apr 2022 17:36:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231680AbiDGVgM (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 7E9A81667E7 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/jUGmXE/1Rh3MKYWsdOo33GMcyvoEcrLRZt6CQgDeBmO8aMVeRq2VyihFLNw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1649367249; bh=ChFklgIDo6SkCf2PCYreOpb++eS0TXgTlQ+/JK9CSPS=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=g1kiwzMGW6GIzAz0CNzL4Q0g016mWoEWSyzI0qte529px/ZqkiXwcnlfjacvl7WHft1zi4QF6Cb7i5q5cCH5TcfxlwtlohFH6dk3kh2Tg9/5OCrgVyfKvd0QpSiqWQHxt8SLc9OUkA5+v+Ply9fYE5gR6qG9JOX+pLJTYHIXzB/GXCUR+1Et4AE3OoQ0gRbJizbiTMoimGmfEQ79G71BnbU7MohzpjJnI2CxBvBTYHkP5GmNOA0siqPx508RS6JhHKcxse2oTlKwbE3zbrU2TnD9jUwcay2Jrkl+YsG98BHCtv5h+nxit6PbQoKixfd1MJF4I8X5wjhmyDwKSkT6Xg== X-YMail-OSG: sKLYDQkVM1lufyPAN1fUu.bkDCs6.fpu5oj6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ZQMU0QTf9y4UJzwVYAxu_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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 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; -- 2.35.1