This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit d6a120e506165a0ce42d5b540d3bcded0a695657 Author: Xiang Xiao <[email protected]> AuthorDate: Sat Apr 19 19:00:23 2025 +0800 drivers/misc/rpmsgdev: check that the payload can hold the ioctl packet rpmsgdev_ioctl() copied the ioctl argument into the tx buffer without checking its size. Return -EMSGSIZE when the argument does not fit. Signed-off-by: Xiang Xiao <[email protected]> --- drivers/misc/rpmsgdev.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/misc/rpmsgdev.c b/drivers/misc/rpmsgdev.c index b92f0bdb117..74cffd25ee4 100644 --- a/drivers/misc/rpmsgdev.c +++ b/drivers/misc/rpmsgdev.c @@ -688,14 +688,19 @@ static int rpmsgdev_ioctl(FAR struct file *filep, int cmd, unsigned long arg) return arglen; } - msglen = sizeof(*msg) + arglen - 1; - msg = rpmsgdev_get_tx_payload_buffer(dev, &space); if (msg == NULL) { return -ENOMEM; } + msglen = sizeof(*msg) + arglen - 1; + if (space < msglen) + { + rpmsg_release_tx_buffer(&dev->ept, msg); + return -EMSGSIZE; + } + msg->filep = priv->filep; msg->request = cmd; msg->arg = arg;
