CV-Bowen opened a new pull request, #22264:
URL: https://github.com/apache/nuttx/pull/22264

   ## Summary
   
   Depends on apache/nuttx#22262
   
   rpmsg_port kept its own copy of the name service handling. In the order
   the changes were made:
   
   - `hold the endpoint across the ns bound callbacks`: the copy dropped
     `rdev->lock` before `ns_bound_cb()` for `NS_CREATE` and
     `NS_CREATE_ACK` without holding a reference, so a concurrent `close()`
     could free the endpoint during the callback. Take the reference on all
     three paths, as rpmsg_virtio does (apache/nuttx#22262).
   - `reuse the common name service handling`: with that, the copy behaves
     like `rpmsg_ns_handle_msg()` from apache/nuttx#22262; drop it and call
     the common one. rpmsg_port still copies the message out and releases
     the rx buffer before any user callback runs.
   
   ## Impact
   
   - rpmsg_port only. No API, Kconfig or protocol change.
   - Closes the use-after-free window on the rpmsg_port bound callbacks.
   
   ## Testing
   
   Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu 
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU 
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
   
   Both commits build sim:rpserver, sim:rpproxy, qemu-armv8a:rpserver,
   qemu-armv8a:rpproxy, sim:rpserver_uart, sim:rpserver with
   `CONFIG_OPENAMP_VIRTIO_DEVICE_SUPPORT=n` and sim:rpserver with
   `CONFIG_RPMSG_POOL_COUNT=8` + `CONFIG_RPMSG_WQUEUE_NUMBER=2` with 0
   warnings. qemu-armv8a:rpserver/rpproxy also link over
   rpmsg_port_uart, so the baseline below binds every service on that link
   through the new path: `rpmsg ping all` and `rpmsg dump all` reach both
   links.
   
   Not tested at runtime: the use-after-free itself, which needs a
   `close()` racing the bound callback.
   
   No regression in rpmsg: sim:rpserver/rpproxy and 
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping, 
rpmsgfs; 15/15). qemu-armv8a was built with LIBC_ENVPATH and BINFMT_CHECKEXEC 
disabled, which current master needs for nxinit to start nsh there; unrelated 
to this change.
   


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