Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1455786rwb; Tue, 27 Sep 2022 13:23:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5oPVDImoiOmjLlKRfDnMlNXTTr/upjpMbT18v0bLA+IN95+MQiM4U+ijZqoyS0SceM8BM9 X-Received: by 2002:aa7:985e:0:b0:557:cc92:34ae with SMTP id n30-20020aa7985e000000b00557cc9234aemr18348556pfq.66.1664310224482; Tue, 27 Sep 2022 13:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664310224; cv=none; d=google.com; s=arc-20160816; b=dsAiSDP9lpO8CdjoyuZuBNjXepQgU4uWRaahcRAEUik2/Xi9ek+kZHXHbxIL+QysLs MMhEZu0CicOiJhJYZtc59LTsahc25chmQPdb5NaaUFXRO9X8Zx5h+DEQww8JJO9E0oQD xkxY+k3bzaDqUgyBaB0BiJJ54cQKnGfrisv6ZEkOS1pq8glmBv0bl7OC/9ZjFAosEV9y nIkIFLEr+zy5DC+slpLpPqU4LkaAGs2qNoScDr/pwN54Wls4HKFqEG4RMWc5zD6vY08a O/229WZUfY143ecP4G7LO7HmpglwUcgMun76X8kTgftb3uDbeqlPD4WTBfC+t9gZM0yM xq0Q== 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=Z8k6KNfxmofAulBiJEk844o4bSszlNFVmtrbKWlkLuM=; b=H96/xgZzRz6sK0tGh5p8DfxmWb+QtZVnvyf/XuGGg3WdhIi+72ScjmJPaRvfPBjiQm 9L/qgMjdmU9OgcfG9klOACGDMH8cZmqdaTaWcw3lVNLKE/VtwHrLCi4nBMz9y7tb4wZn almwpiNRkFbX3PjJaAHzfKG9Ee2p9sC+OYjt0K2M+4gs4AwCmX7zv2aYLXwLl/LIhSD3 b7dYpSUcFziQRc23vadONtA1fUlWNjH/VE/Ez5L/ZRQosUeadf/wt8ih89VnuoohCsP6 fU/C/RaG/ifS2UiH9ywmoBX0jcXN5XlN3eBhH/wPsVgIubK7a6TI5xcN63IqeGTWpr+E Ldaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b="sZEX/6YM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o18-20020a170903301200b00174c8f14836si2444381pla.237.2022.09.27.13.23.31; Tue, 27 Sep 2022 13:23:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b="sZEX/6YM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232937AbiI0ULG (ORCPT + 99 others); Tue, 27 Sep 2022 16:11:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232880AbiI0UK1 (ORCPT ); Tue, 27 Sep 2022 16:10:27 -0400 Received: from sonic302-28.consmr.mail.ne1.yahoo.com (sonic302-28.consmr.mail.ne1.yahoo.com [66.163.186.154]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E2B71E459A for ; Tue, 27 Sep 2022 13:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1664309357; bh=Z8k6KNfxmofAulBiJEk844o4bSszlNFVmtrbKWlkLuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=sZEX/6YMb/63KSBUzzGgu0L16tLj3IxS2/5SKuR+qKQUvl3fZD2J3NPUhcNUyJiNNiSfb53n+DzES7KY5YsHS5Q1TDRbA/hS1YpJENHvpOAtFqIYH32Wmnado1yIN44444+RB/R6filq7bgLYgNv1hEHnU4jOBe9s0JVUbinhDPfB6iSCqLY3G11Yu4RR1g3LIQO3KNrPPfxTde6TGNWgwY01kvVLaViB+1BgqLT14anL3LyzSeKwzMnXvys1/k9+qciaK6EgdsPexTl1dsAeOVccnKrx8IQLjb3svZbWHlUBXGJpreXv/MnT7yWxL+AO951ID4ebvQ3EdnEidt/jg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1664309357; bh=bho2X12oNS19WM5/1W3KAWaCNq34D62T/6fZvoQaCmd=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=sLQgZFH4XhMVxWLEUa1l9wD5HnrXJEtv84Nf92dmxHn8PNLVUR1akBgeFwDWoLoWUYY7MPbzxCOszGrLDg9z1/7DnEYFhuuWbFL6vgtlOCF+jd1LkBdn4eEpr32VmXtkLlShCcc4VEwUDsMCuJTw+IyPgbtA2jwBTkUYynIxKL33fXOa3Mng7ue2SQZyZ2mcrspjIBsExSfDc0ZfbgyqMNAu5mRTYpbAvAIjlsJ3KXDmpee6NWh74cVsACW57WLJaWWK/j2RSa8qnvFIULW+JcBGFYcp1UyTVM/RtHKmNzMBV4n8PHb5iP1egJR/VLcBu7s2uzteKDdOx7HusVkX2Q== X-YMail-OSG: epppJwEVM1mZ0L.s5YTCarJ4gFo_xdBozrarhW5yrNFJWVy6ap4pLmGO5lmXIiz _1Gfw0zzWRWoMLKDWr7AWHzho_BwnQ06ZYleH3Hm0CQvKax4ZTSVAcg_ICXRTuSk8K713ARIIhYz BCkA4VtWN6SEFitQnJ4ali2HD.BPfwt7ori80uWQOAna1JXohxEa3Ib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S6x8vGJ5IC_5GjS2Ntsd 6cROSt_ws6aJUZAA8ahiJhrB5Hf_dIMVPfE7QQA-- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.ne1.yahoo.com with HTTP; Tue, 27 Sep 2022 20:09:17 +0000 Received: by hermes--production-ne1-6dd4f99767-x2f2n (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 962ba498c220faeab9c55c1f2e7ba390; Tue, 27 Sep 2022 20:09:12 +0000 (UTC) From: Casey Schaufler To: casey.schaufler@intel.com, paul@paul-moore.com, linux-security-module@vger.kernel.org Cc: casey@schaufler-ca.com, linux-audit@redhat.com, jmorris@namei.org, selinux@vger.kernel.org, keescook@chromium.org, john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp, stephen.smalley.work@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH v38 29/39] Audit: Keep multiple LSM data in audit_names Date: Tue, 27 Sep 2022 12:54:11 -0700 Message-Id: <20220927195421.14713-30-casey@schaufler-ca.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220927195421.14713-1-casey@schaufler-ca.com> References: <20220927195421.14713-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,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 accommodates 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 ca00187b4864..e8f632736d2b 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; @@ -1564,13 +1563,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 { @@ -2278,17 +2276,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 = lsmblob_first(&blob); + security_inode_getsecid(inode, &name->lsmblob); if (flags & AUDIT_INODE_NOEVAL) { name->fcap_ver = -1; return; -- 2.37.3