Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp210249pxb; Wed, 4 Nov 2020 20:04:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpGGeWNzXFiBMoKqotVfNvBs+2VdCO2JMrxdG77bvSrg9ca3JsCkln+PbB2eEZPMCXzL/a X-Received: by 2002:aa7:cd90:: with SMTP id x16mr622842edv.302.1604549064753; Wed, 04 Nov 2020 20:04:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604549064; cv=none; d=google.com; s=arc-20160816; b=jC2P/4jHviGSRJfEeFvYWdxnnT76sIS7w1sR/W5wjxvh5xPVQAYhCgWoaYYL7sSxJt P0xfvbXiEKD03b1hRMSwpE7gZxRUk7KLW/Fl8LN99V5t1RfienlUY+JrtHoQzsjLN9Ty eiqX5eRfPa1kPH2gp835uC8eBnJ++Ybu69+BH/HmtHgegQ54YcrdC6BAV3PO+ShMChbK tuJc5MhD9afd9JjVYIfwbbHWU3wxfBYBXEItu13uEoCEzxIdreVNuu9hRhvdvzr+XxgM 1/PRqgYQZIA3pjnYfTTy5cc6UcP+ryX4COs1srpDiFNVhz9hm+LEDv0W43PIf5YN99MH AExA== 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=U5bKWCQ1u99Nru5o24TB+6IKzAJnsO7yXV4aGiXz6j8=; b=Bd/uIy8+mOnTJz/VWOmAe2uIu5akJDjyAOgdzSTDN04sg1bAxW6OPQ7Ffv9tHf+tpt Higo51fY3V1HXwXGDgIq9bhDJHyC1Qr/TKYwuBYzIwHwUXANeRHTSMRwrKxNFr3rv4eA TGPj34lA2LYBCpvJqajiYfenfapmcsDH0v+QPAhI6BWQI06z0gQfFqXkIkOrClJHNTW4 O9M0w67G2mjdQCXpqase+tIJ/tE1I3PzuFPGbMXLXVwTpo6z9UiXpbdr9j+lW2Pj1YxE Np/CrHnn6qnOnkYW/C6JlUnZ8+UysQiWvYTQlP7mnho7WAbIgFRhqQRFdTPdGLPPh+BQ I3Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=CfZFa4At; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v13si426567edl.552.2020.11.04.20.04.02; Wed, 04 Nov 2020 20:04:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=CfZFa4At; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387922AbgKEA5p (ORCPT + 99 others); Wed, 4 Nov 2020 19:57:45 -0500 Received: from sonic313-15.consmr.mail.ne1.yahoo.com ([66.163.185.38]:39379 "EHLO sonic313-15.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726604AbgKEA5p (ORCPT ); Wed, 4 Nov 2020 19:57:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1604537863; bh=U5bKWCQ1u99Nru5o24TB+6IKzAJnsO7yXV4aGiXz6j8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject; b=CfZFa4AtkOxc9/v1plpCg1CMq7ETS/GY3o+nUgeP3xU+ybAhbQsHu89F3Xnt3sWF29KZWejMYPKUqAUgx1mdIBfX+hlI9OCuyLvzycP4TXE48Zxd5OhmGEfihsdXC6YYBTRSZkcUDb1HhxZhzuc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9Bi_R9BUR9_X1DtuRp5zjAfv JELVM07LoXh0pEOUrR2WpawauIqAm7_aDRxcDLQZymXoLcp8DGhwBONhAzQE8Km8W5_IJpR07otq g6a6hV.zoLIXj1kJD9Vbbku4uSqgFrD8JFUkL7_X87r18RGRMBABjoiRfmq9wRz5vl9cKut7_T.H vmWjO1.xKrH.bH.2syaPu6mH6ZAJP3H1NDeq.xGwmcWynIWlXw5xoYDjEVXjfxk.lSlARHDYYW.J hqwNTOBF8Xxm.YfTYiToNkA6FjkkDfcULsgKdhgFYpztGLdmRv9wBWGy3VssbFMm0J3XtgrMZTNS TqqGoNKQ0lS2.p.HcpB6oek8j3WM_K9ZvHVRpGJR7ZuuRF20uN86bvSryBUCxQ4KTFpFlbOu4BBv .j4QckGZOuAMdq6XpNIv.J6oMVOafItJmasWsJRhfDhx1zweaUTjZnxDAfqS2gaVgfZid1K3g7AW Yjm8PZrAj8J_3saYK48oknhVBokp8K0pJcE0Xzno_2V1S4qxSRgy__6qBhr4KWpFCu1JTMp0dA_d yjQq98SsEPfK1D8TMb8hK9_BuLhgOBSGhcKlCIf8mgIEwH9psZJIjLAlXTmaOGHQjWIMMkAEROJu .qJ7gFBcxEOm7_A4KclEakIhM7qauqR8SSAlf_O2R_7BkYSdesOpZypX80o9gnn58YMzG_gOew4L DPjcor.JIPj7QFUi_TTuPPmFULIgumU8jRw6odGIbeVL1aOqRcRx8zCPA0tQLZFPha61mkpxHWJ7 fp.WRhuYbbb50YEfML6YW1FU.M6OJ3xOkBiqLhmwn3olh_SjHi1K0Egn_HNDbueUVH4d_.jQ6hju wenYF Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.ne1.yahoo.com with HTTP; Thu, 5 Nov 2020 00:57:43 +0000 Received: by smtp412.mail.gq1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 0f801c19fdf8e714d7c3077c3b87be14; Thu, 05 Nov 2020 00:57:41 +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, sds@tycho.nsa.gov, linux-kernel@vger.kernel.org Subject: [PATCH v22 07/23] LSM: Use lsmblob in security_ipc_getsecid Date: Wed, 4 Nov 2020 16:49:08 -0800 Message-Id: <20201105004924.11651-8-casey@schaufler-ca.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20201105004924.11651-1-casey@schaufler-ca.com> References: <20201105004924.11651-1-casey@schaufler-ca.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Length: 3548 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 fad361bf320e..be8db737da74 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -499,7 +499,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); @@ -1228,9 +1228,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 5f9bdd62f78d..35d6bd0526a2 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -2341,11 +2341,16 @@ 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 ea927a00de18..9c1098ecea03 100644 --- a/security/security.c +++ b/security/security.c @@ -1882,10 +1882,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.24.1