summaryrefslogtreecommitdiff
path: root/lib/efi_loader
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-09-15 00:51:00 -0600
committerAlexander Graf <agraf@suse.de>2018-09-23 21:55:30 +0200
commit2ae843f7323bf6ffa74771bcac8ecd5fa78d66ea (patch)
tree5b462f3bb7e456bc2e3829edb81171c17a2015e3 /lib/efi_loader
parent428aa0ca56aef4ca7facb503c4dba2de127c6046 (diff)
efi: Correct the operation of efi_file_write()
We should not directly cast between pointers and addresses since it breaks sandbox. Fix this and simplify the code in file_read(). Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib/efi_loader')
-rw-r--r--lib/efi_loader/efi_file.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
index 84be0d5818..7edec908f5 100644
--- a/lib/efi_loader/efi_file.c
+++ b/lib/efi_loader/efi_file.c
@@ -292,10 +292,8 @@ static efi_status_t file_read(struct file_handle *fh, u64 *buffer_size,
void *buffer)
{
loff_t actread;
- /* fs_read expects buffer address, not pointer */
- uintptr_t buffer_addr = (uintptr_t)map_to_sysmem(buffer);
- if (fs_read(fh->path, buffer_addr, fh->offset,
+ if (fs_read(fh->path, map_to_sysmem(buffer), fh->offset,
*buffer_size, &actread))
return EFI_DEVICE_ERROR;
@@ -425,7 +423,7 @@ static efi_status_t EFIAPI efi_file_write(struct efi_file_handle *file,
goto error;
}
- if (fs_write(fh->path, (ulong)buffer, fh->offset, *buffer_size,
+ if (fs_write(fh->path, map_to_sysmem(buffer), fh->offset, *buffer_size,
&actwrite)) {
ret = EFI_DEVICE_ERROR;
goto error;