* [PATCH] misc: bcm-vk: bound plane descriptors against the message buffer
@ 2026-11-17 9:37 Hyunjung Ko
0 siblings, 0 replies; only message in thread
From: Hyunjung Ko @ 2026-11-17 9:37 UTC (permalink / raw)
To: Scott Branden
Cc: bcm-kernel-feedback-list, Arnd Bergmann, Greg Kroah-Hartman,
linux-kernel, stable, Hyunjung Ko
In bcm_vk_write(), a VK_FID_TRANS_BUF message embeds an array of
num_planes struct _vk_data descriptors at the end of the message. Their
start is computed as:
data = (struct _vk_data *)&entry->to_v_msg[msg_size + 1];
data -= num_planes;
num_planes (0..15) comes from the message cmd field and msg_size (a u8)
from the size field; both are fully controlled by user space and are only
checked with 'msg_size > to_v_blks'. Nothing verifies that the plane
count is consistent with the message size, so a crafted message (for
example size 0 with a non-zero plane count) makes 'data' underflow below
the copied buffer. bcm_vk_sg_alloc() then reads num_planes descriptors
from out-of-bounds memory and interprets them as DMA addresses/sizes.
Reject any message whose descriptor range does not fall entirely within
the buffer copied from user space.
Cc: stable@vger.kernel.org
Signed-off-by: Hyunjung Ko <hj351016@gmail.com>
---
drivers/misc/bcm-vk/bcm_vk_msg.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/misc/bcm-vk/bcm_vk_msg.c b/drivers/misc/bcm-vk/bcm_vk_msg.c
index 17114092a284..e0d57f99a569 100644
--- a/drivers/misc/bcm-vk/bcm_vk_msg.c
+++ b/drivers/misc/bcm-vk/bcm_vk_msg.c
@@ -1192,6 +1192,21 @@ ssize_t bcm_vk_write(struct file *p_file,
/* Now back up to the start of the pointers */
data -= num_planes;
+ /*
+ * 'data' and the num_planes descriptors that follow must lie
+ * within the message buffer copied from user space. A crafted
+ * message with a plane count inconsistent with its size (e.g.
+ * size 0 with a non-zero plane count) makes 'data' underflow
+ * below the buffer (or run past its end), leading to an
+ * out-of-bounds read in bcm_vk_sg_alloc().
+ */
+ if ((void *)data < (void *)&entry->to_v_msg[0] ||
+ (void *)(data + num_planes) >
+ (void *)&entry->to_v_msg[entry->to_v_blks]) {
+ rc = -EINVAL;
+ goto write_free_msgid;
+ }
+
/* Convert user addresses to DMA SG List */
rc = bcm_vk_sg_alloc(dev, entry->dma, dir, data, num_planes);
if (rc)
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-17 9:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 9:37 [PATCH] misc: bcm-vk: bound plane descriptors against the message buffer Hyunjung Ko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®