Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp110178pxh; Thu, 7 Apr 2022 15:35:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaOrWZj3z3P1KtaoPkofRGRphG5J7HVqkDooeFU0pkGwXesvbsTx9gFAdToUjRX3mKAGRl X-Received: by 2002:a65:4503:0:b0:382:aad5:ad7d with SMTP id n3-20020a654503000000b00382aad5ad7dmr13058023pgq.488.1649370947234; Thu, 07 Apr 2022 15:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649370947; cv=none; d=google.com; s=arc-20160816; b=OowgEr9I8m6uglGbrHwIkndOqPjxjeKmHuLK6d0JQJjX+YPNZJGFpzW9pBmsB7JrL7 OcznYGVrd1hZqz4dhZbN0wVVrK9Rokyc055zatvqilPE6iCAJJDnZfAdHizVEAd+hC/6 UbJbSQxK2JCGNsQu97xTdM/bUQPiuVkZhMYHxUax0bfYhHreeth+wmlB+1nokBRqV031 NsBEC8PSVxTpLsBYGsVnN5Sl4PydpMfiR2wSWJpo4cgW4J6nrb30dVuZ5KRnljbe0Myc JarZpyoKi14slHmBcGDz8tjVmolof/gRi6t7zQeIr32UN0/AnMjfobBROOT00wY3USQz wbww== 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=BtHo1QSoNl0+JSUijRm0h7RCZJK8XQ8GDtQ9CbzS1Bo=; b=HRS/kTFhp+0qvVh47z6VxL8Sojdy3P+pblCEq/pnVaLvyb81puanZF4YNwjX3MwFHS E1twckQKNQihaTEkAe7ZISIymUG6N91iiHANZM+/mvzK4NXfMtykHiamTXfySyZHNehp tf2onpEluu6uhvskwK+Prfjr5L76wBXlEokTmcEPwwj4my7JESkW8ENGORxAJOM6JdiS PU1GgkFRacIUlIrURYGi9GbR/sjUU+iFdWCCMwvTpHRTYy1amRK5OOG3IAH9tbSPYrbe QkNitt3kGopVnUfBu5WgHCfohg4BF0R5jiYxGp4iPb4n/huzw37+rRZI7c/NtLOai1Dn ZNKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b="L5/tabTZ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 4-20020a630504000000b003816043efe6si7458448pgf.475.2022.04.07.15.35.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 15:35:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b="L5/tabTZ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 9EBCA1A3956; Thu, 7 Apr 2022 14:28:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231472AbiDGV3z (ORCPT + 99 others); Thu, 7 Apr 2022 17:29:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231363AbiDGV3p (ORCPT ); Thu, 7 Apr 2022 17:29:45 -0400 Received: from sonic311-30.consmr.mail.ne1.yahoo.com (sonic311-30.consmr.mail.ne1.yahoo.com [66.163.188.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DE7119F449 for ; Thu, 7 Apr 2022 14:27:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1649366863; bh=BtHo1QSoNl0+JSUijRm0h7RCZJK8XQ8GDtQ9CbzS1Bo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=L5/tabTZHLYxoHwIhJH3sxIC6GxQ6/JovdjnGvJeJbu92BX2QCdtKAkCETyopZGF0VkOHd/pyBTi8TN32b9L1GRMsfbEOwJwYZYpRuT3IkqaXcwD74DE4wmfwvePnjkn8naimo2Ad5CdTECTfXIHkBYTRQniBea/GoIIZmzSE4v2DSupRMq2nWTSJzAt9Fg0vqwoTTF5mFs2hsgJakzKkrB9T3c++6zyL4m9PXt0YTuRgwYAUd3CSNnlp2kTUv+jCD5sWT4HKs7v7H95vUh896hfcLElojWNB2grl5YjAVgovjiS7rcNAvsKc8wHntdC+bODvJOM78+ciTNkXA6Wpg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1649366863; bh=MaplFYysY+Ah6wLWvXWiiUfk1v+Yzl4T7nKlrOMurRT=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=bES03OG9ytk0efQ4V5+3XpFZ+hCirgTiWrn88Eo7iE8YMYMyQTVYULZzN0jPmgUaVKwrzB1tsB9KxqB9Dlt0JUOWNEB3KCSD2glkgJGgH0GrSzvM7M4/Y3B9iP9B0oOm1QXfemxtHx1U4ZSCtQNJpeJkf6HQwlDuFEWa1JawH5D1URyviN0VX8Dnd5Geeh3hQy79E9XT4Hno5HxgILo4WBJ2Lmo0mEWFkcoallNX635esXzQGiTlx2GWJOeBfhfjr1HMLAOO+vBMFDpYuBL1jAjmNCePcFPjCSn5k7GnQpFT0dCFY727Mzu2wgS7leGLE5Bce8NrqAM9HidIb286kQ== X-YMail-OSG: 2hMF8DYVM1mCaZQV1y9TAXEVk6dJyqLgDs9y3Dmr1tSazuX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p9 Q2gp26tikvJhBswa5hxIs7lhzgyeMdX2iMLef1tIZ_kkXXwMqEle7fYvXl5wkWhbdr.N_TnIcvSd 9bIzhSDlVwlLoGOlwSLVOL8nYFOl1AaFqyC1ioFyzdavd9CqH7H5PnseiDtvdO.I55zKCUnS1BAV pgasvDai6F1_E8H1.RrwesjvsZo.dEIA- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic311.consmr.mail.ne1.yahoo.com with HTTP; Thu, 7 Apr 2022 21:27:43 +0000 Received: by kubenode522.mail-prod1.omega.ne1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID cdeff4c1363a36af98b9100857bab95c; Thu, 07 Apr 2022 21:27:40 +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 10/29] LSM: Use lsmblob in security_ipc_getsecid Date: Thu, 7 Apr 2022 14:22:11 -0700 Message-Id: <20220407212230.12893-11-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 There may be more than one LSM that provides IPC data for auditing. Change security_ipc_getsecid() to fill in a lsmblob structure instead of the u32 secid. The audit data structure containing the secid will be updated later, so there is a bit of scaffolding here. Reviewed-by: Kees Cook Reviewed-by: John Johansen Acked-by: Stephen Smalley Acked-by: Paul Moore Signed-off-by: Casey Schaufler Cc: linux-audit@redhat.com --- include/linux/security.h | 7 ++++--- kernel/auditsc.c | 7 ++++++- security/security.c | 12 +++++++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/include/linux/security.h b/include/linux/security.h index 4f940ef06e51..4646ca90f457 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -520,7 +520,7 @@ int security_task_prctl(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5); void security_task_to_inode(struct task_struct *p, struct inode *inode); int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag); -void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid); +void security_ipc_getsecid(struct kern_ipc_perm *ipcp, struct lsmblob *blob); int security_msg_msg_alloc(struct msg_msg *msg); void security_msg_msg_free(struct msg_msg *msg); int security_msg_queue_alloc(struct kern_ipc_perm *msq); @@ -1277,9 +1277,10 @@ static inline int security_ipc_permission(struct kern_ipc_perm *ipcp, return 0; } -static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid) +static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, + struct lsmblob *blob) { - *secid = 0; + lsmblob_init(blob, 0); } static inline int security_msg_msg_alloc(struct msg_msg *msg) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 10b9dc253555..d125dba69a76 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -2662,12 +2662,17 @@ void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) void __audit_ipc_obj(struct kern_ipc_perm *ipcp) { struct audit_context *context = audit_context(); + struct lsmblob blob; context->ipc.uid = ipcp->uid; context->ipc.gid = ipcp->gid; context->ipc.mode = ipcp->mode; context->ipc.has_perm = 0; - security_ipc_getsecid(ipcp, &context->ipc.osid); + security_ipc_getsecid(ipcp, &blob); + /* context->ipc.osid will be changed to a lsmblob later in + * the patch series. This will allow auditing of all the object + * labels associated with the ipc object. */ + context->ipc.osid = lsmblob_value(&blob); context->type = AUDIT_IPC; } diff --git a/security/security.c b/security/security.c index 6e6e44213d80..131c851dd681 100644 --- a/security/security.c +++ b/security/security.c @@ -2012,10 +2012,16 @@ int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag) return call_int_hook(ipc_permission, 0, ipcp, flag); } -void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid) +void security_ipc_getsecid(struct kern_ipc_perm *ipcp, struct lsmblob *blob) { - *secid = 0; - call_void_hook(ipc_getsecid, ipcp, secid); + struct security_hook_list *hp; + + lsmblob_init(blob, 0); + hlist_for_each_entry(hp, &security_hook_heads.ipc_getsecid, list) { + if (WARN_ON(hp->lsmid->slot < 0 || hp->lsmid->slot >= lsm_slot)) + continue; + hp->hook.ipc_getsecid(ipcp, &blob->secid[hp->lsmid->slot]); + } } int security_msg_msg_alloc(struct msg_msg *msg) -- 2.35.1