Skip to content

Commit

Permalink
firmware_loader: EFI firmware loader must handle pre-allocated buffer
Browse files Browse the repository at this point in the history
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: stable@vger.kernel.org
Acked-by: Scott Branden <scott.branden@broadcom.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20200724213640.389191-4-keescook@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Kees Cook authored and Greg Kroah-Hartman committed Jul 25, 2020
1 parent 4505e21 commit 4fb60b1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/base/firmware_loader/fallback_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ int firmware_fallback_platform(struct fw_priv *fw_priv, u32 opt_flags)
if (rc)
return rc; /* rc == -ENOENT when the fw was not found */

fw_priv->data = vmalloc(size);
if (fw_priv->data && size > fw_priv->allocated_size)
return -ENOMEM;
if (!fw_priv->data)
fw_priv->data = vmalloc(size);
if (!fw_priv->data)
return -ENOMEM;

Expand Down

0 comments on commit 4fb60b1

Please sign in to comment.