From patchwork Sun Jun 2 16:50:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Casey Schaufler X-Patchwork-Id: 10971861 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4761118E8 for ; Sun, 2 Jun 2019 16:52:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36E0B1FF40 for ; Sun, 2 Jun 2019 16:52:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B6102873A; Sun, 2 Jun 2019 16:52:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B4F6286E4 for ; Sun, 2 Jun 2019 16:52:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726940AbfFBQwM (ORCPT ); Sun, 2 Jun 2019 12:52:12 -0400 Received: from sonic303-27.consmr.mail.ne1.yahoo.com ([66.163.188.153]:38099 "EHLO sonic303-27.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726957AbfFBQwM (ORCPT ); Sun, 2 Jun 2019 12:52:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1559494331; bh=affcoRY2PaaUmEgcqS6C9HybTLSyjRteSCEEdycSbI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject;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bJaDuEmX6.rSAF1gJrB6o8WL uRmayjqEvhVjIAyWyEv92ArwGGLHdjZQqn2tJpn_6pfLgR3mKOvAALURYRlWeB37W4F33rd93yQi HywScIEaBiBrVVP0nSsZLyNOELNA17JEzBk2iu8I3YJ_b7gUSz8pAljCLO5AUZli21KpgNmKZmBe l8OpNtUrk7O4hHqCydcJ1m5qlqqrLADh2HblUz2yrqA3RslQYBmquWib7vrNhBdY9cqHOHDxb7lY JcgiL9hqvVPcnvSG.aheweGhaL4hPe1mxIQIRadwT6ocLQNRxpTqplN91Srsy9wFOBmO7unI3x6R IQnd0lVFaAk4lQydRVEt8FlBCEo9tRulb8rwTNxQW5AKFDBeaXVzsGn58AIyi88TgyVhNEDmiFm4 ZaylV87mozqj2EtWVge9._XPSf4zSYYRHr6QhSuOI46ve3mJ5JWjPrlMcjsDySzx55ys1F0t8vdL i23FIdesTzruaqgY8wgC69E.JAHJIewXyteHahq5zs_qbbXeKsz7fk8jpXYqIPsdjI4tomRW2kw6 TfstI7pQSp2EFFjoDrOEVG5AXgGn9e9_1u091gOFPJKqlz4WnZoh_ANs060o- Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.ne1.yahoo.com with HTTP; Sun, 2 Jun 2019 16:52:11 +0000 Received: from c-73-223-4-185.hsd1.ca.comcast.net (EHLO localhost.net) ([73.223.4.185]) by smtp423.mail.ne1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID fe9f27128ba4a09bc4aa17914eac4de2; Sun, 02 Jun 2019 16:52:06 +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, keescook@chromium.org, john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp, paul@paul-moore.com, sds@tycho.nsa.gov Subject: [PATCH 18/58] LSM: Use lsm_export in security_ipc_getsecid Date: Sun, 2 Jun 2019 09:50:21 -0700 Message-Id: <20190602165101.25079-19-casey@schaufler-ca.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190602165101.25079-1-casey@schaufler-ca.com> References: <20190602165101.25079-1-casey@schaufler-ca.com> MIME-Version: 1.0 Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Convert security_ipc_getsecid to use the lsm_export structure instead of a u32 secid. There is some scaffolding involved that will be removed when the related data is updated. Signed-off-by: Casey Schaufler --- include/linux/security.h | 7 ++++--- kernel/auditsc.c | 4 +++- security/security.c | 8 +++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/linux/security.h b/include/linux/security.h index 5cea6260bbd9..6ac48c7c4a41 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -411,7 +411,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 lsm_export *l); 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); @@ -1096,9 +1096,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 lsm_export *l) { - *secid = 0; + lsm_export_init(l); } static inline int security_msg_msg_alloc(struct msg_msg *msg) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 83aba0336eac..eabbf78fee96 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -2266,11 +2266,13 @@ 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 lsm_export le; 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, &le); + lsm_export_secid(&le, &context->ipc.osid); context->type = AUDIT_IPC; } diff --git a/security/security.c b/security/security.c index b6a096be95ac..6ba1187c9655 100644 --- a/security/security.c +++ b/security/security.c @@ -1775,12 +1775,10 @@ 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 lsm_export *l) { - struct lsm_export data = { .flags = LSM_EXPORT_NONE }; - - call_void_hook(ipc_getsecid, ipcp, &data); - lsm_export_secid(&data, secid); + lsm_export_init(l); + call_void_hook(ipc_getsecid, ipcp, l); } int security_msg_msg_alloc(struct msg_msg *msg)