jingfei195887 opened a new pull request, #21776:
URL: https://github.com/apache/nuttx/pull/21776
## Summary
- **fs/tmpfs: lock parent dir in tmpfs_getpath().**
`tmpfs_getpath()` (used by `FIOC_FILEPATH` / `fcntl(F_GETPATH)`) walks the
parent's `tdo_entry[]` and copies `tde_name` without the directory lock.
`tmpfs_unlink()`, `tmpfs_rmdir()` and `tmpfs_rename()` free names, move the
last entry into the freed slot and realloc the array under that lock, so a
concurrent `F_GETPATH` can miss the entry it is looking for or read a freed
name. Hold the directory lock while searching and copying the name.
## Impact
tmpfs only. `F_GETPATH` takes each parent directory lock once, one at a time
(the recursion to the parent finishes before the lock is taken), so it does
not nest directory locks and cannot invert the order used by unlink/rename.
## Testing
Host: Ubuntu x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, master
dc9481383e.
`sim:smp` (4 CPUs) with `CONFIG_FS_TMPFS`: one thread creates and unlinks
128 to 1024 files in a tmpfs directory in a loop, while the main thread calls
`fcntl(F_GETPATH)` 20000 times on a file open in the same directory. Four
rounds, each in a new directory:
| | master | this PR |
|---|---|---|
| `F_GETPATH` failures per round | 2, 1, 1, 1 | 0, 0, 0, 0 |
| wrong path returned | 0 | 0 |
- `./tools/checkpatch.sh -g master..HEAD`: all checks pass.
- `sim:nsh` Make and CMake builds pass with no new warnings; `ostest` exits
with status 0.
--
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]