CV-Bowen commented on PR #22142:
URL: https://github.com/apache/nuttx/pull/22142#issuecomment-7089726295

   @cederom updated:
   
   - PR title and the commits that change API, wire protocol or defaults are
     marked with `!` and carry a `BREAKING CHANGE:` paragraph with the quick
     fix; the PR description has a BREAKING CHANGE section.
   - The series now also contains the follow-up rpmsgdev changes (split
     large reads again, request messages back on the stack, per-open state
     preallocated, private/configdata ioctls, ...), so it no longer stops in
     the intermediate state with reads capped at one buffer.
   - Runtime logs from qemu-armv8a (two QEMU instances over ivshmem) and sim
     are in the description.
   
   1. Pool starvation: yes, with `CONFIG_RPMSG_POOL_COUNT > 0` each pending
      blocking read held two pool blocks, and a few idle readers could
      exhaust the pool. `keep request messages on the stack again` moves the
      request and its cookie back to the caller's stack, so rpmsgdev no
      longer uses the pool at all. With a 4-block pool the previous push
      crashed the client at the third idle reader on qemu-armv8a (NULL pool
      block in `rpmsgdev_open()`) and hung it on sim; now three idle readers
      wait while other rpmsgdev I/O and `rpmsg ping` keep working (logs in
      the description).
   
   2. Pending read on teardown: `rpmsgdev_close_handler()` cannot run while a
      read is pending on the same file: the client read holds a reference
      on the file and waits uninterruptibly, so CLOSE is only sent after the
      read has returned. But `rpmsgdev_ept_release()` (client core goes away)
      only tore down the client's own poll, not the pending read's, and
      then closed the file and freed the slots: a use-after-free. And on the
      client nothing completed the waiting request when the server went
      away, so the blocked reader never woke up. The last commit fixes both:
      the server drops the pending read poll and its work before the slot is
      reused or freed (also in the close handler), and the client fails all
      waiting requests with -ENOTCONN when the server endpoint is unbound or
      the rpmsg device is destroyed. Stopping the peer during a pending read
      crashed the server in `rpmsgdev_read_work()` on qemu-armv8a and gave a
      KASAN read error on sim before; now both sides stay up and the
      client's read returns -ENOTCONN.
   
   On the command numbers: I kept the renumbering. rpmsgdev is a
   kernel-to-kernel protocol between the cores of one product; the client
   and server images are built and updated together, so a mixed-version
   pair is not a supported setup, and keeping the numbers identical to the
   existing users avoids carrying two encodings of the same commands. The
   breaking note in the commit and the PR says so explicitly.
   
   The series keeps the internal order of the changes, so a few intermediate
   commits still carry the two problems above (pool use from `allocate
   request messages from the rpmsg pool` until `keep request messages on the
   stack again`, the pending read teardown until the last commit); the tip of
   the series has neither.
   


-- 
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