jingfei195887 opened a new pull request, #21749:
URL: https://github.com/apache/nuttx/pull/21749

   ## Summary
   
   Three fixes in the rpmsgfs client and server.
   
   - **fs/rpmsgfs: free client priv from the endpoint release callback.**
     `rpmsgfs_client_unbind()` frees `priv` as soon as
     `rpmsg_unregister_callback()` returns, but that only drops one endpoint
     reference. An endpoint still held by an in-flight message survives, and
     its callback then runs on the freed `priv`. `priv` is now freed from the
     endpoint's release callback.
   - **fs/rpmsgfs: hold an endpoint reference across the unbind sweep.**
     `rpmsg_unregister_callback()` calls `device_destroy()` for every rpmsg
     device. After the previous change, the matching device drops the last
     reference and frees `priv` in the middle of the sweep, and the sweep then
     reads `priv->cpuname` for the remaining devices. The client now holds its
     own reference across the sweep.
   - **fs/rpmsgfs: carry 64-bit lseek offsets.** `struct rpmsgfs_lseek_s`
     carries the offset as `int32_t`, and the server returns the new position
     in `header.result`, also `int32_t`. With `CONFIG_FS_LARGEFILE`, offsets
     and positions at or beyond 2 GB are truncated. The offset is now
     `int64_t` and carries the new position back; `header.result` keeps the
     status.
   
   ## Impact
   
   The layout of the lseek message changes, so the rpmsgfs client and server
   must be built from the same revision. Without `CONFIG_FS_LARGEFILE` the
   behavior of lseek is unchanged.
   
   ## Testing
   
   Host: Ubuntu x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, master 
72c45233a0 (rebased onto 72c45233a0; no
   new commit touches fs/rpmsgfs). `sim:rpserver` and `sim:rpproxy`, both
   with `CONFIG_FS_LARGEFILE`, built from the same revision and run together.
   The server mounts a host directory with hostfs; the proxy mounts it with
   `mount -t rpmsgfs -o cpu=server,fs=/hst` and a small test program calls
   `lseek(fd, off, SEEK_SET)` on a file there:
   
   | offset | master | this PR |
   |---|---|---|
   | 0x10000000 | 0x10000000 | 0x10000000 |
   | 0xc0000000 | -1, EINVAL | 0xc0000000 |
   | 0x140000000 | 0x40000000 | 0x140000000 |
   
   Mounting and unmounting rpmsgfs 10 times leaves the heap unchanged on both
   master and this PR. The endpoint lifetime races need a message in flight
   while unmounting and were not reproduced on sim; those two changes are
   covered by review.
   
   - `./tools/checkpatch.sh -g master..HEAD`: all checks pass.
   - `sim:nsh` with `CONFIG_RPTUN`, `CONFIG_OPENAMP`, `CONFIG_FS_RPMSGFS`,
     `CONFIG_FS_RPMSGFS_SERVER`, `CONFIG_DEV_SIMPLE_ADDRENV` and
     `CONFIG_FS_LARGEFILE`: 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]

  • [PR] fs/rpmsgfs: fix client t... jingfei195887 (via GitHub) via commits

Reply via email to