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 <mishra.abhishek2808@gmail.com>
This commit is contained in:
Abhishek Mishra 2026-07-16 18:55:19 +00:00 committed by Xiang Xiao
parent 4c62271654
commit 4bbe61ead5
4 changed files with 17 additions and 22 deletions

View file

@ -229,6 +229,10 @@ void inode_runlock(void)
*
****************************************************************************/
/****************************************************************************
* Name: inode_checkperm
****************************************************************************/
int inode_checkperm(FAR struct inode *inode, int amode)
{
#ifdef CONFIG_FS_PERMISSION

View file

@ -30,6 +30,7 @@
#include <errno.h>
#include <nuttx/kmalloc.h>
#include <nuttx/sched.h>
#include <nuttx/fs/fs.h>
#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);
}

View file

@ -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
*

View file

@ -33,7 +33,6 @@
#include <fcntl.h>
#include <sys/param.h>
#include <nuttx/sched.h>
#include <nuttx/kmalloc.h>
#include <nuttx/fs/fs.h>
#include <nuttx/fs/ioctl.h>
@ -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();