casaroli opened a new pull request, #20631: URL: https://github.com/apache/nuttx/pull/20631
## Summary Two defects in `chmod()`: - `v9fs_client_chstat()` converts `st_mode` with `v9fs_map_open_flags()`, which maps the `O_*` flags of `open()`. `chmod()` on a v9fs file sets a wrong mode: 755 gives 701, 644 gives 600 and 777 gives 700. The first commit sends the permission bits of `st_mode`. - `chmod()`, `lchmod()` and `fchmod()` mask the mode with 0777, so a program cannot set `S_ISUID`, `S_ISGID` or `S_ISVTX`, although `exec()` of a binary with `S_ISUID` sets the effective user ID. The second commit masks the mode with 07777. ## Impact `chmod()`, `lchmod()` and `fchmod()` on all file systems: the set-user-ID, set-group-ID and sticky bits are now kept. On v9fs, the mode that `chmod()` sets is now the mode that the caller gives. No API change. ## Testing `qemu-armv8a:knsh` with a virtio 9P share, with these commits on a larger local branch. For each mode: create a file on the share, `chmod` it, and read the mode back with `stat -c %a`. Before: `chmod 755` gave 701 and `chmod 777` gave 700, and the set-user-ID, set-group-ID and sticky bits were lost. After: for 755, 644, 4755, 2755, 1777 and 6711, the mode read back is the mode given. Build: `qemu-armv8a:nsh` and `qemu-armv8a:knsh`. -- 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]
