Skip to contentSkip to conversation

efi_loader: loosen buffer parameter check in efi_file_read_int

PATCH New Peng Fan (OSS) 3 participants 3 messages Apr 28, 2021 – Apr 30, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 efi_loader: loosen buffer parameter check in efi_file_read_int

From: Peng Fan <[email protected]>

This is same issue as https://bugzilla.redhat.com/show_bug.cgi?id=1733817,
but that fix was wrongly partial reverted.

When reading a directory, EFI_BUFFER_TOO_SMALL should be returned when the supplied buffer is too small, so a use-case is to call EFI_FILE_PROTOCOL.Read() with *buffer_size=0 and buffer=NULL to obtain the needed size before doing the actual read.

So remove the check only for directory reading, file reading already do the check by itself.

Fixes db12f518edb0("efi_loader: implement non-blocking file services")
Cc Heinrich Schuchardt <[email protected]>
Cc Stefan S?rensen <[email protected]>

---

V2:
Update commit log Per Heinrich's comments.
Add T-b tag

 lib/efi_loader/efi_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_loader/efi_file.c +1 -1
index 204105e25a..6b3f5962be 100644
@@ -554,7 +554,7 @@ static efi_status_t efi_file_read_int(struct efi_file_handle *this,
 	efi_status_t ret = EFI_SUCCESS;
 	u64 bs;
 
-	if (!this || !buffer_size || !buffer)
+	if (!this || !buffer_size)
 		return EFI_INVALID_PARAMETER;
 
 	bs = *buffer_size;
Signature · 1 line
2.30.0
#1 lore raw

PATCH v2 1/1 efi_loader: loosen buffer parameter check in efi_file_read_int

Quoted 10 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

This is same issue as https://bugzilla.redhat.com/show_bug.cgi?id=1733817,
but that fix was wrongly partial reverted.

When reading a directory, EFI_BUFFER_TOO_SMALL should be returned when the supplied buffer is too small, so a use-case is to call EFI_FILE_PROTOCOL.Read() with *buffer_size=0 and buffer=NULL to obtain the needed size before doing the actual read.

Quoted 8 lines

So remove the check only for directory reading, file reading already do the check by itself.

Fixes db12f518edb0("efi_loader: implement non-blocking file services")
Cc Heinrich Schuchardt <[email protected]>
Cc Stefan S?rensen <[email protected]>
Quoted 23 lines

---

V2:
Update commit log Per Heinrich's comments.
Add T-b tag

 lib/efi_loader/efi_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_loader/efi_file.c +1 -1
index 204105e25a..6b3f5962be 100644
@@ -554,7 +554,7 @@ static efi_status_t efi_file_read_int(struct efi_file_handle *this,
 	efi_status_t ret = EFI_SUCCESS;
 	u64 bs;
 
-	if (!this || !buffer_size || !buffer)
+	if (!this || !buffer_size)
 		return EFI_INVALID_PARAMETER;
 
 	bs = *buffer_size;
#2 lore raw

PATCH v2 1/1 efi_loader: loosen buffer parameter check in efi_file_read_int

In reply to Peng Fan (OSS)

st 28. 4. 2021 v 15:22 odes?latel Peng Fan (OSS) <[email protected]> napsal:

Quoted 42 lines

From: Peng Fan <[email protected]>

This is same issue as https://bugzilla.redhat.com/show_bug.cgi?id=1733817,
but that fix was wrongly partial reverted.

When reading a directory, EFI_BUFFER_TOO_SMALL should be returned when the supplied buffer is too small, so a use-case is to call EFI_FILE_PROTOCOL.Read() with *buffer_size=0 and buffer=NULL to obtain the needed size before doing the actual read.

So remove the check only for directory reading, file reading already do the check by itself.

Fixes db12f518edb0("efi_loader: implement non-blocking file services")
Cc Heinrich Schuchardt <[email protected]>
Cc Stefan S?rensen <[email protected]>

---

V2:
Update commit log Per Heinrich's comments.
Add T-b tag

 lib/efi_loader/efi_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_loader/efi_file.c +1 -2
index 204105e25a..6b3f5962be 100644
@@ -554,7 +554,7 @@ static efi_status_t efi_file_read_int(struct efi_file_handle *this,
        efi_status_t ret = EFI_SUCCESS;
        u64 bs;
 
-       if (!this || !buffer_size || !buffer)
+       if (!this || !buffer_size)
                return EFI_INVALID_PARAMETER;
 
        bs = *buffer_size;
--
Quoted 2 lines

2.30.0

Thanks,
Michal

Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs