Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp25892lfe; Fri, 15 Apr 2022 17:46:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFK5mcoht2hznBk6obHEgSXuy/PXwMkEYIFVAVbG1kavTo9CPktTiLkXHo55Pm+8bDiVCR X-Received: by 2002:a63:fd53:0:b0:386:66d:b40c with SMTP id m19-20020a63fd53000000b00386066db40cmr1174965pgj.266.1650070011993; Fri, 15 Apr 2022 17:46:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650070011; cv=none; d=google.com; s=arc-20160816; b=y6bIKjUUf2VVz+37PfpaJNH98VHc6dgEmzO2n4Q2gcF48OcoMZarhF8NDFujpBd+9t MTg3ndY9EAjPaSUwhHUVj+hcMLywHRWJl/lm6PVtEptHe0GKEh2oLr4NLbiZRFmsnker KzG9X3BhZ16+4cXar9HzdbBA9PVtGJuh9wieSWx2ZOFkiH2C1FcPd/QW457MQYH/pG5j KFtYPlQjx74emb2veVBpbhFwdApw3tJSXqARtsX3N7EzpjqJwMi1P9zNzmfwqPMsjTos iGO7Lit1q5akd9SoYju7kUouXg9LPZ7ebgxesQZ7Cwyfge+cOhW+uRhBahjVje/6hAWW q8DA== 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=Pw8r3xiqXUWThAHmPbR7HRzK0xCeeXx+xYWuqGjM0IrjDugDw5faDYuZV3tHqE8Lh2 EfMvj/Slo8tI/WNdnbaiJ5bIb/w9hQeDgl+aT69UDQAGY/tXiHJgmZTYZIc5+noLQS55 Lc+d7hIge4pL8AjQpY6qgUz+0Wj8mOfkosL8lYFUxi642p52fet3g3JORih9n39jcKwv tJ2Uj+QExxZxDxO6klffLXGgXZU9cmGNBI8WCqWCh8cXWffAZkbGAUddhJbrbXtoex9f a44yYkBJkyeJJzdxxBXlO7t+oyu2tdDMbrAssMoip4gQCL3SBd9hUaQJTE6wuXrKWbkh MP7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=WELmHADi; 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 g8-20020a056a0023c800b00505cdd19af1si2852546pfc.51.2022.04.15.17.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 17:46:51 -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=WELmHADi; 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 859831AF3D; Fri, 15 Apr 2022 17:38:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355292AbiDOVcW (ORCPT + 99 others); Fri, 15 Apr 2022 17:32:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355240AbiDOVcQ (ORCPT ); Fri, 15 Apr 2022 17:32:16 -0400 Received: from sonic317-39.consmr.mail.ne1.yahoo.com (sonic317-39.consmr.mail.ne1.yahoo.com [66.163.184.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DED7C36310 for ; Fri, 15 Apr 2022 14:29:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1650058182; bh=GCzw8AbIKSF767bZWFoiVd6qOcKopRj1eBVPCUHsTtQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=WELmHADivsuv1YI6hCn4GOFbB0UC3X6JYp/cHsj5hlhq073Q0cmqNqgtsWgGSozZpM9a5rDd9F2LOiMzbzQdWnTZvklAgR1nu2I2Xo7vT5tx/wAND81BeRY/FHFqlx6w071gJbFxbMAOAzJk9i0/MrPTmPAp7VSWc7JX7TZI/epblzvP0kdRy2MCMPcxHrRQgH0crqGywzfwAUwOYqaVGolaVuw/unEYVkvcgp3xaip8eR0N12ovFedXSgJ7M7tDJ8iIxyj3Gc9TUbFdAGBtjj73lhosC33MvdO/rv8C+CTaXRQrpNuNXhuOlGpAP2L1gO7f3G7CfnltqtH9K+/azw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1650058182; bh=BMGsZGShAkqoLzf+QVjAtzLK4oVuzlNfEfrpEFPG+3n=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=OSyLAxUz/iazZRzXdCxwRUJsYzZA0uAB505QhV0KJNVT5V3IOyvr5Nse4EjMCZgGhNX02WbqQcWl/3V8mRVAt6+ZtlZHjCz4TwRGYV9OyFeN9URXD7tm6eQqqhVWq3++5ts2UA+ytQcaPzVZXGYFf/2QFsrKsVObWuYO8DuTVVDJ1tls0Csh3xlnelS1NZMUc7sirK66EhwmfJcW6GTWH+Y5ltRcQ3l5scozgYdsqeO7anyoWWEQihCyTbhgYIEpqjEjfsx/1rtZ4EiprhS7UwfTSyF2DTKV6FxMcPItxcPQhveF+ivzn1V8c7grD+dYBIrl2SVlG0woHJdHw/AzQQ== X-YMail-OSG: LZNoxqIVM1ma.qpLXdNWgMZiXzc9RromagQ0lsRcrVB4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lzGUhiacnsE8k8eky8c TF5o6y2mRTLKh45M5rVvO_R5gxwZRnQdZ1MTrGZRRrB4YkiYA9D08.r1uUcMiYB4ZTwH1n1CGdp_ Xu2imDafF6rnN4G30D7_HMgew_BVGRnwuOmMd5rAlwcuBi6nQ5HPaGdADg2LmR0QhDTwgBghEI.L cKhoG X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.ne1.yahoo.com with HTTP; Fri, 15 Apr 2022 21:29:42 +0000 Received: by hermes--canary-production-gq1-665697845d-l9qwj (VZM Hermes SMTP Server) with ESMTPA ID e13e266d8c7792b63d16d18d4175b5aa; Fri, 15 Apr 2022 21:29:39 +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: Fri, 15 Apr 2022 14:17:54 -0700 Message-Id: <20220415211801.12667-23-casey@schaufler-ca.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220415211801.12667-1-casey@schaufler-ca.com> References: <20220415211801.12667-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