From: Wentao Liang <vulab@iscas.ac.cn>
To: bcm-kernel-feedback-list@broadcom.com
Cc: florian.fainelli@broadcom.com, gregkh@linuxfoundation.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
linux-rpi-kernel@lists.infradead.org, uajain@igalia.com,
wahrenst@gmx.net, Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] platform/raspberrypi: Fix service use-after-free in vchiq_blocking_bulk_transfer()
Date: Thu, 17 Sep 2026 13:54:51 +0000 [thread overview]
Message-ID: <20260917135451.2154073-1-vulab@iscas.ac.cn> (raw)
find_service_by_handle() returns the service with a reference taken,
but vchiq_blocking_bulk_transfer() drops it immediately and then keeps
dereferencing service->state to reach the bulk_waiter spinlock on the
"not a retry" and "cancel the signal" paths. Once a concurrent
vchiq_free_service_internal() releases the last reference the service
is freed, so those accesses use freed memory.
Hold the reference until the end of the function instead, as
vchiq_service_callback() already does.
Fixes: 12cc5f92c159 ("staging: vc04_services: Move spinlocks to vchiq_state")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c b/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
index e78641703252..10f33a04e22a 100644
--- a/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
+++ b/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
@@ -588,8 +588,6 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl
if (!service)
return -EINVAL;
- vchiq_service_put(service);
-
mutex_lock(&instance->bulk_waiter_list_mutex);
list_for_each_entry(iter, &instance->bulk_waiter_list, list) {
if (iter->pid == current->pid) {
@@ -619,8 +617,10 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl
}
} else {
waiter = kzalloc_obj(*waiter);
- if (!waiter)
+ if (!waiter) {
+ vchiq_service_put(service);
return -ENOMEM;
+ }
}
bulk_params->waiter = &waiter->bulk_waiter;
@@ -645,6 +645,8 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl
waiter, current->pid);
}
+ vchiq_service_put(service);
+
return ret;
}
--
2.34.1
reply other threads:[~2026-09-17 13:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260917135451.2154073-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=florian.fainelli@broadcom.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=stable@vger.kernel.org \
--cc=uajain@igalia.com \
--cc=wahrenst@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox