jingfei195887 opened a new pull request, #21673: URL: https://github.com/apache/nuttx/pull/21673
## Summary `procfs_write()` checks `ops->write` before calling it, but `procfs_read()` calls `ops->read` unconditionally. An entry added with `procfs_register()` that only implements `write` can still be opened for reading, and a read then jumps through a NULL pointer. Return 0 (end of file) when the entry has no read method, the same way the write side handles a missing handler. ## Impact Reading such an entry now returns end of file instead of crashing. Entries that implement `read` are unchanged. ## Testing Host: Ubuntu x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, master 03aea78639, `sim:nsh` with `CONFIG_FS_PROCFS_REGISTER=y`. A small test program registers `/proc/fsup_wo` with `open`, `close`, `write` and `stat` only, writes to it, then opens it read-only and calls `read()`: | step | master | this PR | |---|---|---| | `write()` | 1 | 1 | | `read()` | sim crashes (SIGSEGV) | 0 | - `./tools/checkpatch.sh -g master..HEAD`: all checks pass. - Make and CMake builds pass; `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]
