From 4bbe61ead5e1ab0f2d5b17f32022f2caddf8b837 Mon Sep 17 00:00:00 2001 From: Abhishek Mishra Date: Thu, 16 Jul 2026 18:55:19 +0000 Subject: [PATCH] fs/inode: assign owner and group when reserving pseudo-inodes Set i_owner and i_group from the caller's effective credentials in inode_reserve(), covering IPC objects, FIFOs, and pseudo-files. Signed-off-by: Abhishek Mishra --- fs/inode/fs_inode.c | 4 ++++ fs/inode/fs_inodereserve.c | 13 +++++++++++++ fs/inode/inode.h | 6 ------ fs/vfs/fs_pseudofile.c | 16 ---------------- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/fs/inode/fs_inode.c b/fs/inode/fs_inode.c index 294f7bb791e..654b8f7a340 100644 --- a/fs/inode/fs_inode.c +++ b/fs/inode/fs_inode.c @@ -229,6 +229,10 @@ void inode_runlock(void) * ****************************************************************************/ +/**************************************************************************** + * Name: inode_checkperm + ****************************************************************************/ + int inode_checkperm(FAR struct inode *inode, int amode) { #ifdef CONFIG_FS_PERMISSION diff --git a/fs/inode/fs_inodereserve.c b/fs/inode/fs_inodereserve.c index 8cd41a5b186..e255f3f3753 100644 --- a/fs/inode/fs_inodereserve.c +++ b/fs/inode/fs_inodereserve.c @@ -30,6 +30,7 @@ #include #include +#include #include #include "inode/inode.h" @@ -82,6 +83,9 @@ static FAR struct inode *inode_alloc(FAR const char *name, mode_t mode) { FAR struct inode *inode; int namelen; +#if defined(CONFIG_PSEUDOFS_ATTRIBUTES) && defined(CONFIG_SCHED_USER_IDENTITY) + FAR struct tcb_s *rtcb; +#endif namelen = inode_namelen(name); inode = fs_heap_zalloc(FSNODE_SIZE(namelen)); @@ -94,6 +98,15 @@ static FAR struct inode *inode_alloc(FAR const char *name, mode_t mode) clock_gettime(CLOCK_REALTIME, &inode->i_atime); inode->i_mtime = inode->i_atime; inode->i_ctime = inode->i_atime; +# if defined(CONFIG_SCHED_USER_IDENTITY) + rtcb = nxsched_self(); + if (rtcb != NULL && rtcb->group != NULL) + { + inode->i_owner = rtcb->group->tg_euid; + inode->i_group = rtcb->group->tg_egid; + } + +# endif #endif inode_namecpy(inode->i_name, name); } diff --git a/fs/inode/inode.h b/fs/inode/inode.h index b8280d91bb5..7cacd0697f3 100644 --- a/fs/inode/inode.h +++ b/fs/inode/inode.h @@ -461,12 +461,6 @@ int fs_open_amode(int oflags); int fs_checkopenperm(uid_t owner, gid_t group, mode_t mode, int oflags); #endif -#ifdef CONFIG_FS_PERMISSION -int fs_checkmode(uid_t owner, gid_t group, mode_t mode, int amode); -int fs_open_amode(int oflags); -int fs_checkopenperm(uid_t owner, gid_t group, mode_t mode, int oflags); -#endif - /**************************************************************************** * Name: foreach_inode * diff --git a/fs/vfs/fs_pseudofile.c b/fs/vfs/fs_pseudofile.c index e5376cfe97e..e5204b0641b 100644 --- a/fs/vfs/fs_pseudofile.c +++ b/fs/vfs/fs_pseudofile.c @@ -33,7 +33,6 @@ #include #include -#include #include #include #include @@ -468,10 +467,6 @@ int pseudofile_create(FAR struct inode **node, FAR const char *path, mode_t mode) { FAR struct fs_pseudofile_s *pf; -#if defined(CONFIG_PSEUDOFS_ATTRIBUTES) && \ - defined(CONFIG_SCHED_USER_IDENTITY) - FAR struct tcb_s *rtcb; -#endif int ret; if (node == NULL || path == NULL) @@ -498,17 +493,6 @@ int pseudofile_create(FAR struct inode **node, FAR const char *path, (*node)->u.i_ops = &g_pseudofile_ops; (*node)->i_private = pf; -#if defined(CONFIG_PSEUDOFS_ATTRIBUTES) && \ - defined(CONFIG_SCHED_USER_IDENTITY) - - rtcb = nxsched_self(); - if (rtcb != NULL && rtcb->group != NULL) - { - (*node)->i_owner = rtcb->group->tg_euid; - (*node)->i_group = rtcb->group->tg_egid; - } -#endif - atomic_fetch_add(&(*node)->i_crefs, 1); inode_unlock();