Skip to content

Commit 4fb60b1

Browse files
keesgregkh
authored andcommitted
firmware_loader: EFI firmware loader must handle pre-allocated buffer
The EFI platform firmware fallback would clobber any pre-allocated buffers. Instead, correctly refuse to reallocate when too small (as already done in the sysfs fallback), or perform allocation normally when needed. Fixes: e4c2c0f ("firmware: Add new platform fallback mechanism and firmware_request_platform()") Cc: [email protected] Acked-by: Scott Branden <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4505e21 commit 4fb60b1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/base/firmware_loader/fallback_platform.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ int firmware_fallback_platform(struct fw_priv *fw_priv, u32 opt_flags)
2525
if (rc)
2626
return rc; /* rc == -ENOENT when the fw was not found */
2727

28-
fw_priv->data = vmalloc(size);
28+
if (fw_priv->data && size > fw_priv->allocated_size)
29+
return -ENOMEM;
30+
if (!fw_priv->data)
31+
fw_priv->data = vmalloc(size);
2932
if (!fw_priv->data)
3033
return -ENOMEM;
3134

0 commit comments

Comments
 (0)