All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efi/libstub: prevent read overflow in find_file_option()
@ 2021-04-23 11:48 Dan Carpenter
  2021-05-10 15:38 ` Ard Biesheuvel
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-04-23 11:48 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Arvind Sankar, Philipp Fent, linux-efi, linux-kernel, kernel-janitors

If the buffer has slashes up to the end then this will read past the end
of the array.  I don't anticipate that this is an issue for many people
in real life, but it's the right thing to do and it makes static
checkers happy.

Fixes: 7a88a6227dc7 ("efi/libstub: Fix path separator regression")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/firmware/efi/libstub/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/libstub/file.c b/drivers/firmware/efi/libstub/file.c
index 4e81c6077188..dd95f330fe6e 100644
--- a/drivers/firmware/efi/libstub/file.c
+++ b/drivers/firmware/efi/libstub/file.c
@@ -103,7 +103,7 @@ static int find_file_option(const efi_char16_t *cmdline, int cmdline_len,
 		return 0;
 
 	/* Skip any leading slashes */
-	while (cmdline[i] == L'/' || cmdline[i] == L'\\')
+	while (i < cmdline_len && (cmdline[i] == L'/' || cmdline[i] == L'\\'))
 		i++;
 
 	while (--result_len > 0 && i < cmdline_len) {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] efi/libstub: prevent read overflow in find_file_option()
  2021-04-23 11:48 [PATCH] efi/libstub: prevent read overflow in find_file_option() Dan Carpenter
@ 2021-05-10 15:38 ` Ard Biesheuvel
  0 siblings, 0 replies; 2+ messages in thread
From: Ard Biesheuvel @ 2021-05-10 15:38 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Arvind Sankar, Philipp Fent, linux-efi,
	Linux Kernel Mailing List, kernel-janitors

On Fri, 23 Apr 2021 at 13:48, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> If the buffer has slashes up to the end then this will read past the end
> of the array.  I don't anticipate that this is an issue for many people
> in real life, but it's the right thing to do and it makes static
> checkers happy.
>
> Fixes: 7a88a6227dc7 ("efi/libstub: Fix path separator regression")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/firmware/efi/libstub/file.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/efi/libstub/file.c b/drivers/firmware/efi/libstub/file.c
> index 4e81c6077188..dd95f330fe6e 100644
> --- a/drivers/firmware/efi/libstub/file.c
> +++ b/drivers/firmware/efi/libstub/file.c
> @@ -103,7 +103,7 @@ static int find_file_option(const efi_char16_t *cmdline, int cmdline_len,
>                 return 0;
>
>         /* Skip any leading slashes */
> -       while (cmdline[i] == L'/' || cmdline[i] == L'\\')
> +       while (i < cmdline_len && (cmdline[i] == L'/' || cmdline[i] == L'\\'))
>                 i++;
>
>         while (--result_len > 0 && i < cmdline_len) {
> --
> 2.30.2
>

Thanks Dan, I will queue this up.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-10 15:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23 11:48 [PATCH] efi/libstub: prevent read overflow in find_file_option() Dan Carpenter
2021-05-10 15:38 ` Ard Biesheuvel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.