* [PATCH 1/5] efi_selftest: fix buffer overflow
2026-02-19 18:43 [PATCH 0/5] efi_selftest: manageprotocols fixes and enhancements Vincent Stehlé
@ 2026-02-19 18:43 ` Vincent Stehlé
2026-02-20 7:37 ` Ilias Apalodimas
2026-02-24 15:45 ` Heinrich Schuchardt
2026-02-19 18:43 ` [PATCH 2/5] efi_selftest: fix buffer overflow and memory leak Vincent Stehlé
` (3 subsequent siblings)
4 siblings, 2 replies; 14+ messages in thread
From: Vincent Stehlé @ 2026-02-19 18:43 UTC (permalink / raw)
To: u-boot; +Cc: Vincent Stehlé, Heinrich Schuchardt, Ilias Apalodimas,
Tom Rini
The test of the UEFI LocateHandleBuffer() function clears a returned buffer
at some point to reuse it, but there is an error in the size computation,
which leads to a buffer overflow; fix it.
Fixes: 927ca890b09f ("efi_selftest: test protocol management")
Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
---
lib/efi_selftest/efi_selftest_manageprotocols.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
index 097b2ae3545..ccffa59095d 100644
--- a/lib/efi_selftest/efi_selftest_manageprotocols.c
+++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
@@ -241,7 +241,7 @@ static int execute(void)
return EFI_ST_FAILURE;
}
/* Clear the buffer, we are reusing it it the next step. */
- boottime->set_mem(buffer, sizeof(efi_handle_t) * buffer_size, 0);
+ boottime->set_mem(buffer, sizeof(efi_handle_t) * count, 0);
/*
* Test LocateHandle with ByProtocol
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH 1/5] efi_selftest: fix buffer overflow
2026-02-19 18:43 ` [PATCH 1/5] efi_selftest: fix buffer overflow Vincent Stehlé
@ 2026-02-20 7:37 ` Ilias Apalodimas
2026-02-24 15:45 ` Heinrich Schuchardt
1 sibling, 0 replies; 14+ messages in thread
From: Ilias Apalodimas @ 2026-02-20 7:37 UTC (permalink / raw)
To: Vincent Stehlé, u-boot
Cc: Heinrich Schuchardt, Ilias Apalodimas, Tom Rini
On Thu Feb 19, 2026 at 8:43 PM EET, Vincent Stehlé wrote:
> The test of the UEFI LocateHandleBuffer() function clears a returned buffer
> at some point to reuse it, but there is an error in the size computation,
> which leads to a buffer overflow; fix it.
>
> Fixes: 927ca890b09f ("efi_selftest: test protocol management")
> Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Cc: Tom Rini <trini@konsulko.com>
> ---
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> lib/efi_selftest/efi_selftest_manageprotocols.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
> index 097b2ae3545..ccffa59095d 100644
> --- a/lib/efi_selftest/efi_selftest_manageprotocols.c
> +++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
> @@ -241,7 +241,7 @@ static int execute(void)
> return EFI_ST_FAILURE;
> }
> /* Clear the buffer, we are reusing it it the next step. */
> - boottime->set_mem(buffer, sizeof(efi_handle_t) * buffer_size, 0);
> + boottime->set_mem(buffer, sizeof(efi_handle_t) * count, 0);
>
> /*
> * Test LocateHandle with ByProtocol
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 1/5] efi_selftest: fix buffer overflow
2026-02-19 18:43 ` [PATCH 1/5] efi_selftest: fix buffer overflow Vincent Stehlé
2026-02-20 7:37 ` Ilias Apalodimas
@ 2026-02-24 15:45 ` Heinrich Schuchardt
2026-03-10 17:16 ` Vincent Stehlé
1 sibling, 1 reply; 14+ messages in thread
From: Heinrich Schuchardt @ 2026-02-24 15:45 UTC (permalink / raw)
To: Vincent Stehlé
Cc: Heinrich Schuchardt, Ilias Apalodimas, Tom Rini, u-boot
On 2/19/26 19:43, Vincent Stehlé wrote:
> The test of the UEFI LocateHandleBuffer() function clears a returned buffer
> at some point to reuse it, but there is an error in the size computation,
> which leads to a buffer overflow; fix it.
>
> Fixes: 927ca890b09f ("efi_selftest: test protocol management")
> Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Cc: Tom Rini <trini@konsulko.com>
> ---
> lib/efi_selftest/efi_selftest_manageprotocols.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
> index 097b2ae3545..ccffa59095d 100644
> --- a/lib/efi_selftest/efi_selftest_manageprotocols.c
> +++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
> @@ -241,7 +241,7 @@ static int execute(void)
> return EFI_ST_FAILURE;
> }
> /* Clear the buffer, we are reusing it it the next step. */
> - boottime->set_mem(buffer, sizeof(efi_handle_t) * buffer_size, 0);
> + boottime->set_mem(buffer, sizeof(efi_handle_t) * count, 0);
>
> /*
> * Test LocateHandle with ByProtocol
Hello Vincent,
Thank you for reviewing the code and pointing to an issue.
The fix looks incomplete to me:
In line 167 we allocate a buffer with LocateHandleBuffer(). Assigning
buffer_size in line 173 does not make any sense, as we free the buffer
in line 185.
In line 223 we allocate another buffer with LocateHandleBuffer().
Assigning the value of buffer_size value to count before the invocation
doesn't make much sense.
You fix in line 244 looks correct.
Line 249 sets count to an arbitrary value that is not related to the
size of the buffer.
Line 260 sets variable buffer_size and buffer_size is again used in line
306 to set count to an unused value.
We should completely remove variable buffer_size from the function.
Best regards
Heinrich
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 1/5] efi_selftest: fix buffer overflow
2026-02-24 15:45 ` Heinrich Schuchardt
@ 2026-03-10 17:16 ` Vincent Stehlé
0 siblings, 0 replies; 14+ messages in thread
From: Vincent Stehlé @ 2026-03-10 17:16 UTC (permalink / raw)
To: Heinrich Schuchardt
Cc: Heinrich Schuchardt, Ilias Apalodimas, Tom Rini, u-boot
On Tue, Feb 24, 2026 at 04:45:48PM +0100, Heinrich Schuchardt wrote:
Hi Heinrich,
Thanks for your review and sorry for the late reply.
My answers below.
Best regards,
Vincent.
> On 2/19/26 19:43, Vincent Stehlé wrote:
> > The test of the UEFI LocateHandleBuffer() function clears a returned buffer
> > at some point to reuse it, but there is an error in the size computation,
> > which leads to a buffer overflow; fix it.
> >
> > Fixes: 927ca890b09f ("efi_selftest: test protocol management")
> > Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
> > Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
> > Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> > Cc: Tom Rini <trini@konsulko.com>
> > ---
> > lib/efi_selftest/efi_selftest_manageprotocols.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
> > index 097b2ae3545..ccffa59095d 100644
> > --- a/lib/efi_selftest/efi_selftest_manageprotocols.c
> > +++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
> > @@ -241,7 +241,7 @@ static int execute(void)
> > return EFI_ST_FAILURE;
> > }
> > /* Clear the buffer, we are reusing it it the next step. */
> > - boottime->set_mem(buffer, sizeof(efi_handle_t) * buffer_size, 0);
> > + boottime->set_mem(buffer, sizeof(efi_handle_t) * count, 0);
> > /*
> > * Test LocateHandle with ByProtocol
>
> Hello Vincent,
>
> Thank you for reviewing the code and pointing to an issue.
>
> The fix looks incomplete to me:
You are right: I broke down all the fixes into multiple steps, which explains
why the first patch ("fix buffer overflow") is not the full story.
I thought this would ease reviewing but now I wonder if that was maybe a bad
idea. Let me know if I should send a v2 with the series as a single patch if
that helps.
>
> In line 167 we allocate a buffer with LocateHandleBuffer(). Assigning
> buffer_size in line 173 does not make any sense, as we free the buffer in
> line 185.
This is removed in patch 4 ("fix buffer size and count computations").
>
> In line 223 we allocate another buffer with LocateHandleBuffer().
> Assigning the value of buffer_size value to count before the invocation
> doesn't make much sense.
This is removed in patch 3 ("remove unnecessary initializations").
>
> You fix in line 244 looks correct.
>
> Line 249 sets count to an arbitrary value that is not related to the size of
> the buffer.
This part is reworked in patch 4 to use buffer_size instead.
>
> Line 260 sets variable buffer_size and buffer_size is again used in line 306
> to set count to an unused value.
This is removed in patch 3.
>
> We should completely remove variable buffer_size from the function.
The patch series takes a different approach: keep both count and buffer_size
variables, and make sure to use those variables to contain quantities
corresponding to their respective names.
>
> Best regards
>
> Heinrich
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/5] efi_selftest: fix buffer overflow and memory leak
2026-02-19 18:43 [PATCH 0/5] efi_selftest: manageprotocols fixes and enhancements Vincent Stehlé
2026-02-19 18:43 ` [PATCH 1/5] efi_selftest: fix buffer overflow Vincent Stehlé
@ 2026-02-19 18:43 ` Vincent Stehlé
2026-02-20 9:10 ` Ilias Apalodimas
2026-02-19 18:43 ` [PATCH 3/5] efi_selftest: remove unnecessary initializations Vincent Stehlé
` (2 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Vincent Stehlé @ 2026-02-19 18:43 UTC (permalink / raw)
To: u-boot; +Cc: Vincent Stehlé, Heinrich Schuchardt, Ilias Apalodimas,
Tom Rini
The test of the UEFI UninstallMultipleProtocolInterfaces() function clears
a buffer returned by LocateHandleBuffer() at some point, but there is an
error in the size computation, which leads to a buffer overflow.
The buffer is also never freed, which leads to a memory leak.
As the buffer is in fact not reused during the test, fix both errors by
simply freeing the buffer.
Fixes: 927ca890b09f ("efi_selftest: test protocol management")
Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
---
lib/efi_selftest/efi_selftest_manageprotocols.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
index ccffa59095d..0334a074866 100644
--- a/lib/efi_selftest/efi_selftest_manageprotocols.c
+++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
@@ -319,7 +319,12 @@ static int execute(void)
efi_st_error("Failed to locate new handle\n");
return EFI_ST_FAILURE;
}
- boottime->set_mem(buffer, sizeof(efi_handle_t) * buffer_size, 0);
+ /* Release buffer */
+ ret = boottime->free_pool(buffer);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("FreePool failed\n");
+ return EFI_ST_FAILURE;
+ }
/*
* Test ProtocolsPerHandle
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH 2/5] efi_selftest: fix buffer overflow and memory leak
2026-02-19 18:43 ` [PATCH 2/5] efi_selftest: fix buffer overflow and memory leak Vincent Stehlé
@ 2026-02-20 9:10 ` Ilias Apalodimas
0 siblings, 0 replies; 14+ messages in thread
From: Ilias Apalodimas @ 2026-02-20 9:10 UTC (permalink / raw)
To: Vincent Stehlé; +Cc: u-boot, Heinrich Schuchardt, Tom Rini
On Thu, 19 Feb 2026 at 20:44, Vincent Stehlé <vincent.stehle@arm.com> wrote:
>
> The test of the UEFI UninstallMultipleProtocolInterfaces() function clears
> a buffer returned by LocateHandleBuffer() at some point, but there is an
> error in the size computation, which leads to a buffer overflow.
> The buffer is also never freed, which leads to a memory leak.
>
> As the buffer is in fact not reused during the test, fix both errors by
> simply freeing the buffer.
>
> Fixes: 927ca890b09f ("efi_selftest: test protocol management")
> Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Cc: Tom Rini <trini@konsulko.com>
> ---
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> lib/efi_selftest/efi_selftest_manageprotocols.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
> index ccffa59095d..0334a074866 100644
> --- a/lib/efi_selftest/efi_selftest_manageprotocols.c
> +++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
> @@ -319,7 +319,12 @@ static int execute(void)
> efi_st_error("Failed to locate new handle\n");
> return EFI_ST_FAILURE;
> }
> - boottime->set_mem(buffer, sizeof(efi_handle_t) * buffer_size, 0);
> + /* Release buffer */
> + ret = boottime->free_pool(buffer);
> + if (ret != EFI_SUCCESS) {
> + efi_st_error("FreePool failed\n");
> + return EFI_ST_FAILURE;
> + }
>
> /*
> * Test ProtocolsPerHandle
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 3/5] efi_selftest: remove unnecessary initializations
2026-02-19 18:43 [PATCH 0/5] efi_selftest: manageprotocols fixes and enhancements Vincent Stehlé
2026-02-19 18:43 ` [PATCH 1/5] efi_selftest: fix buffer overflow Vincent Stehlé
2026-02-19 18:43 ` [PATCH 2/5] efi_selftest: fix buffer overflow and memory leak Vincent Stehlé
@ 2026-02-19 18:43 ` Vincent Stehlé
2026-02-20 7:43 ` Ilias Apalodimas
2026-02-19 18:43 ` [PATCH 4/5] efi_selftest: fix buffer size and count computations Vincent Stehlé
2026-02-19 18:44 ` [PATCH 5/5] efi_selftest: cosmetic: fix spelling in comments Vincent Stehlé
4 siblings, 1 reply; 14+ messages in thread
From: Vincent Stehlé @ 2026-02-19 18:43 UTC (permalink / raw)
To: u-boot; +Cc: Vincent Stehlé, Heinrich Schuchardt, Ilias Apalodimas,
Tom Rini
The UEFI function LocateHandleBuffer() always writes to the value pointed
to by its NoHandles argument (in the test, `count'); remove the unnecessary
initializations.
Remove also one copy to buffer_size, which has become unnecessary.
Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
---
lib/efi_selftest/efi_selftest_manageprotocols.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
index 0334a074866..7fe7b285011 100644
--- a/lib/efi_selftest/efi_selftest_manageprotocols.c
+++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
@@ -219,7 +219,6 @@ static int execute(void)
*
* handle1, handle2
*/
- count = buffer_size;
ret = boottime->locate_handle_buffer(BY_PROTOCOL, &guid1, NULL,
&count, &buffer);
if (ret != EFI_SUCCESS) {
@@ -257,7 +256,6 @@ static int execute(void)
efi_st_error("LocateHandle failed to locate new handles\n");
return EFI_ST_FAILURE;
}
- buffer_size = count;
ret = find_in_buffer(handle1, count, buffer);
if (ret != EFI_SUCCESS) {
efi_st_error("LocateHandle failed to locate new handles\n");
@@ -303,7 +301,6 @@ static int execute(void)
/*
* Check that the protocols are really uninstalled.
*/
- count = buffer_size;
ret = boottime->locate_handle_buffer(BY_PROTOCOL, &guid1, NULL,
&count, &buffer);
if (ret != EFI_SUCCESS) {
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH 3/5] efi_selftest: remove unnecessary initializations
2026-02-19 18:43 ` [PATCH 3/5] efi_selftest: remove unnecessary initializations Vincent Stehlé
@ 2026-02-20 7:43 ` Ilias Apalodimas
0 siblings, 0 replies; 14+ messages in thread
From: Ilias Apalodimas @ 2026-02-20 7:43 UTC (permalink / raw)
To: Vincent Stehlé, u-boot
Cc: Heinrich Schuchardt, Ilias Apalodimas, Tom Rini
On Thu Feb 19, 2026 at 8:43 PM EET, Vincent Stehlé wrote:
> The UEFI function LocateHandleBuffer() always writes to the value pointed
> to by its NoHandles argument (in the test, `count'); remove the unnecessary
> initializations.
>
> Remove also one copy to buffer_size, which has become unnecessary.
>
> Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Cc: Tom Rini <trini@konsulko.com>
> ---
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> lib/efi_selftest/efi_selftest_manageprotocols.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
> index 0334a074866..7fe7b285011 100644
> --- a/lib/efi_selftest/efi_selftest_manageprotocols.c
> +++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
> @@ -219,7 +219,6 @@ static int execute(void)
> *
> * handle1, handle2
> */
> - count = buffer_size;
> ret = boottime->locate_handle_buffer(BY_PROTOCOL, &guid1, NULL,
> &count, &buffer);
> if (ret != EFI_SUCCESS) {
> @@ -257,7 +256,6 @@ static int execute(void)
> efi_st_error("LocateHandle failed to locate new handles\n");
> return EFI_ST_FAILURE;
> }
> - buffer_size = count;
> ret = find_in_buffer(handle1, count, buffer);
> if (ret != EFI_SUCCESS) {
> efi_st_error("LocateHandle failed to locate new handles\n");
> @@ -303,7 +301,6 @@ static int execute(void)
> /*
> * Check that the protocols are really uninstalled.
> */
> - count = buffer_size;
> ret = boottime->locate_handle_buffer(BY_PROTOCOL, &guid1, NULL,
> &count, &buffer);
> if (ret != EFI_SUCCESS) {
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 4/5] efi_selftest: fix buffer size and count computations
2026-02-19 18:43 [PATCH 0/5] efi_selftest: manageprotocols fixes and enhancements Vincent Stehlé
` (2 preceding siblings ...)
2026-02-19 18:43 ` [PATCH 3/5] efi_selftest: remove unnecessary initializations Vincent Stehlé
@ 2026-02-19 18:43 ` Vincent Stehlé
2026-02-20 9:13 ` Ilias Apalodimas
2026-02-19 18:44 ` [PATCH 5/5] efi_selftest: cosmetic: fix spelling in comments Vincent Stehlé
4 siblings, 1 reply; 14+ messages in thread
From: Vincent Stehlé @ 2026-02-19 18:43 UTC (permalink / raw)
To: u-boot; +Cc: Vincent Stehlé, Heinrich Schuchardt, Ilias Apalodimas,
Tom Rini
When testing the UEFI LocateHandle() function, the BufferSize argument is
erroneously computed with a count from three test steps before, leading to
an incorrect input buffer size.
Also, while the buffer size returned by LocateHandle() is correctly
converted to a count during a subsequent comparison, it is incorrectly
passed "as is" as a count to later calls to find_in_buffer().
Finally, the variables usage during this test step is misleading, as the
`buffer_size' variable is used to hold a count, and the `count' variable is
used to hold a buffer size.
Fix all those issues at once, and remove also one copy to buffer_size,
which has now become unnecessary.
Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
---
lib/efi_selftest/efi_selftest_manageprotocols.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
index 7fe7b285011..f07ff256ce1 100644
--- a/lib/efi_selftest/efi_selftest_manageprotocols.c
+++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
@@ -170,7 +170,6 @@ static int execute(void)
efi_st_error("LocateHandleBuffer with AllHandles failed\n");
return EFI_ST_FAILURE;
}
- buffer_size = count;
ret = find_in_buffer(handle1, count, buffer);
if (ret != EFI_SUCCESS) {
efi_st_error("LocateHandleBuffer failed to locate new handle\n");
@@ -245,14 +244,15 @@ static int execute(void)
/*
* Test LocateHandle with ByProtocol
*/
- count = buffer_size * sizeof(efi_handle_t);
+ buffer_size = count * sizeof(efi_handle_t);
ret = boottime->locate_handle(BY_PROTOCOL, &guid1, NULL,
- &count, buffer);
+ &buffer_size, buffer);
if (ret != EFI_SUCCESS) {
efi_st_error("LocateHandle with ByProtocol failed\n");
return EFI_ST_FAILURE;
}
- if (count / sizeof(efi_handle_t) != 2) {
+ count = buffer_size / sizeof(efi_handle_t);
+ if (count != 2) {
efi_st_error("LocateHandle failed to locate new handles\n");
return EFI_ST_FAILURE;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH 4/5] efi_selftest: fix buffer size and count computations
2026-02-19 18:43 ` [PATCH 4/5] efi_selftest: fix buffer size and count computations Vincent Stehlé
@ 2026-02-20 9:13 ` Ilias Apalodimas
0 siblings, 0 replies; 14+ messages in thread
From: Ilias Apalodimas @ 2026-02-20 9:13 UTC (permalink / raw)
To: Vincent Stehlé; +Cc: u-boot, Heinrich Schuchardt, Tom Rini
On Thu, 19 Feb 2026 at 20:44, Vincent Stehlé <vincent.stehle@arm.com> wrote:
>
> When testing the UEFI LocateHandle() function, the BufferSize argument is
> erroneously computed with a count from three test steps before, leading to
> an incorrect input buffer size.
>
> Also, while the buffer size returned by LocateHandle() is correctly
> converted to a count during a subsequent comparison, it is incorrectly
> passed "as is" as a count to later calls to find_in_buffer().
>
> Finally, the variables usage during this test step is misleading, as the
> `buffer_size' variable is used to hold a count, and the `count' variable is
> used to hold a buffer size.
>
> Fix all those issues at once, and remove also one copy to buffer_size,
> which has now become unnecessary.
>
> Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Cc: Tom Rini <trini@konsulko.com>
> ---
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> lib/efi_selftest/efi_selftest_manageprotocols.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
> index 7fe7b285011..f07ff256ce1 100644
> --- a/lib/efi_selftest/efi_selftest_manageprotocols.c
> +++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
> @@ -170,7 +170,6 @@ static int execute(void)
> efi_st_error("LocateHandleBuffer with AllHandles failed\n");
> return EFI_ST_FAILURE;
> }
> - buffer_size = count;
> ret = find_in_buffer(handle1, count, buffer);
> if (ret != EFI_SUCCESS) {
> efi_st_error("LocateHandleBuffer failed to locate new handle\n");
> @@ -245,14 +244,15 @@ static int execute(void)
> /*
> * Test LocateHandle with ByProtocol
> */
> - count = buffer_size * sizeof(efi_handle_t);
> + buffer_size = count * sizeof(efi_handle_t);
> ret = boottime->locate_handle(BY_PROTOCOL, &guid1, NULL,
> - &count, buffer);
> + &buffer_size, buffer);
> if (ret != EFI_SUCCESS) {
> efi_st_error("LocateHandle with ByProtocol failed\n");
> return EFI_ST_FAILURE;
> }
> - if (count / sizeof(efi_handle_t) != 2) {
> + count = buffer_size / sizeof(efi_handle_t);
> + if (count != 2) {
> efi_st_error("LocateHandle failed to locate new handles\n");
> return EFI_ST_FAILURE;
> }
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 5/5] efi_selftest: cosmetic: fix spelling in comments
2026-02-19 18:43 [PATCH 0/5] efi_selftest: manageprotocols fixes and enhancements Vincent Stehlé
` (3 preceding siblings ...)
2026-02-19 18:43 ` [PATCH 4/5] efi_selftest: fix buffer size and count computations Vincent Stehlé
@ 2026-02-19 18:44 ` Vincent Stehlé
2026-02-20 7:42 ` Ilias Apalodimas
2026-02-24 15:55 ` Heinrich Schuchardt
4 siblings, 2 replies; 14+ messages in thread
From: Vincent Stehlé @ 2026-02-19 18:44 UTC (permalink / raw)
To: u-boot; +Cc: Vincent Stehlé, Heinrich Schuchardt, Ilias Apalodimas,
Tom Rini
Fix a few UEFI function names, as well as a typo.
Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
---
lib/efi_selftest/efi_selftest_manageprotocols.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
index f07ff256ce1..a096e8c2b01 100644
--- a/lib/efi_selftest/efi_selftest_manageprotocols.c
+++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
@@ -6,7 +6,7 @@
*
* This unit test checks the following protocol services:
* InstallProtocolInterface, UninstallProtocolInterface,
- * InstallMultipleProtocolsInterfaces, UninstallMultipleProtocolsInterfaces,
+ * InstallMultipleProtocolInterfaces, UninstallMultipleProtocolInterfaces,
* HandleProtocol, ProtocolsPerHandle,
* LocateHandle, LocateHandleBuffer.
*/
@@ -188,7 +188,7 @@ static int execute(void)
}
/*
- * Test error handling in UninstallMultipleProtocols
+ * Test error handling in UninstallMultipleProtocolInterfaces
*
* These are the installed protocol interfaces on handle 2:
*
@@ -238,7 +238,7 @@ static int execute(void)
efi_st_error("LocateHandleBuffer failed to locate new handle\n");
return EFI_ST_FAILURE;
}
- /* Clear the buffer, we are reusing it it the next step. */
+ /* Clear the buffer, we are reusing it in the next step. */
boottime->set_mem(buffer, sizeof(efi_handle_t) * count, 0);
/*
@@ -287,7 +287,7 @@ static int execute(void)
}
/*
- * Test UninstallMultipleProtocols
+ * Test UninstallMultipleProtocolInterfaces
*/
ret = boottime->uninstall_multiple_protocol_interfaces(
handle2,
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH 5/5] efi_selftest: cosmetic: fix spelling in comments
2026-02-19 18:44 ` [PATCH 5/5] efi_selftest: cosmetic: fix spelling in comments Vincent Stehlé
@ 2026-02-20 7:42 ` Ilias Apalodimas
2026-02-24 15:55 ` Heinrich Schuchardt
1 sibling, 0 replies; 14+ messages in thread
From: Ilias Apalodimas @ 2026-02-20 7:42 UTC (permalink / raw)
To: Vincent Stehlé, u-boot
Cc: Heinrich Schuchardt, Ilias Apalodimas, Tom Rini
On Thu Feb 19, 2026 at 8:44 PM EET, Vincent Stehlé wrote:
> Fix a few UEFI function names, as well as a typo.
>
> Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Cc: Tom Rini <trini@konsulko.com>
> ---
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> lib/efi_selftest/efi_selftest_manageprotocols.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
> index f07ff256ce1..a096e8c2b01 100644
> --- a/lib/efi_selftest/efi_selftest_manageprotocols.c
> +++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
> @@ -6,7 +6,7 @@
> *
> * This unit test checks the following protocol services:
> * InstallProtocolInterface, UninstallProtocolInterface,
> - * InstallMultipleProtocolsInterfaces, UninstallMultipleProtocolsInterfaces,
> + * InstallMultipleProtocolInterfaces, UninstallMultipleProtocolInterfaces,
> * HandleProtocol, ProtocolsPerHandle,
> * LocateHandle, LocateHandleBuffer.
> */
> @@ -188,7 +188,7 @@ static int execute(void)
> }
>
> /*
> - * Test error handling in UninstallMultipleProtocols
> + * Test error handling in UninstallMultipleProtocolInterfaces
> *
> * These are the installed protocol interfaces on handle 2:
> *
> @@ -238,7 +238,7 @@ static int execute(void)
> efi_st_error("LocateHandleBuffer failed to locate new handle\n");
> return EFI_ST_FAILURE;
> }
> - /* Clear the buffer, we are reusing it it the next step. */
> + /* Clear the buffer, we are reusing it in the next step. */
> boottime->set_mem(buffer, sizeof(efi_handle_t) * count, 0);
>
> /*
> @@ -287,7 +287,7 @@ static int execute(void)
> }
>
> /*
> - * Test UninstallMultipleProtocols
> + * Test UninstallMultipleProtocolInterfaces
> */
> ret = boottime->uninstall_multiple_protocol_interfaces(
> handle2,
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 5/5] efi_selftest: cosmetic: fix spelling in comments
2026-02-19 18:44 ` [PATCH 5/5] efi_selftest: cosmetic: fix spelling in comments Vincent Stehlé
2026-02-20 7:42 ` Ilias Apalodimas
@ 2026-02-24 15:55 ` Heinrich Schuchardt
1 sibling, 0 replies; 14+ messages in thread
From: Heinrich Schuchardt @ 2026-02-24 15:55 UTC (permalink / raw)
To: Vincent Stehlé
Cc: Heinrich Schuchardt, Ilias Apalodimas, Tom Rini, u-boot
On 2/19/26 19:44, Vincent Stehlé wrote:
> Fix a few UEFI function names, as well as a typo.
>
> Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> lib/efi_selftest/efi_selftest_manageprotocols.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
> index f07ff256ce1..a096e8c2b01 100644
> --- a/lib/efi_selftest/efi_selftest_manageprotocols.c
> +++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
> @@ -6,7 +6,7 @@
> *
> * This unit test checks the following protocol services:
> * InstallProtocolInterface, UninstallProtocolInterface,
> - * InstallMultipleProtocolsInterfaces, UninstallMultipleProtocolsInterfaces,
> + * InstallMultipleProtocolInterfaces, UninstallMultipleProtocolInterfaces,
> * HandleProtocol, ProtocolsPerHandle,
> * LocateHandle, LocateHandleBuffer.
> */
> @@ -188,7 +188,7 @@ static int execute(void)
> }
>
> /*
> - * Test error handling in UninstallMultipleProtocols
> + * Test error handling in UninstallMultipleProtocolInterfaces
> *
> * These are the installed protocol interfaces on handle 2:
> *
> @@ -238,7 +238,7 @@ static int execute(void)
> efi_st_error("LocateHandleBuffer failed to locate new handle\n");
> return EFI_ST_FAILURE;
> }
> - /* Clear the buffer, we are reusing it it the next step. */
> + /* Clear the buffer, we are reusing it in the next step. */
> boottime->set_mem(buffer, sizeof(efi_handle_t) * count, 0);
>
> /*
> @@ -287,7 +287,7 @@ static int execute(void)
> }
>
> /*
> - * Test UninstallMultipleProtocols
> + * Test UninstallMultipleProtocolInterfaces
> */
> ret = boottime->uninstall_multiple_protocol_interfaces(
> handle2,
^ permalink raw reply [flat|nested] 14+ messages in thread