lkml.org 
[lkml]   [2022]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] efi/x86: don't try to set page attributes on 0-sized regions.
Date
In "efi/x86: Explicitly set sections memory attributes", the following
region is defined to help compute page permissions:

/* .setup [image_base, _head] */
efi_adjust_memory_range_protection(image_base,
(unsigned long)_head - image_base,
EFI_MEMORY_RO | EFI_MEMORY_XP);

In at least some cases, that will result in a size of 0, which will
produce an error and a message on the console, though no actual failure
will be caused in the boot process.

This patch checks that case in efi_adjust_memory_range_protection() and
returns the error without logging.

Signed-off-by: Peter Jones <pjones@redhat.com>
---
drivers/firmware/efi/libstub/mem.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/firmware/efi/libstub/mem.c b/drivers/firmware/efi/libstub/mem.c
index d52841adcc2..d20b1986c9e 100644
--- a/drivers/firmware/efi/libstub/mem.c
+++ b/drivers/firmware/efi/libstub/mem.c
@@ -247,6 +247,9 @@ efi_status_t efi_adjust_memory_range_protection(unsigned long start,
efi_physical_addr_t rounded_start, rounded_end;
unsigned long attr_clear;

+ if (size == 0)
+ return EFI_INVALID_PARAMETER;
+
/*
* This function should not be used to modify attributes
* other than writable/executable.
--
2.38.1
\
 
 \ /
  Last update: 2022-12-13 19:06    [W:0.080 / U:0.824 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site