mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] lib/test_firmware: allocate the configured into_buf size
@ 2026-06-05  0:30 Samuel Moelius
  2026-06-06  1:44 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Samuel Moelius @ 2026-06-05  0:30 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Samuel Moelius, open list:LIBRARY CODE

The batched into_buf test path allocates TEST_FIRMWARE_BUF_SIZE bytes
unconditionally, but then passes test_fw_config->buf_size to
request_firmware_into_buf() or request_partial_firmware_into_buf().

Userspace can set config_buf_size above TEST_FIRMWARE_BUF_SIZE before
triggering a batched request. If the firmware file is large enough, the
firmware loader writes past the end of the 1 KiB test buffer.

Allocate the buffer with the same size that the test passes to the firmware
API so config_buf_size remains the actual buffer size under test.

Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
---
 lib/test_firmware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/test_firmware.c b/lib/test_firmware.c
index b471d720879a..7459bba65444 100644
--- a/lib/test_firmware.c
+++ b/lib/test_firmware.c
@@ -867,7 +867,7 @@ static int test_fw_run_batch_request(void *data)
 	if (test_fw_config->into_buf) {
 		void *test_buf;
 
-		test_buf = kzalloc(TEST_FIRMWARE_BUF_SIZE, GFP_KERNEL);
+		test_buf = kzalloc(test_fw_config->buf_size, GFP_KERNEL);
 		if (!test_buf)
 			return -ENOMEM;
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] lib/test_firmware: allocate the configured into_buf size
  2026-06-05  0:30 [PATCH] lib/test_firmware: allocate the configured into_buf size Samuel Moelius
@ 2026-06-06  1:44 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2026-06-06  1:44 UTC (permalink / raw)
  To: Samuel Moelius
  Cc: open list:LIBRARY CODE, Kees Cook, Luis R. Rodriguez, Scott Branden

On Fri,  5 Jun 2026 00:30:37 +0000 Samuel Moelius <sam.moelius@trailofbits.com> wrote:

> The batched into_buf test path allocates TEST_FIRMWARE_BUF_SIZE bytes
> unconditionally, but then passes test_fw_config->buf_size to
> request_firmware_into_buf() or request_partial_firmware_into_buf().
> 
> Userspace can set config_buf_size above TEST_FIRMWARE_BUF_SIZE before
> triggering a batched request. If the firmware file is large enough, the
> firmware loader writes past the end of the 1 KiB test buffer.
> 
> Allocate the buffer with the same size that the test passes to the firmware
> API so config_buf_size remains the actual buffer size under test.

Cool, thanks.

> Assisted-by: Codex:gpt-5.5-cyber-preview

Sashiko evidently looked further:
	https://sashiko.dev/#/patchset/20260605003038.2005840-1-sam.moelius@trailofbits.com

And appears to have found other bugs in test_firmware.c.  Let me cc a
few people who have previously worked on this.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-06  1:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-05  0:30 [PATCH] lib/test_firmware: allocate the configured into_buf size Samuel Moelius
2026-06-06  1:44 ` Andrew Morton

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®