From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35516C28CC6 for ; Sun, 2 Jun 2019 16:54:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0E7EA2794D for ; Sun, 2 Jun 2019 16:54:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.b="fCsxCOqP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727108AbfFBQy0 (ORCPT ); Sun, 2 Jun 2019 12:54:26 -0400 Received: from sonic317-38.consmr.mail.ne1.yahoo.com ([66.163.184.49]:38512 "EHLO sonic317-38.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727091AbfFBQy0 (ORCPT ); Sun, 2 Jun 2019 12:54:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1559494464; bh=0jVxUPp+/V3kRc2gW7rNVCE5I4hyQouQVqDWX5FgND4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject; b=fCsxCOqPQbS0JgHfLSYk2uvPXrZPY7OaAwxt2Rbn3zR+YnVfHVg27t48plJlgbUsUT689OOI30LAKjaWthBS8hB9l5Bi9pSqqszz0F9dgwkw4l/DQtP/tsR6v2DZasQFtAyT9BQn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tnVAu8TQgyxY8GS.eQ5iN38XmdHDyZ13IdbWopx9u lkuncBRMS6OZ.XCyj.Ihye..gKmQpHnz3.ZAUqGTET7ylSBbo5qjfy3b951H2xXeifCamUuc4vfD rpVP1j7WkFXpm4iKNnxx5wVWBQ_m2L6VmVfLdAmlFJwIXv5YWPwsK0QkFnyk6PwYcOgo_oBgUL6V 5Kvbgz4WgU4idPJ.KiZIQFa5jPripR4HNZIfAval2.JDHKzUrmvGsgA6oPZTIcHrkRZYvzjvYxmI kqRKourxg71aTw2BjFH2LxxS.bBGhS0LktB_wKEdvq.60Araz0BpTkjo198JJlE5b7jipA5sJE4D _Jcvi.tUjUd3EqRs2MNxoa6OR27.EmPbRlpJQOSQBeUSANxkVHzgXZr3rA4zj1beN9xgengH0o05 mhWnqO.nQDxa1duH_iI2NdoQAtKMhbj12IoFU81bQz0b35wA0X5lD5l1xV0E- Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.ne1.yahoo.com with HTTP; Sun, 2 Jun 2019 16:54:24 +0000 Received: from c-73-223-4-185.hsd1.ca.comcast.net (EHLO localhost.net) ([73.223.4.185]) by smtp418.mail.ne1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 0b8226328c4965373e1d598ce42fc97b; Sun, 02 Jun 2019 16:54:21 +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 52/58] LSM: Use lsm_context in security_inode_setsecctx Date: Sun, 2 Jun 2019 09:50:55 -0700 Message-Id: <20190602165101.25079-53-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 Content-Transfer-Encoding: 8bit Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: From: Casey Schaufler Convert security_inode_setsecctx 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/nfsd/nfs4proc.c | 8 ++++++-- fs/nfsd/vfs.c | 7 ++++++- include/linux/security.h | 5 +++-- security/security.c | 8 ++------ 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 0cfd257ffdaf..5b4ea2a317ed 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -54,12 +54,16 @@ static inline void nfsd4_security_inode_setsecctx(struct svc_fh *resfh, struct xdr_netobj *label, u32 *bmval) { + struct lsm_context lc; struct inode *inode = d_inode(resfh->fh_dentry); int status; inode_lock(inode); - status = security_inode_setsecctx(resfh->fh_dentry, - label->data, label->len); + + lsm_context_init(&lc); + lc.context = label->data; + lc.len = label->len; + status = security_inode_setsecctx(resfh->fh_dentry, &lc); inode_unlock(inode); if (status) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 7dc98e14655d..2d6dd4bb7247 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -531,6 +531,7 @@ __be32 nfsd4_set_nfs4_label(struct svc_rqst *rqstp, struct svc_fh *fhp, __be32 error; int host_error; struct dentry *dentry; + struct lsm_context lc; error = fh_verify(rqstp, fhp, 0 /* S_IFREG */, NFSD_MAY_SATTR); if (error) @@ -539,7 +540,11 @@ __be32 nfsd4_set_nfs4_label(struct svc_rqst *rqstp, struct svc_fh *fhp, dentry = fhp->fh_dentry; inode_lock(d_inode(dentry)); - host_error = security_inode_setsecctx(dentry, label->data, label->len); + + lsm_context_init(&lc); + lc.context = label->data; + lc.len = label->len; + host_error = security_inode_setsecctx(dentry, &lc); inode_unlock(d_inode(dentry)); return nfserrno(host_error); } diff --git a/include/linux/security.h b/include/linux/security.h index 94c714310ab7..0be6eadd0110 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -439,7 +439,7 @@ void security_release_secctx(struct lsm_context *cp); void security_inode_invalidate_secctx(struct inode *inode); int security_inode_notifysecctx(struct inode *inode, struct lsm_context *cp); -int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen); +int security_inode_setsecctx(struct dentry *dentry, struct lsm_context *cp); int security_inode_getsecctx(struct inode *inode, struct lsm_context *cp); #else /* CONFIG_SECURITY */ @@ -1237,7 +1237,8 @@ static inline int security_inode_notifysecctx(struct inode *inode, { return -EOPNOTSUPP; } -static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen) +static inline int security_inode_setsecctx(struct dentry *dentry, + struct lsm_context *cp) { return -EOPNOTSUPP; } diff --git a/security/security.c b/security/security.c index 9d09c774a1e9..363647cf1ae8 100644 --- a/security/security.c +++ b/security/security.c @@ -2006,13 +2006,9 @@ int security_inode_notifysecctx(struct inode *inode, struct lsm_context *cp) } EXPORT_SYMBOL(security_inode_notifysecctx); -int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen) +int security_inode_setsecctx(struct dentry *dentry, struct lsm_context *cp) { - struct lsm_context lc; - - lc.context = ctx; - lc.len = ctxlen; - return call_int_hook(inode_setsecctx, 0, dentry, &lc); + return call_int_hook(inode_setsecctx, 0, dentry, cp); } EXPORT_SYMBOL(security_inode_setsecctx); -- 2.19.1