* [PATCH] mei: vsc: fix potential array bounds violation in ACE address allocation
@ 2025-08-01 9:06 WangYuli
2025-08-01 9:29 ` Greg KH
2025-08-17 11:10 ` Greg KH
0 siblings, 2 replies; 3+ messages in thread
From: WangYuli @ 2025-08-01 9:06 UTC (permalink / raw)
To: alexander.usyskin, arnd, gregkh
Cc: linux-kernel, zhanjun, niecheng1, guanwentao, WangYuli
When ACE images require dynamic address allocation, the code accesses
frags[frag_index - 1] without bounds checking. This could lead to:
- Array underflow if frag_index is 0
- Use of uninitialized fragment data for address calculations
- Silent failures in address allocation
Add proper validation before accessing the previous fragment and
provide clear error messages when validation fails.
Signed-off-by: WangYuli <wangyuli@uniontech.com>
---
drivers/misc/mei/vsc-fw-loader.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/misc/mei/vsc-fw-loader.c b/drivers/misc/mei/vsc-fw-loader.c
index 43abefa806e1..e2d318ecb76a 100644
--- a/drivers/misc/mei/vsc-fw-loader.c
+++ b/drivers/misc/mei/vsc-fw-loader.c
@@ -516,7 +516,19 @@ static int vsc_identify_ace_image(struct vsc_fw_loader *fw_loader)
frag->type = ace_image_map[i].image_type;
if (!frag->location) {
+ if (frag_index == 0) {
+ dev_err(fw_loader->dev,
+ "Cannot auto-allocate address for first fragment\n");
+ ret = -EINVAL;
+ goto err_release_image;
+ }
last_frag = &fw_loader->frags[frag_index - 1];
+ if (!last_frag->location || !last_frag->size) {
+ dev_err(fw_loader->dev,
+ "Previous fragment not properly initialized for auto-allocation\n");
+ ret = -EINVAL;
+ goto err_release_image;
+ }
frag->location =
ALIGN(last_frag->location + last_frag->size, SZ_4K);
}
--
2.50.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mei: vsc: fix potential array bounds violation in ACE address allocation
2025-08-01 9:06 [PATCH] mei: vsc: fix potential array bounds violation in ACE address allocation WangYuli
@ 2025-08-01 9:29 ` Greg KH
2025-08-17 11:10 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2025-08-01 9:29 UTC (permalink / raw)
To: WangYuli
Cc: alexander.usyskin, arnd, linux-kernel, zhanjun, niecheng1,
guanwentao
On Fri, Aug 01, 2025 at 05:06:00PM +0800, WangYuli wrote:
> When ACE images require dynamic address allocation, the code accesses
> frags[frag_index - 1] without bounds checking. This could lead to:
>
> - Array underflow if frag_index is 0
How can that happen? Does this value come from the kernel or from the
hardware?
> - Use of uninitialized fragment data for address calculations
> - Silent failures in address allocation
>
> Add proper validation before accessing the previous fragment and
> provide clear error messages when validation fails.
>
> Signed-off-by: WangYuli <wangyuli@uniontech.com>
What commit id does this fix?
How was this tested?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mei: vsc: fix potential array bounds violation in ACE address allocation
2025-08-01 9:06 [PATCH] mei: vsc: fix potential array bounds violation in ACE address allocation WangYuli
2025-08-01 9:29 ` Greg KH
@ 2025-08-17 11:10 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2025-08-17 11:10 UTC (permalink / raw)
To: WangYuli
Cc: alexander.usyskin, arnd, linux-kernel, zhanjun, niecheng1,
guanwentao
On Fri, Aug 01, 2025 at 05:06:00PM +0800, WangYuli wrote:
> When ACE images require dynamic address allocation, the code accesses
> frags[frag_index - 1] without bounds checking. This could lead to:
>
> - Array underflow if frag_index is 0
How can that happen? It's coming directly from a static array in the
code itself that it declared right above these lines?
> - Use of uninitialized fragment data for address calculations
Where will that come from?
> - Silent failures in address allocation
Where?
> Add proper validation before accessing the previous fragment and
> provide clear error messages when validation fails.
But how can any of this really happen? If it does, it's a bug in the
code that people added. So why is any of this needed to the code today?
How did you hit any of the above, and how was this patch tested?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-17 11:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-01 9:06 [PATCH] mei: vsc: fix potential array bounds violation in ACE address allocation WangYuli
2025-08-01 9:29 ` Greg KH
2025-08-17 11:10 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox