From nobody Fri Nov 29 17:49:21 2024 Received: from sonic314-27.consmr.mail.ne1.yahoo.com (sonic314-27.consmr.mail.ne1.yahoo.com [66.163.189.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B699117C9A7 for ; Tue, 17 Sep 2024 23:53:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.163.189.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726617232; cv=none; b=P0jcxjl57T+OvxC7X+iqoJu9WxkJE29N0qND+IjDhtsX1TgJDwpw2d/YGPNfqTqakzPAvUrl7hP3pgjnIDH4fvlZ8I4YZ3L2+D+dPzLDA28swEjAgRv2ELaAnTliocWUBNCGKmG2gIG1UZS7RA/ZbxSx3yE/vdCTF1q1FWmV6EQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726617232; c=relaxed/simple; bh=pkiJFK4UWzbihdSQP0/vZjet04jCTlLQiH9p+ugfN30=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o080bSk12Uuj5AHyijgeOuwT1SH2Gh6XGExrhKcyg9SeJ1Y5VyIiT09X1ayCOriPlyycZ1PsiPOS5jYjYOMoEVnwoJqMX84fr/LhDG0CT4jcwUGCo4t9mSWtYmm3Bmo6oxKbAkUncZBPOIKEnBBAn4kko84coYXWqjyyz11d/IA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=schaufler-ca.com; spf=none smtp.mailfrom=schaufler-ca.com; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.b=aN8vqmnN; arc=none smtp.client-ip=66.163.189.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=schaufler-ca.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=schaufler-ca.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.b="aN8vqmnN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1726617229; bh=rLl2LsJz48bPh17xjOUIrSgVKkITvgpZAh47LFR7xMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=aN8vqmnNvDZ9BXRzktIgzepVFtdZlUF4dPa1lIpwYmmOT1vXW/R4wv6k4ODw1Qzy9PDOiVp1pxP4Z7/DpGy0Rm1r1Ps4nTmWfjO00YRbQN5U73RztbNJ8j5KXpo8ODCe2gCaoKxQJaG94z7PyL06NoyPjc0M1bNhtfDnDmXH5IM1ZLm0pG+X/j0ukg2GRZSJsRgw67vPp0blbsapjaZXnVWdp0y7O9bo8ZcspL6/Y2Z0V852O3cSC+keGzh9YKjmkdFBZgFPdN6qCdt1Z5lg1Q9F2UxrJQviSyQcp/SZJ3SunBVjZ7nyj9WtqsECiZVkYGhvoDIlnYVv6Zvn9AQ3zw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1726617229; bh=nzurJyaw6wgzma+7cmEzE6ah9+uczsB0t0PcMV6REn8=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=LKU9+0/gvBKTcCFnLN7LCno1U/mJ7fcHeVCpO9lYHh/76ImSMiIJ61ieoS2n9apfzPY0mGF/n/rV128jmEEcCcyiVeDzejZxDActMvXnmx4HP582HBFMqXKwv6KfNjSMug5BjgWFGjjZzbdEsk2lMYM1GVQ0N4k7Le9728p20NhlHRWnRbvYnb/CFWVox6lyCh8A3lDSmQMc3Onzlo9xPYVGg4ns4fj92umBbMwOCGuflwaw+oMgvyR/9WX855pu6UCeSWi/UEf3EsSaL8SqnXwmnScBTRYggvTT0so83c+YQYePQsqVk76nxlGVUEKJYmUs6Gm3VhpQdkhZuLUyX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Z F7.6Xu0PsqB8_E1IAJgtjsC8tHX4L8drGoQslh9ebj_OcDxPwsYyGH918e2vw3JMwMuHURB4r1M9 jlP_nVRk21b81vGjY4WJxBcszfFrcrI3w2hostNs9xsPnYDhGVFF7e5KRVAReZCSwRZlA7Yf6yp1 b73x6vGDntWCd1aJoCEtdOx85kGPLWW6OceWdQSU4veYnLuQA6yZKT_Z1VjWuXxrfkHt0eMSuK46 qlGSo_Jd5fVdYHCuQe08E8ce43OQ1TXsbp.w- X-Sonic-MF: X-Sonic-ID: 9f23d04c-1822-4eae-a91e-9d5266c6a30e Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ne1.yahoo.com with HTTP; Tue, 17 Sep 2024 23:53:49 +0000 Received: by hermes--production-gq1-5d95dc458-rvnnh (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 41ac41609d6122fff099bda257412a4d; Tue, 17 Sep 2024 23:53:45 +0000 (UTC) From: Casey Schaufler To: casey@schaufler-ca.com, paul@paul-moore.com, linux-security-module@vger.kernel.org Cc: jmorris@namei.org, serge@hallyn.com, keescook@chromium.org, john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp, stephen.smalley.work@gmail.com, linux-kernel@vger.kernel.org, selinux@vger.kernel.org, mic@digikod.net Subject: [PATCH 5/5] LSM: Use lsm_context in security_inode_notifysecctx Date: Tue, 17 Sep 2024 16:52:02 -0700 Message-ID: <20240917235202.32578-6-casey@schaufler-ca.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240917235202.32578-1-casey@schaufler-ca.com> References: <20240917235202.32578-1-casey@schaufler-ca.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the lsm_context structure in the security_inode_notifysecctx() interface. Its sole user is already using lsm_context to store the data. Signed-off-by: Casey Schaufler --- fs/nfs/inode.c | 3 +-- include/linux/lsm_hook_defs.h | 3 ++- include/linux/security.h | 4 ++-- security/security.c | 7 +++---- security/selinux/hooks.c | 5 +++-- security/smack/smack_lsm.c | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 056ddc876cb5..4323a39c14c1 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -359,8 +359,7 @@ void nfs_setsecurity(struct inode *inode, struct nfs_fa= ttr *fattr) =20 if ((fattr->valid & NFS_ATTR_FATTR_V4_SECURITY_LABEL) && inode->i_securit= y) { error =3D security_inode_notifysecctx(inode, - fattr->label->lsmctx.context, - fattr->label->lsmctx.len); + &fattr->label->lsmctx); if (error) printk(KERN_ERR "%s() %s %d " "security_inode_notifysecctx() %d\n", diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h index 6b671f4ada03..0216aeb4a3fd 100644 --- a/include/linux/lsm_hook_defs.h +++ b/include/linux/lsm_hook_defs.h @@ -298,7 +298,8 @@ LSM_HOOK(int, -EOPNOTSUPP, lsmprop_to_secctx, struct ls= m_prop *prop, LSM_HOOK(int, 0, secctx_to_secid, const char *secdata, u32 seclen, u32 *se= cid) LSM_HOOK(void, LSM_RET_VOID, release_secctx, struct lsm_context *cp) LSM_HOOK(void, LSM_RET_VOID, inode_invalidate_secctx, struct inode *inode) -LSM_HOOK(int, 0, inode_notifysecctx, struct inode *inode, void *ctx, u32 c= txlen) +LSM_HOOK(int, 0, inode_notifysecctx, struct inode *inode, + struct lsm_context *cp) LSM_HOOK(int, 0, inode_setsecctx, struct dentry *dentry, void *ctx, u32 ct= xlen) LSM_HOOK(int, -EOPNOTSUPP, inode_getsecctx, struct inode *inode, struct lsm_context *cp) diff --git a/include/linux/security.h b/include/linux/security.h index c9c4845da3a6..1b1411fff6ac 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -555,7 +555,7 @@ int security_lsmprop_to_secctx(struct lsm_prop *prop, s= truct lsm_context *cp); int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid); void security_release_secctx(struct lsm_context *cp); void security_inode_invalidate_secctx(struct inode *inode); -int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen= ); +int security_inode_notifysecctx(struct inode *inode, struct lsm_context *c= p); int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen); int security_inode_getsecctx(struct inode *inode, struct lsm_context *cp); int security_locked_down(enum lockdown_reason what); @@ -1536,7 +1536,7 @@ static inline void security_inode_invalidate_secctx(s= truct inode *inode) { } =20 -static inline int security_inode_notifysecctx(struct inode *inode, void *c= tx, u32 ctxlen) +static inline int security_inode_notifysecctx(struct inode *inode, struct = lsm_context *cp); { return -EOPNOTSUPP; } diff --git a/security/security.c b/security/security.c index 020e7a89de16..44639d193ecd 100644 --- a/security/security.c +++ b/security/security.c @@ -4268,8 +4268,7 @@ EXPORT_SYMBOL(security_inode_invalidate_secctx); /** * security_inode_notifysecctx() - Notify the LSM of an inode's security l= abel * @inode: inode - * @ctx: secctx - * @ctxlen: length of secctx + * @ctx: LSM context * * Notify the security module of what the security context of an inode sho= uld * be. Initializes the incore security context managed by the security mo= dule @@ -4280,9 +4279,9 @@ EXPORT_SYMBOL(security_inode_invalidate_secctx); * * Return: Returns 0 on success, error on failure. */ -int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen) +int security_inode_notifysecctx(struct inode *inode, struct lsm_context *c= p) { - return call_int_hook(inode_notifysecctx, inode, ctx, ctxlen); + return call_int_hook(inode_notifysecctx, inode, cp); } EXPORT_SYMBOL(security_inode_notifysecctx); =20 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 93188e124f99..382c63d67743 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -6665,10 +6665,11 @@ static void selinux_inode_invalidate_secctx(struct = inode *inode) /* * called with inode->i_mutex locked */ -static int selinux_inode_notifysecctx(struct inode *inode, void *ctx, u32 = ctxlen) +static int selinux_inode_notifysecctx(struct inode *inode, + struct lsm_context *cp) { int rc =3D selinux_inode_setsecurity(inode, XATTR_SELINUX_SUFFIX, - ctx, ctxlen, 0); + cp->context, cp->len, 0); /* Do not return error when suppressing label (SBLABEL_MNT not set). */ return rc =3D=3D -EOPNOTSUPP ? 0 : rc; } diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index b443859948e9..1dfc4292ea15 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -4906,10 +4906,10 @@ static int smack_secctx_to_secid(const char *secdat= a, u32 seclen, u32 *secid) * Now that there's a list such a hook adds cost. */ =20 -static int smack_inode_notifysecctx(struct inode *inode, void *ctx, u32 ct= xlen) +static int smack_inode_notifysecctx(struct inode *inode, struct lsm_contex= t *cp) { - return smack_inode_setsecurity(inode, XATTR_SMACK_SUFFIX, ctx, - ctxlen, 0); + return smack_inode_setsecurity(inode, XATTR_SMACK_SUFFIX, cp->context, + cp->len, 0); } =20 static int smack_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctx= len) --=20 2.46.0