Skip to contentSkip to conversation

Common:fdt: Check for error return

PATCH New Hongwei Zhang 3 participants 7 messages Dec 2, 2020 – Dec 23, 2020

lore
Share & tools
lore
#0 lore raw

cover Common:fdt: Check for error return

Hello Reviewer,

Check for negative return value of fdt_noffset from calling boot_get_fdt_fit(). Otherwise, when fdt subimage is corrupted, the u-boot report bad hash value but continue loading kernel image and get hanged later.

Hongwei Zhang (1):
Common:fdt: Check for error return value

 common/image-fdt.c | 3 +++
 1 file changed, 3 insertions(+)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 Common:fdt: Check for error return value

Check for negative return value of fdt_noffset from calling boot_get_fdt_fit().

---
 common/image-fdt.c | 3 +++
 1 file changed, 3 insertions(+)
common/image-fdt.c +3 -0
index 01186aeac7..52ada56fc1 100644
@@ -402,6 +402,9 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
 					&fit_uname_config,
 					arch, &load, &len);
 
+				if (fdt_noffset < 0)
+					goto error;
+
 				images->fit_hdr_fdt = map_sysmem(fdt_addr, 0);
 				images->fit_uname_fdt = fit_uname_fdt;
 				images->fit_noffset_fdt = fdt_noffset;
Signature · 1 line
2.17.1
#3 lore raw

PATCH 1/1 Common:fdt: Check for error return value

Quoted 6 lines · Simon Glass
Quoted 4 lines · Hongwei Zhang

Check for negative return value of fdt_noffset from calling boot_get_fdt_fit().

Quoted 7 lines
Quoted 5 lines
---
 common/image-fdt.c | 3 +++
 1 file changed, 3 insertions(+)

Applied to u-boot-dm/next, thanks!

#4 lore raw

cover Common:fdt: Check for error return

In reply to Hongwei Zhang

Hello Hongwei,

Quoted 7 lines · Hongwei Zhang

Hello Reviewer,

Check for negative return value of fdt_noffset from calling boot_get_fdt_fit(). Otherwise, when fdt subimage is corrupted, the u-boot report bad hash value but continue loading kernel image and get hanged later.

I can see from your subject line that you intended this to go to Aspeed's fork of u-boot. That's fine, but you shouldn't cc the upstream maintainers as they don't care for these changes.

If the bug exists in mainline u-boot, you should certainly send the fix there and ask for it to be backported to the aspeed fork.

Cheers,

Joel

Quoted 10 lines

Hongwei Zhang (1):
Common:fdt: Check for error return value

 common/image-fdt.c | 3 +++
 1 file changed, 3 insertions(+)

--
2.17.1

#5 lore raw

cover Common:fdt: Check for error return

In reply to Hongwei Zhang

Thanks Joel,

Quoted 15 lines

From: Joel Stanley <[email protected]>
Sent: Wednesday, December 2, 2020 9:17 PM
To: Hongwei Zhang

Hello Hongwei,

Quoted 7 lines · Hongwei Zhang

Hello Reviewer,

Check for negative return value of fdt_noffset from calling boot_get_fdt_fit(). Otherwise, when fdt subimage is corrupted, the u-boot report bad hash value but continue loading kernel image and get hanged later.

Quoted 6 lines

I can see from your subject line that you intended this to go to Aspeed's fork of u-boot. That's fine, but you shouldn't cc the upstream maintainers as they don't care for these changes.

If the bug exists in mainline u-boot, you should certainly send the fix there and ask for it to be backported to the aspeed fork.

I think this issue existing in mainline u-boot, however, I have difficulty to include 'master' branch of u-boot in openbmc project, to acturaly test it. There are compiling errors.

Also, I'm not sure for mainline u-boot, which branch should I use to test and verification? is it 'master', or 'next' branch?

--Hongwei

Quoted 15 lines

Cheers,

Joel

Quoted 10 lines

Hongwei Zhang (1):
Common:fdt: Check for error return value

 common/image-fdt.c | 3 +++
 1 file changed, 3 insertions(+)

--
2.17.1

#6 lore raw

cover Common:fdt: Check for error return

Quoted 25 lines · Hongwei Zhang

Thanks Joel,

Quoted 15 lines
From: Joel Stanley <[email protected]>
Sent: Wednesday, December 2, 2020 9:17 PM
To:   Hongwei Zhang

Hello Hongwei,

Quoted 7 lines · Hongwei Zhang

Hello Reviewer,

Check for negative return value of fdt_noffset from calling boot_get_fdt_fit(). Otherwise, when fdt subimage is corrupted, the u-boot report bad hash value but continue loading kernel image and get hanged later.

Quoted 6 lines

I can see from your subject line that you intended this to go to Aspeed's fork of u-boot. That's fine, but you shouldn't cc the upstream maintainers as they don't care for these changes.

If the bug exists in mainline u-boot, you should certainly send the fix there and ask for it to be backported to the aspeed fork.

Quoted 6 lines

I think this issue existing in mainline u-boot, however, I have difficulty to include 'master' branch of u-boot in openbmc project, to acturaly test it. There are compiling errors.

Also, I'm not sure for mainline u-boot, which branch should I use to test and verification? is it 'master', or 'next' branch?

I suspect it doesn't matter much. As this is a small fix, I would chose to send it to master. (I see that's what you did)

Quoted 17 lines

--Hongwei

Quoted 15 lines

Cheers,

Joel

Quoted 10 lines

Hongwei Zhang (1):
Common:fdt: Check for error return value

 common/image-fdt.c | 3 +++
 1 file changed, 3 insertions(+)

--
2.17.1