arnavsharma990 opened a new issue, #21116:
URL: https://github.com/apache/nuttx/issues/21116

   ### Description / Steps to reproduce the issue
   
   ### Description
   
   In `file_vopen()` in `fs/vfs/fs_open.c`, the `CONFIG_FS_LINKS` code returns 
`-ELOOP` directly when `O_NOFOLLOW` is specified and the resolved inode is a 
symbolic link.
   
   Before reaching this check, `inode_search_setup()` initializes the inode 
search descriptor, and `inode_find()` acquires a reference to the resolved 
inode. The direct return bypasses the existing cleanup labels, potentially 
leaking the inode reference and search descriptor.
   
   Repeated attempts to open a symbolic link with `O_NOFOLLOW` may therefore 
accumulate unreleased resources.
   
   ### Steps to reproduce
   
   1. Build NuttX with symbolic-link support enabled (`CONFIG_FS_LINKS=y`).
   2. Create a regular file and a symbolic link pointing to it.
   3. Call `open()` on the symbolic link with `O_RDONLY | O_NOFOLLOW`.
   4. Verify that the call fails with `ELOOP`, as expected.
   5. Inspect the error path in `file_vopen()` to verify whether the inode 
reference and search descriptor are released.
   
   ### Expected behavior
   
   The operation should fail with `ELOOP` while releasing all resources 
acquired during the attempt.
   
   ### Actual behavior
   
   The identified error path returns `-ELOOP` directly instead of routing 
through the existing cleanup labels. Source inspection indicates that this 
bypasses the corresponding inode-reference and search-descriptor cleanup.
   
   **Validation status:** The source-level cleanup path was inspected, the 
modified source compiled into `build/fs/libfs.a`, and `nxstyle` passed. A 
runtime reproduction and leak measurement have not yet been performed.
   
   ### On which OS does this issue occur?
   
   [OS: Mac]
   
   ### What is the version of your OS?
   
   Darwin 25.6.0 (arm64)
   
   ### NuttX Version
   
   local checkout at 5994c940bc
   
   ### Issue Architecture
   
   [Arch: simulator]
   
   ### Issue Area
   
   [Area: File System]
   
   ### Host information
   
   Configuration: `sim:citest-dirty`
   Host OS: macOS (Darwin 25.6.0), arm64
   Toolchain: clang
   Configuration options: `CONFIG_FS_LINKS=y`, `CONFIG_CM_FS_TEST=y`
   
   ### Verification
   
   - [x] I have verified before submitting the report.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to