Skip to content

staging: vc04_services: vchiq-mmal: validate component index in event…#7326

Closed
Sebasteuo wants to merge 1 commit intoraspberrypi:rpi-6.18.yfrom
Sebasteuo:fix/mmal-vchiq-component-index-6.18
Closed

staging: vc04_services: vchiq-mmal: validate component index in event…#7326
Sebasteuo wants to merge 1 commit intoraspberrypi:rpi-6.18.yfrom
Sebasteuo:fix/mmal-vchiq-component-index-6.18

Conversation

@Sebasteuo
Copy link
Copy Markdown

…_to_host_cb()

event_to_host_cb() uses msg->u.event_to_host.client_component as an index into the instance->component[] array (size VCHIQ_MMAL_MAX_COMPONENTS = 64) without bounds validation. While the kernel generally trusts the hardware it is bound to, a bounds check here hardens the driver against potential firmware bugs that could otherwise cause an uncontrolled out-of-bounds array access and kernel crash.

Add a bounds check on comp_idx before using it as an array index and move the component pointer assignment after the validation. Use pr_err_ratelimited() to avoid log flooding. Note: this file does not currently have access to a struct device, so dev_err() is not available.

Cc: stable@vger.kernel.org
Fixes: b18ee53 ("staging: bcm2835: Break MMAL support out from camera")

…_to_host_cb()

event_to_host_cb() uses msg->u.event_to_host.client_component as an
index into the instance->component[] array (size VCHIQ_MMAL_MAX_COMPONENTS
= 64) without bounds validation. While the kernel generally trusts the
hardware it is bound to, a bounds check here hardens the driver against
potential firmware bugs that could otherwise cause an uncontrolled
out-of-bounds array access and kernel crash.

Add a bounds check on comp_idx before using it as an array index and
move the component pointer assignment after the validation. Use
pr_err_ratelimited() to avoid log flooding. Note: this file does not
currently have access to a struct device, so dev_err() is not available.

Cc: stable@vger.kernel.org
Fixes: b18ee53 ("staging: bcm2835: Break MMAL support out from camera")
Signed-off-by: Sebastián Alba Vives <sebasjosue84@gmail.com>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the second implementation of event_to_host_cb, the first of which is just a stub (https://github.com/raspberrypi/linux/pull/7326/changes#diff-c7eb07be414e4492176f38e319d52a418c65483a6747bda080c0191cbb200df7R234-R243).
How is this meant to work?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this is an artifact of rebasing onto the wrong kernel tree.
This commit should look like the one in the other PR (against 6.18): 09cfb46

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree:

$ git log --oneline pr7326
f94c456841fbf (pr7326) staging: vc04_services: vchiq-mmal: validate component index in event_to_host_cb()
28062d320bded bcachefs: Fix gc handling of bucket gens
86a225c42d44b bcachefs: fix a deadlock on startup
3c5fa33a55ac2 bcachefs: force str_hash code to be inlined
d16b4a77a5c64 bcachefs: Assorted journal refactoring
ecf37a4a80ec0 bcachefs: fs_usage_u64s()

where

$ git show pr7326^
commit 28062d320bded23eb7d24633e6ab11ea3c03487b
Author: Kent Overstreet <kent.overstreet@gmail.com>
Date:   Wed Feb 20 17:57:06 2019 -0500

    bcachefs: Fix gc handling of bucket gens
    
    Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>

diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c
index 56402fc64bc22..c899a77bf8919 100644
--- a/fs/bcachefs/btree_gc.c
+++ b/fs/bcachefs/btree_gc.c
@@ -142,22 +142,23 @@ static int bch2_gc_mark_key(struct bch_fs *c, struct bkey_s_c k,
                bkey_for_each_ptr(ptrs, ptr) {
...

@Sebasteuo
Copy link
Copy Markdown
Author

Closing in favor of #7327 which is correctly rebased onto rpi-6.18.y.

@Sebasteuo Sebasteuo closed this Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants