All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fastboot: fix partition name truncation in environment lookup
@ 2021-07-30 12:23 Matthias Schiffer
  2021-07-30 14:04 ` Sean Anderson
  2021-10-13 14:16 ` Tom Rini
  0 siblings, 2 replies; 4+ messages in thread
From: Matthias Schiffer @ 2021-07-30 12:23 UTC (permalink / raw)
  To: u-boot; +Cc: Sean Anderson, Matthias Schiffer

strlcat() need to be passed the full buffer length. The incorrect call
caused truncation of partition names for fastboot_raw_partition_... and
fastboot_partition_alias_... env lookup to much less than PART_NAME_LEN.

Fixes: 69a752983171 ("fastboot: Fix possible buffer overrun")
Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---
 drivers/fastboot/fb_mmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index 2f3837e559..33fd6c21af 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -40,7 +40,7 @@ static int raw_part_get_info_by_name(struct blk_desc *dev_desc,
 
 	/* check for raw partition descriptor */
 	strcpy(env_desc_name, "fastboot_raw_partition_");
-	strlcat(env_desc_name, name, PART_NAME_LEN);
+	strlcat(env_desc_name, name, sizeof(env_desc_name));
 	raw_part_desc = strdup(env_get(env_desc_name));
 	if (raw_part_desc == NULL)
 		return -ENODEV;
@@ -114,7 +114,7 @@ static int part_get_info_by_name_or_alias(struct blk_desc **dev_desc,
 
 		/* check for alias */
 		strcpy(env_alias_name, "fastboot_partition_alias_");
-		strlcat(env_alias_name, name, PART_NAME_LEN);
+		strlcat(env_alias_name, name, sizeof(env_alias_name));
 		aliased_part_name = env_get(env_alias_name);
 		if (aliased_part_name != NULL)
 			ret = do_get_part_info(dev_desc, aliased_part_name,
-- 
2.17.1


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

* Re: [PATCH] fastboot: fix partition name truncation in environment lookup
  2021-07-30 12:23 [PATCH] fastboot: fix partition name truncation in environment lookup Matthias Schiffer
@ 2021-07-30 14:04 ` Sean Anderson
  2021-09-28 12:21   ` Matthias Schiffer
  2021-10-13 14:16 ` Tom Rini
  1 sibling, 1 reply; 4+ messages in thread
From: Sean Anderson @ 2021-07-30 14:04 UTC (permalink / raw)
  To: Matthias Schiffer, u-boot

On 7/30/21 8:23 AM, Matthias Schiffer wrote:
> strlcat() need to be passed the full buffer length. The incorrect call
> caused truncation of partition names for fastboot_raw_partition_... and
> fastboot_partition_alias_... env lookup to much less than PART_NAME_LEN.
> 
> Fixes: 69a752983171 ("fastboot: Fix possible buffer overrun")
> Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
> ---
>   drivers/fastboot/fb_mmc.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
> index 2f3837e559..33fd6c21af 100644
> --- a/drivers/fastboot/fb_mmc.c
> +++ b/drivers/fastboot/fb_mmc.c
> @@ -40,7 +40,7 @@ static int raw_part_get_info_by_name(struct blk_desc *dev_desc,
>   
>   	/* check for raw partition descriptor */
>   	strcpy(env_desc_name, "fastboot_raw_partition_");
> -	strlcat(env_desc_name, name, PART_NAME_LEN);
> +	strlcat(env_desc_name, name, sizeof(env_desc_name));
>   	raw_part_desc = strdup(env_get(env_desc_name));
>   	if (raw_part_desc == NULL)
>   		return -ENODEV;
> @@ -114,7 +114,7 @@ static int part_get_info_by_name_or_alias(struct blk_desc **dev_desc,
>   
>   		/* check for alias */
>   		strcpy(env_alias_name, "fastboot_partition_alias_");
> -		strlcat(env_alias_name, name, PART_NAME_LEN);
> +		strlcat(env_alias_name, name, sizeof(env_alias_name));
>   		aliased_part_name = env_get(env_alias_name);
>   		if (aliased_part_name != NULL)
>   			ret = do_get_part_info(dev_desc, aliased_part_name,
> 

Reviewed-by: Sean Anderson <seanga2@gmail.com>

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

* Re: [PATCH] fastboot: fix partition name truncation in environment lookup
  2021-07-30 14:04 ` Sean Anderson
@ 2021-09-28 12:21   ` Matthias Schiffer
  0 siblings, 0 replies; 4+ messages in thread
From: Matthias Schiffer @ 2021-09-28 12:21 UTC (permalink / raw)
  To: Sean Anderson, u-boot

On Fri, 2021-07-30 at 10:04 -0400, Sean Anderson wrote:
> On 7/30/21 8:23 AM, Matthias Schiffer wrote:
> > strlcat() need to be passed the full buffer length. The incorrect call
> > caused truncation of partition names for fastboot_raw_partition_... and
> > fastboot_partition_alias_... env lookup to much less than PART_NAME_LEN.
> > 
> > Fixes: 69a752983171 ("fastboot: Fix possible buffer overrun")
> > Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
> > ---
> >   drivers/fastboot/fb_mmc.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
> > index 2f3837e559..33fd6c21af 100644
> > --- a/drivers/fastboot/fb_mmc.c
> > +++ b/drivers/fastboot/fb_mmc.c
> > @@ -40,7 +40,7 @@ static int raw_part_get_info_by_name(struct blk_desc *dev_desc,
> >   
> >   	/* check for raw partition descriptor */
> >   	strcpy(env_desc_name, "fastboot_raw_partition_");
> > -	strlcat(env_desc_name, name, PART_NAME_LEN);
> > +	strlcat(env_desc_name, name, sizeof(env_desc_name));
> >   	raw_part_desc = strdup(env_get(env_desc_name));
> >   	if (raw_part_desc == NULL)
> >   		return -ENODEV;
> > @@ -114,7 +114,7 @@ static int part_get_info_by_name_or_alias(struct blk_desc **dev_desc,
> >   
> >   		/* check for alias */
> >   		strcpy(env_alias_name, "fastboot_partition_alias_");
> > -		strlcat(env_alias_name, name, PART_NAME_LEN);
> > +		strlcat(env_alias_name, name, sizeof(env_alias_name));
> >   		aliased_part_name = env_get(env_alias_name);
> >   		if (aliased_part_name != NULL)
> >   			ret = do_get_part_info(dev_desc, aliased_part_name,
> > 
> 
> Reviewed-by: Sean Anderson <seanga2@gmail.com>

Hi,
what's the status here? It would be great to have this bugfix in the
next release.

Regards,
Matthias


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

* Re: [PATCH] fastboot: fix partition name truncation in environment lookup
  2021-07-30 12:23 [PATCH] fastboot: fix partition name truncation in environment lookup Matthias Schiffer
  2021-07-30 14:04 ` Sean Anderson
@ 2021-10-13 14:16 ` Tom Rini
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Rini @ 2021-10-13 14:16 UTC (permalink / raw)
  To: Matthias Schiffer; +Cc: u-boot, Sean Anderson

[-- Attachment #1: Type: text/plain, Size: 535 bytes --]

On Fri, Jul 30, 2021 at 02:23:54PM +0200, Matthias Schiffer wrote:

> strlcat() need to be passed the full buffer length. The incorrect call
> caused truncation of partition names for fastboot_raw_partition_... and
> fastboot_partition_alias_... env lookup to much less than PART_NAME_LEN.
> 
> Fixes: 69a752983171 ("fastboot: Fix possible buffer overrun")
> Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
> Reviewed-by: Sean Anderson <seanga2@gmail.com>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

end of thread, other threads:[~2021-10-13 14:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30 12:23 [PATCH] fastboot: fix partition name truncation in environment lookup Matthias Schiffer
2021-07-30 14:04 ` Sean Anderson
2021-09-28 12:21   ` Matthias Schiffer
2021-10-13 14:16 ` Tom Rini

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.