|
@@ -778,6 +778,16 @@ static void rpmsg_recv_done(struct virtqueue *rvq)
|
|
|
print_hex_dump(KERN_DEBUG, "rpmsg_virtio RX: ", DUMP_PREFIX_NONE, 16, 1,
|
|
|
msg, sizeof(*msg) + msg->len, true);
|
|
|
|
|
|
+ /*
|
|
|
+ * We currently use fixed-sized buffers, so trivially sanitize
|
|
|
+ * the reported payload length.
|
|
|
+ */
|
|
|
+ if (len > RPMSG_BUF_SIZE ||
|
|
|
+ msg->len > (len - sizeof(struct rpmsg_hdr))) {
|
|
|
+ dev_warn(dev, "inbound msg too big: (%d, %d)\n", len, msg->len);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
/* use the dst addr to fetch the callback of the appropriate user */
|
|
|
mutex_lock(&vrp->endpoints_lock);
|
|
|
ept = idr_find(&vrp->endpoints, msg->dst);
|