CV-Bowen opened a new pull request, #22364:
URL: https://github.com/apache/nuttx/pull/22364
## Summary
Two fixes in the rpmsg block device client, the same ones rpmsgmtd got
in apache/nuttx#22191:
- `drivers/misc/rpmsgblk: keep a copy of the remote cpu and path`:
`rpmsgblk_register()` only saved the caller's `remotecpu` and
`remotepath` pointers. They are used much later, in the
device_created and device_destroy callbacks (e.g. when the link comes
back), so a caller that passes a stack buffer or frees the strings
after registration leaves the driver reading freed memory. Copy them
into the device.
- `drivers/misc/rpmsgblk: do not copy the ioctl argument from a NULL
pointer`: `rpmsgblk_default_ioctl()` copied `arglen` bytes from
`arg`, and gave `arg` to the reply copy, also when the caller passed
`arg` 0. UBSan reports this as "null pointer passed as argument 2".
## Impact
No behaviour change for callers that pass long-lived strings and valid
ioctl arguments. `struct rpmsgblk_s` grows by the two name buffers
(`RPMSG_NAME_SIZE` each).
## 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
Every commit builds sim:rpserver, sim:rpproxy, qemu-armv8a:rpserver and
qemu-armv8a:rpproxy with `BLK_RPMSG` and `BLK_RPMSG_SERVER` enabled,
with 0 warnings. sim:rpproxy registers `/dev/ram1` of the server
through rpmsgblk at boot.
Not tested at runtime: the freed-name case needs device_created to run
after the caller's buffer is gone, i.e. a link restart, which sim does
not support (`rptun start` does not reconnect after `rptun stop`); the
NULL-argument case needs UBSan. imx93-qsb:rpmsg is unaffected (rpmsgblk
is not enabled there).
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]