From nobody Wed Nov 27 04:42:22 2024 Received: from sonic306-26.consmr.mail.ne1.yahoo.com (sonic306-26.consmr.mail.ne1.yahoo.com [66.163.189.88]) (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 80E291CBE8A for ; Mon, 14 Oct 2024 15:16:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.163.189.88 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919009; cv=none; b=fnUMINgxgiMd3z4ZNFsmZUgMZz96KVJhEYICSg6LbWC4H5cxpEvKVBPZRLat4i7RG3BB7lUdCaurCfv5+NGdJT0JjRACIb1FbAaKGC8E2pQs5ieSl8zM67RonPwEdEq1Wb0JD2b2IiVCS+/tZmhCt72Olzo0OeOk7b+XEoK+wyo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919009; c=relaxed/simple; bh=ere3Kik7ftPK6JxZZEH1M4sTcj2ctKVjykePBsYfvpM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NABrs64og4yTxS1+oegXek0/TAjypDvtcQQhVQngB13jrEEnVdm9sGwcAkGyUll0kq0b85uJVryMDWCvMA1PyNDK3yRdRrSSmtfzDY9y5fUfwukn7ihOAqc3ySPma48/wR+TRSq9s1StFLlzF+U3xNtX6/dJiZS/yPXf3oC4KmE= 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=gYSUmj87; arc=none smtp.client-ip=66.163.189.88 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="gYSUmj87" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1728919001; bh=4mPAELSUVvG9/ofHl8szvzOPyVtLeNBqQjj3M7dfO1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=gYSUmj87/E4MaLUI3kYq+WTu4gWEBybgIBo0t2D5fx2b7QEhs6Vz+zwBEfXw6BfUfZ9NZDGkpeLshGwqUwduQZS3je0uCfn4mGbIWcdIj46Omtxr1LKGVSye2isEr+hu3PCHKjoKbW3y/QV9zBPdhgQMeMLquacMQiGL1DdwbH7DGp08fwhc1yVmyQpWQlFsAh2Hq9N6Xm/oFbsshVyuCN1sZIbS4gzf9h/+v6/cyMCqnmW98wURDNhw/ZwS6wk/TMARIefyvkjnecpwyCBpmsMRAxmXg7QIQpRNgIrV0Blhgtvc2HBuOoKi/uaqtFKXARRzs0XpDcoRFq5D+4GyKg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1728919001; bh=jFa+mINhES7O4LMEYk9qLq+vQaOIKIkdPdzQH4HUFZ7=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=cqbxzyrKZDNVivxHNaPq2JWULQKNeXGcmThZzg8iO0cJQi7v8JxYTVxitxouMyMMNqTOTZiZ8TtjLgiCockx45odXVCX7kCdIx1pFRXG1z4IEiaJgqWhBQ4fzcwxddjJTyJynCHczFi1cAP7lSVxfLAwuGl/Ntf6iau2q+jl5ksIbsQc2LCO18YcUhqBlfR+hRx89E8tp41VMGn6AQCH3rd5o3+c5FyhlaJ5YbRMlq05HZm4GGC5ydub9irm9FvHURDQLLRAV4TgPz3VwRGZqp9syC6Grq4pA+depuluLAlVjJ+RXaPqCC1ijYr85GvihRZ+AypturFMqbV2dle/lA== X-YMail-OSG: HvSVcx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CJdBTMN e5IV8KIfhbLpjX4cAUJAldSQLsO9S0vui8QVrgfpLbPEh6ASOh6KyOsfS21l1VKSk3QpW9hIbCJP fDYNX0FgTI5gPFyfzLnPORE7TTHTEEAIxkmOopYsbSljyP96Ad5e2aeYRyUk5kiu.KKK0.F49u3C Uqkj__sdZCg84cmA.uvFqdc4VET_SNDCywxiifQ-- X-Sonic-MF: X-Sonic-ID: 304cb278-0e6e-4e01-8cca-c232728638e4 Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.ne1.yahoo.com with HTTP; Mon, 14 Oct 2024 15:16:41 +0000 Received: by hermes--production-gq1-5d95dc458-4hqnr (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 8dd3ed09a3dd7dbd0509b276d789cdef; Mon, 14 Oct 2024 15:16:38 +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 v2 6/6] LSM: Use lsm_context in security_inode_notifysecctx Date: Mon, 14 Oct 2024 08:14:50 -0700 Message-ID: <20241014151450.73674-7-casey@schaufler-ca.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241014151450.73674-1-casey@schaufler-ca.com> References: <20241014151450.73674-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 d00a6304133a..9bd38c0f3b09 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 e2f1ce37c41e..afadbce8bb60 100644 --- a/include/linux/lsm_hook_defs.h +++ b/include/linux/lsm_hook_defs.h @@ -301,7 +301,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 3ad59666e56c..6dcb0046531d 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -570,7 +570,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); @@ -1563,7 +1563,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 1d57e4e1bceb..c961edb0af57 100644 --- a/security/security.c +++ b/security/security.c @@ -4387,8 +4387,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 @@ -4399,9 +4398,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 b9286c2c5efe..6aeb8468e568 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -6656,10 +6656,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 c9ec4d93fb13..c5d7652395c1 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -4887,10 +4887,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