This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch releases/13.0 in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 6715797a2b51082280c3eb1caa5edec8ff6ac797 Author: tengshuangshuang <[email protected]> AuthorDate: Mon Sep 8 17:14:06 2025 +0800 shm: fix shm_open permission error to pass PSE52 test suite Signed-off-by: tengshuangshuang <[email protected]> --- fs/mmap/fs_mmap.c | 2 +- fs/shm/shm_open.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/mmap/fs_mmap.c b/fs/mmap/fs_mmap.c index a0c06e5c7e9..b5cac9175d4 100644 --- a/fs/mmap/fs_mmap.c +++ b/fs/mmap/fs_mmap.c @@ -138,7 +138,7 @@ static int file_mmap_(FAR struct file *filep, FAR void *start, } if ((flags & MAP_SHARED) && - (filep->f_oflags & O_WRONLY) == 0 && prot == PROT_WRITE) + (filep->f_oflags & O_WRONLY) == 0 && (prot & PROT_WRITE)) { ferr("ERROR: Unsupported options for read-only file descriptor," "prot=%x flags=%04x\n", prot, flags); diff --git a/fs/shm/shm_open.c b/fs/shm/shm_open.c index b83b324c6fc..258b88f899e 100644 --- a/fs/shm/shm_open.c +++ b/fs/shm/shm_open.c @@ -29,6 +29,7 @@ #include <stdio.h> #include <fcntl.h> #include <errno.h> +#include <sys/stat.h> #include "inode/inode.h" #include "vfs/vfs.h" @@ -111,6 +112,16 @@ static int file_shm_open(FAR struct file *shm, FAR const char *name, goto errout_with_sem; } +#ifdef CONFIG_PSEUDOFS_ATTRIBUTES + if (((oflags & O_WRONLY) && !(inode->i_mode & S_IWUSR)) || + ((oflags & O_RDONLY) && !(inode->i_mode & S_IRUSR)) + { + ret = -EACCES; + inode_release(inode); + goto errout_with_sem; + } +#endif + /* If the shared memory object already exists, truncate it to * zero bytes. */
