This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new c7cbee7a337 fs/smartfs: mask reserved flags from stat mode.
c7cbee7a337 is described below
commit c7cbee7a3378333e686a06eeacf44805887aa8d5
Author: Abhishek Mishra <[email protected]>
AuthorDate: Sat Oct 3 09:28:37 2026 +0000
fs/smartfs: mask reserved flags from stat mode.
SMARTFS_DIRENT_RESERVED uses bits that overlap S_ISUID, S_ISGID, and
S_ISVTX. smartfs_stat_common() currently clears only S_IFMT, allowing reserved
directory-entry flags to appear in st_mode and ls output as setuid and setgid
bits. Preserve only SMARTFS_DIRENT_MODE when constructing st_mode.
Assisted-by: GPT-5.6 Sol
Signed-off-by: Abhishek Mishra <[email protected]>
---
fs/smartfs/smartfs_smart.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/smartfs/smartfs_smart.c b/fs/smartfs/smartfs_smart.c
index d473da2eb98..2a4cf132922 100644
--- a/fs/smartfs/smartfs_smart.c
+++ b/fs/smartfs/smartfs_smart.c
@@ -1047,10 +1047,12 @@ static int smartfs_ioctl(FAR struct file *filep, int
cmd, unsigned long arg)
case FIOC_FILEPATH:
{
FAR char *path = (FAR char *)(uintptr_t)arg;
+
ret = inode_getpath(inode, path, PATH_MAX);
if (ret >= 0)
{
size_t len = strlen(path);
+
if (path[len - 1] != '/')
{
path[len++] = '/';
@@ -2131,9 +2133,12 @@ static void smartfs_stat_common(FAR struct
smartfs_mountpt_s *fs,
}
else
{
- /* Mask out the file type */
+ /* Preserve only the permission bits. The other directory-entry
+ * flags include SMARTFS_DIRENT_RESERVED, which overlaps the POSIX
+ * setuid, setgid, and sticky mode bits.
+ */
- buf->st_mode = entry->flags & ~S_IFMT;
+ buf->st_mode = entry->flags & SMARTFS_DIRENT_MODE;
/* Add the file type based on the SmartFS entry flags */