From patchwork Fri Apr 19 00:45:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Casey Schaufler X-Patchwork-Id: 10908435 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 D03701932 for ; Fri, 19 Apr 2019 00:48:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C158D28B1F for ; Fri, 19 Apr 2019 00:48:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5BE228BA0; Fri, 19 Apr 2019 00:48:02 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 5446E28B91 for ; Fri, 19 Apr 2019 00:48:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726884AbfDSAsB (ORCPT ); Thu, 18 Apr 2019 20:48:01 -0400 Received: from sonic308-9.consmr.mail.bf2.yahoo.com ([74.6.130.48]:35477 "EHLO sonic308-9.consmr.mail.bf2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726906AbfDSAsB (ORCPT ); Thu, 18 Apr 2019 20:48:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1555634879; bh=TM2ZUN68jEXypRJ0f+YHN9yBHBRv2sOZZODRyMmX3oI=; h=From:To:Cc:Subject:Date:In-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QV6EGZmMI2JEtqjbs9JnycglOfnjatHmOQt0B32ooNfW Rq5XSX3NyQM_80bifAT_AdiLfd_sXCDp3qkiYGwyBHdTc.zHDKsP8psyFsP_0BQarjVq_Nvf4A0p l9Y7CR.q4eLPE0t4H6b9zVpCts25oJrHbpy6ySaoG3R0XokIbR93czW.axRv7b4gbFpbNv4hGvCH zTeDoaikwABQdAKsRtLx7qW1eKP43IUfANO323bOij9lb2Pn_YEiebnn9rBCBggepZ7b.Kwf0WC9 2Jw2a_MnGpa08i7lgIqYQx497PVOzol34eB7e9kBiejvAr0PZ.eLKLiccsFmxZnsfvyNxTBzs_yW rn10LnKMSyds5lA5S4S9H5M0oB_Ojfc0yIJ91BntEesgWCDiaE00efXVC_sAdWYyD2xLAOpUtKc1 gF1BMle.ivMjaHyeFr024oJ7gU4jwXTKU8Aw.X22ZqH.X2X._8KnjdICrYFqkbTs- Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.bf2.yahoo.com with HTTP; Fri, 19 Apr 2019 00:47:59 +0000 Received: from c-67-169-65-224.hsd1.ca.comcast.net (EHLO localhost.localdomain) ([67.169.65.224]) by smtp422.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 9312487679b1d62a89b866e0f3ee025b; Fri, 19 Apr 2019 00:47:59 +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 Subject: [PATCH 43/90] LSM: Use lsm_context in security_dentry_init_security Date: Thu, 18 Apr 2019 17:45:30 -0700 Message-Id: <20190419004617.64627-44-casey@schaufler-ca.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190419004617.64627-1-casey@schaufler-ca.com> References: <20190419004617.64627-1-casey@schaufler-ca.com> Sender: selinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Casey Schaufler Convert security_dentry_init_security to use the lsm_context structure instead of a context/secid pair. There is some scaffolding involved that will be removed when the related data is updated. Signed-off-by: Casey Schaufler --- fs/nfs/nfs4proc.c | 5 ++++- include/linux/security.h | 7 +++---- security/security.c | 14 ++++---------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 4dbb0ee23432..de000649f9f3 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -113,6 +113,7 @@ static inline struct nfs4_label * nfs4_label_init_security(struct inode *dir, struct dentry *dentry, struct iattr *sattr, struct nfs4_label *label) { + struct lsm_context lc; /* Scaffolding -Casey */ int err; if (label == NULL) @@ -122,7 +123,9 @@ nfs4_label_init_security(struct inode *dir, struct dentry *dentry, return NULL; err = security_dentry_init_security(dentry, sattr->ia_mode, - &dentry->d_name, (void **)&label->label, &label->len); + &dentry->d_name, &lc); + label->label = lc.context; + label->len = lc.len; if (err == 0) return label; diff --git a/include/linux/security.h b/include/linux/security.h index e12b169deed6..6c3a74a44a59 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -302,8 +302,8 @@ int security_sb_clone_mnt_opts(const struct super_block *oldsb, int security_add_mnt_opt(const char *option, const char *val, int len, void **mnt_opts); int security_dentry_init_security(struct dentry *dentry, int mode, - const struct qstr *name, void **ctx, - u32 *ctxlen); + const struct qstr *name, + struct lsm_context *cp); int security_dentry_create_files_as(struct dentry *dentry, int mode, struct qstr *name, const struct cred *old, @@ -674,8 +674,7 @@ static inline void security_inode_free(struct inode *inode) static inline int security_dentry_init_security(struct dentry *dentry, int mode, const struct qstr *name, - void **ctx, - u32 *ctxlen) + struct lsm_context *cp) { return -EOPNOTSUPP; } diff --git a/security/security.c b/security/security.c index fa0500b2c15f..649fd13cdda1 100644 --- a/security/security.c +++ b/security/security.c @@ -1014,17 +1014,11 @@ void security_inode_free(struct inode *inode) } int security_dentry_init_security(struct dentry *dentry, int mode, - const struct qstr *name, void **ctx, - u32 *ctxlen) + const struct qstr *name, + struct lsm_context *cp) { - struct lsm_context lc = { .context = NULL, .len = 0, }; - int rc; - - rc = call_int_hook(dentry_init_security, -EOPNOTSUPP, dentry, mode, - name, &lc); - *ctx = (void *)lc.context; - *ctxlen = lc.len; - return rc; + return call_int_hook(dentry_init_security, -EOPNOTSUPP, dentry, mode, + name, cp); } EXPORT_SYMBOL(security_dentry_init_security);