[PATCH -next -v4 13/17] LSM: rename inode_setsecctx to path_setsecctx
From: Cai Xinchen
Date: Tue Nov 17 2026 - 09:38:51 EST
The inode_setsecctx hook receives a struct path, so rename it to
path_setsecctx and rename security_inode_setsecctx() and the SELinux and
Smack implementations accordingly. The exported symbol is renamed as
well, so out-of-tree modules calling security_inode_setsecctx() have to
be updated. Nothing under tools/ attaches to this hook.
Signed-off-by: Cai Xinchen <caixinchen1@xxxxxxxxxx>
---
fs/nfsd/vfs.c | 2 +-
include/linux/lsm_hook_defs.h | 2 +-
include/linux/security.h | 6 +++---
security/security.c | 8 ++++----
security/selinux/hooks.c | 6 +++---
security/smack/smack_lsm.c | 4 ++--
6 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 9eae731ecb26..aa75d2a60d60 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -628,7 +628,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
break;
}
if (attr->na_seclabel && attr->na_seclabel->len)
- attr->na_labelerr = security_inode_setsecctx(&path,
+ attr->na_labelerr = security_path_setsecctx(&path,
attr->na_seclabel->data, attr->na_seclabel->len);
if (IS_ENABLED(CONFIG_FS_POSIX_ACL) && attr->na_dpacl) {
if (!S_ISDIR(inode->i_mode))
diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
index 2680972b2c50..eefe68db5b45 100644
--- a/include/linux/lsm_hook_defs.h
+++ b/include/linux/lsm_hook_defs.h
@@ -340,7 +340,7 @@ LSM_HOOK(int, 0, secctx_to_secid, const char *secdata, u32 seclen, u32 *secid)
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 ctxlen)
-LSM_HOOK(int, 0, inode_setsecctx, const struct path *path, void *ctx,
+LSM_HOOK(int, 0, path_setsecctx, const struct path *path, void *ctx,
u32 ctxlen)
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 e625564ada1f..ddd9e1561084 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -597,7 +597,7 @@ 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_setsecctx(const struct path *path, void *ctx, u32 ctxlen);
+int security_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen);
int security_inode_getsecctx(struct inode *inode, struct lsm_context *cp);
int security_locked_down(enum lockdown_reason what);
int lsm_fill_user_ctx(struct lsm_ctx __user *uctx, u32 *uctx_len,
@@ -1650,8 +1650,8 @@ static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u3
{
return -EOPNOTSUPP;
}
-static inline int security_inode_setsecctx(const struct path *path, void *ctx,
- u32 ctxlen)
+static inline int security_path_setsecctx(const struct path *path, void *ctx,
+ u32 ctxlen)
{
return -EOPNOTSUPP;
}
diff --git a/security/security.c b/security/security.c
index 314c7736f0dd..d892a26f382f 100644
--- a/security/security.c
+++ b/security/security.c
@@ -4140,7 +4140,7 @@ int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
EXPORT_SYMBOL(security_inode_notifysecctx);
/**
- * security_inode_setsecctx() - Change the security label of an inode
+ * security_path_setsecctx() - Change the security label of an inode
* @path: inode (the VFS makes no guarantees with regard to @path->mnt)
* @ctx: secctx
* @ctxlen: length of secctx
@@ -4155,11 +4155,11 @@ EXPORT_SYMBOL(security_inode_notifysecctx);
*
* Return: Returns 0 on success, error on failure.
*/
-int security_inode_setsecctx(const struct path *path, void *ctx, u32 ctxlen)
+int security_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen)
{
- return call_int_hook(inode_setsecctx, path, ctx, ctxlen);
+ return call_int_hook(path_setsecctx, path, ctx, ctxlen);
}
-EXPORT_SYMBOL(security_inode_setsecctx);
+EXPORT_SYMBOL(security_path_setsecctx);
/**
* security_inode_getsecctx() - Get the security label of an inode
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 02fa9bbf7ea3..b7d90a78c686 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -7162,8 +7162,8 @@ static int selinux_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen
/*
* called with inode->i_mutex locked
*/
-static int selinux_inode_setsecctx(const struct path *path, void *ctx,
- u32 ctxlen)
+static int selinux_path_setsecctx(const struct path *path, void *ctx,
+ u32 ctxlen)
{
return __vfs_setxattr_locked(&nop_mnt_idmap, path, XATTR_NAME_SELINUX,
ctx, ctxlen, 0, NULL, NULL);
@@ -7837,7 +7837,7 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = {
LSM_HOOK_INIT(release_secctx, selinux_release_secctx),
LSM_HOOK_INIT(inode_invalidate_secctx, selinux_inode_invalidate_secctx),
LSM_HOOK_INIT(inode_notifysecctx, selinux_inode_notifysecctx),
- LSM_HOOK_INIT(inode_setsecctx, selinux_inode_setsecctx),
+ LSM_HOOK_INIT(path_setsecctx, selinux_path_setsecctx),
LSM_HOOK_INIT(unix_stream_connect, selinux_socket_unix_stream_connect),
LSM_HOOK_INIT(unix_may_send, selinux_socket_unix_may_send),
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index f301757ab2b7..d4364e9eb1f1 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -5006,7 +5006,7 @@ static int smack_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
ctxlen, 0);
}
-static int smack_inode_setsecctx(const struct path *path, void *ctx, u32 ctxlen)
+static int smack_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen)
{
return __vfs_setxattr_locked(&nop_mnt_idmap, path, XATTR_NAME_SMACK,
ctx, ctxlen, 0, NULL, NULL);
@@ -5331,7 +5331,7 @@ static struct security_hook_list smack_hooks[] __ro_after_init = {
LSM_HOOK_INIT(lsmprop_to_secctx, smack_lsmprop_to_secctx),
LSM_HOOK_INIT(secctx_to_secid, smack_secctx_to_secid),
LSM_HOOK_INIT(inode_notifysecctx, smack_inode_notifysecctx),
- LSM_HOOK_INIT(inode_setsecctx, smack_inode_setsecctx),
+ LSM_HOOK_INIT(path_setsecctx, smack_path_setsecctx),
LSM_HOOK_INIT(inode_getsecctx, smack_inode_getsecctx),
LSM_HOOK_INIT(inode_copy_up, smack_inode_copy_up),
LSM_HOOK_INIT(inode_copy_up_xattr, smack_inode_copy_up_xattr),
--
2.18.0.huawei.25