Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp694948pxp; Fri, 11 Mar 2022 12:36:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6cZ/+m/evzZwMV9AEW33gjqvuWOpv5HmKFaD9K4zdNTicOZAOYWcQHrp4GRa/lAO+pv4b X-Received: by 2002:a17:90a:5148:b0:1bf:cf3a:6751 with SMTP id k8-20020a17090a514800b001bfcf3a6751mr11306573pjm.82.1647030993007; Fri, 11 Mar 2022 12:36:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647030993; cv=none; d=google.com; s=arc-20160816; b=abO7orcfnesw7Xpn1XPTAfjMnnerVorFA7ntYDu2O1Fo/XDiGmugZ4BiJmDnOGylUE Km2uYVW1qHOeDaQPKJ50lHWZ+FLMHtif7yjGzN4yEKx/q1XPsGnQt34qiToZGpVIb5bU CSrCODqZY7K/7N/ihg9K07lEmqBtgiMc3yU/acc/xuZ9aBcOwOEN1qAn3PLu43ovLIlU i5KeYZ9WQWS3gUOQnb8mYfK8TedkviExbBNpUTIyMn6Yl7t4TRGtNbifbQxrmE4FUJs2 65JGK5AsGG3AaTI2quorgM30+dBGKHemCl+JCpXZN04KHxeA/wClyVpSMvCO8t+ismmw Kr+Q== 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=vgO//PFYDezNojD/b4WOsqsxvAcTkDNEtP0WkzWCjT4=; b=uaC2tdViTg1H8xoOnf9I1vyNiHFZzfXeLABHw2UvpjelyVNLv6rM0m/TbMe2BGv456 IhDdo3DPc3G3W+wDM4nkcSA6zjc8pwJHjeaq/3+XD+c8REse4HdDcCA8T8fRaviMceR3 nFh7UuGftnL9b6CB+073cx+RCEVixS6z2KlUazmTvqYd4CLnc1dJQWIAEvvn3pnmsfGP YeNZUfLnMEiNwVFugwlfKQ4Pry29tfQGkkspjrH1PzII9rQXk1RxuGe2M4oc7jkdFPA1 MCLvSl4DdCox2vTUfqqtv5jp8joXdFz45kmxG01rZSaGVoqXWPLM2ZWoDDIhNbGr7v+Q pIZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b="eA/IpXYl"; 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 128-20020a630086000000b0037c714b60b2si8610052pga.465.2022.03.11.12.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 12:36:32 -0800 (PST) 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="eA/IpXYl"; 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 E64611CFA20; Fri, 11 Mar 2022 12:36:07 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345044AbiCJX7N (ORCPT + 99 others); Thu, 10 Mar 2022 18:59:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345030AbiCJX7F (ORCPT ); Thu, 10 Mar 2022 18:59:05 -0500 Received: from sonic308-16.consmr.mail.ne1.yahoo.com (sonic308-16.consmr.mail.ne1.yahoo.com [66.163.187.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 791225F4DE for ; Thu, 10 Mar 2022 15:58:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1646956682; bh=vgO//PFYDezNojD/b4WOsqsxvAcTkDNEtP0WkzWCjT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=eA/IpXYlxN7FaAJKltc0323QG+pnB8rwJcKw7eBCfiNUQjct104HQIEnmv8FngIWL1nUJuAN986xR/TGVuRicolLxcCvp/rVULygTDqb0CZg4hUbfBvk6iHC6jatcq4iXNcbwm5cPke/tOXT69lFdeWfuYD4m8TUnN8MY+vRaL/8YkaDdOjeC3NeHPIfRyg6wd21CJly/STnwauZbSXaEb0EcFukCX4qSW6yknMJw5EdePzMlM3VNh8qfIEmmEvRTY+uJKBXJcGYDc2i8m6gU5ipG4bnfZOiN346oOB5TizNZHpxGyHBWKcaoX1RqUHD+0S/g1VahaSlgOp73BjqDA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1646956682; bh=QeAKXrHutqGOEC52e+GlO1m/pSV3Kse9tjSES3QeLzV=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=Ao0AYVn13hCVnKezqkERjeh/qFfptUzo/hNwms2KDHpkXPcgG0cSX8ByOqImyglHLfhu6BUFEg/g2zNxhpYxTFL+bwL4B5QAYALdDHHjkM31tjxAS35NzGwA4J5b5uMXbg7oo+rgj8ixQeq7S2qsHuobrCOMQ5xHpJ/Zw8fpi2hDYQX9w+q7QeRV4YHRb6Et5vcW1YuOlwzCts2JN2adktYauQdSatCMUzDKg4gGH7SasfHVJyOiGaX69vBokrJ0N1ceFQiwV1fhKNF+hgTCXlPz7CCsmdoLdPm5E4toGWylcOP84+Yso6yWFcGfeyT5vTfez0RY5S1PX0hKzli31g== X-YMail-OSG: ffF50pAVM1m_JFZkzp8s088rBK3QE.AN_MjkNcsXIDmVvlP9j9xR5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4_.T74xBAIFkh9QpEl67bhnHrkL1D6yymGJRRfyyqxgo3qLjVbepr_9e8L6cv_KjEWDxW9PYpGHt 74pb36U2hWZo38g7o0JRb1z5GkM0To7SHtVnvzCDopVfqCGweWh8- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.ne1.yahoo.com with HTTP; Thu, 10 Mar 2022 23:58:02 +0000 Received: by kubenode526.mail-prod1.omega.ne1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 075078af6eda9fc0a8c4174c138d83b1; Thu, 10 Mar 2022 23:57:57 +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 v33 22/29] Audit: Keep multiple LSM data in audit_names Date: Thu, 10 Mar 2022 15:46:25 -0800 Message-Id: <20220310234632.16194-23-casey@schaufler-ca.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220310234632.16194-1-casey@schaufler-ca.com> References: <20220310234632.16194-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 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 e091d03f9184..47d34433b91e 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; @@ -1537,13 +1536,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 { @@ -2245,17 +2243,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.31.1