Skip to contentSkip to conversation

package/bootgen: add patch to fix crash with -verify

Buildroot Peter Korsgaard 2 participants 3 messages Oct 23, 2024 – Oct 25, 2024

lore
Share & tools
lore
#0 lore raw

The 2023.2 version forgets to populate the iHT structure before accessing it, leading to a segfault. Add a patch submitted upstream to fix that.

Notice that this is fixed in the 2024.1 version as there ReadBinaryFile() now calls ReadHeaderTableDetails():

https://github.com/Xilinx/bootgen/commit/3a0f879c611d67072aad3461f1c72d1a284cd5fc#diff-404aa20e03f1035b725ac1ea6e64c28477bb65c1663da67f64ffdb1a60552cee

---
 ...segmentation-fault-that-occurs-durin.patch | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 package/bootgen/0001-verifyimage-Fix-segmentation-fault-that-occurs-durin.patch
package/bootgen/0001-verifyimage-Fix-segmentation-fault-that-occurs-durin.patch new file +50 -0
new file mode 100644
index 0000000000..096dbac27e
@@ -0,0 +1,50 @@
+From f7825edbd1c85380cfb5ef0cf2c16c910954f57c Mon Sep 17 00:00:00 2001
+From: Charlie Johnston <[email protected]>
+Date: Mon, 5 Aug 2024 13:07:25 -0700
+Subject: [PATCH] verifyimage: Fix segmentation fault that occurs during
+ verifyimage.
+
+In commit d02322b, the behavior of ReadBinaryFile was changed such
+that it no longer populated iHT. This caused VerifyAuthentication
+to access a null iHT value resulting a segmentation fault.
+
+This fix changes VerifyAuthentication to call ReadHeaderTableDetails
+instead, where the old functionality of ReadBinaryFile now lives.
+
+Signed-off-by: Charlie Johnston <[email protected]>
+Signed-off-by: Peter Korsgaard <[email protected]>
+Upstream: https://github.com/Xilinx/bootgen/pull/36
+---
+ verifyimage-versal.cpp | 2 +-
+ verifyimage-zynqmp.cpp | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/verifyimage-versal.cpp b/verifyimage-versal.cpp
+index 5490663..5656e50 100755
+--- a/verifyimage-versal.cpp
++++ b/verifyimage-versal.cpp
+@@ -34,7 +34,7 @@
+ /*******************************************************************************/
+ void VersalReadImage::VerifyAuthentication(bool verifyImageOption)
+ {
+-    ReadBinaryFile();
++    ReadHeaderTableDetails();
+ 
+     if (iHT->headerAuthCertificateWordOffset != 0)
+     {
+diff --git a/verifyimage-zynqmp.cpp b/verifyimage-zynqmp.cpp
+index d4812e6..d73272c 100755
+--- a/verifyimage-zynqmp.cpp
++++ b/verifyimage-zynqmp.cpp
+@@ -50,7 +50,7 @@ static void RearrangeEndianess(uint8_t *array, uint32_t size)
+ /*******************************************************************************/
+ void ZynqMpReadImage::VerifyAuthentication(bool verifyImageOption)
+ {
+-    ReadBinaryFile();
++    ReadHeaderTableDetails();
+ 
+     if (iHT->headerAuthCertificateWordOffset != 0)
+     {
+-- 
+2.39.5
+
Signature · 6 lines
2.39.5

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Reviewed-by Neal Frager
#1 lore raw

Hi Peter

Quoted 9 lines

The 2023.2 version forgets to populate the iHT structure before accessing it, leading to a segfault. Add a patch submitted upstream to fix that.

Notice that this is fixed in the 2024.1 version as there ReadBinaryFile() now calls ReadHeaderTableDetails():

https://github.com/Xilinx/bootgen/commit/3a0f879c611d67072aad3461f1c72d1a284cd5fc#diff-404aa20e03f1035b725ac1ea6e64c28477bb65c1663da67f64ffdb1a60552cee

Excellent job identifying this issue!

Best regards,
Neal Frager
AMD
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Frager," == Frager, Neal <[email protected]> writes:

Hi Peter

Quoted 2 lines

The 2023.2 version forgets to populate the iHT structure before accessing it, leading to a segfault. Add a patch submitted upstream to fix that.

Quoted 8 lines
Quoted 6 lines

Notice that this is fixed in the 2024.1 version as there ReadBinaryFile() now calls ReadHeaderTableDetails():

https://github.com/Xilinx/bootgen/commit/3a0f879c611d67072aad3461f1c72d1a284cd5fc#diff-404aa20e03f1035b725ac1ea6e64c28477bb65c1663da67f64ffdb1a60552cee

Excellent job identifying this issue!

It is quite obvious as bootgen crashes right away when used with the -verify option ;)

Quoted 1 line

Committed to 2024.02.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot