Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-verify crashes on ZynqMP boot.bin file #30

Open
amworsley opened this issue Mar 8, 2024 · 4 comments
Open

-verify crashes on ZynqMP boot.bin file #30

amworsley opened this issue Mar 8, 2024 · 4 comments

Comments

@amworsley
Copy link

The -verify option was crashes bootgen on a ZynqMP boot.bin file as the code wasn't
reading the image headers. Please find the following patch which fixed the problem:

From c6091d880c65665d1752c295b0c6c0f852b9afa8 Mon Sep 17 00:00:00 2001
From: Andrew Worsley <[email protected]>
Date: Fri, 8 Mar 2024 12:39:31 +1100
Subject: [PATCH 1/2] Fix segfault in -verify option

Code wasn't reading in the boot.bin image file headers for the -verify option
So add in a call to ReadHeaderTableDetails() prior to ReadPartitions() which
assumes the iHT (Image Header Table) pointer has been initialised.
With out this it results in the following crash:

(gdb) run -arch zynqmp -verify  BOOT-zub1cg-rsa-new.bin -log trace
Starting program: /home/amw/work/src/bootgen/bootgen -arch zynqmp -verify  BOOT-zub1cg-rsa-new.bin -log trace
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

****** Bootgen v2023.2
  **** Build date : Mar  6 2024-17:46:38
    ** Copyright 1986-2022 Xilinx, Inc. All Rights Reserved.
    ** Copyright 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.

[TRACE]  : Command Line parsing started
[TRACE]  : Command: -arch zynqmp -verify BOOT-zub1cg-rsa-new.bin -log trace
[INFO]   : Command line parsing completed successfully

Program received signal SIGSEGV, Segmentation fault.
0x000055555564c452 in ZynqMpReadImage::VerifyAuthentication (this=0x55555572fa30,
    verifyImageOption=true) at verifyimage-zynqmp.cpp:55
55          if (iHT->headerAuthCertificateWordOffset != 0)
(gdb) p iHT
$1 = (ZynqMpImageHeaderTableStructure *) 0x0
(gdb) bt
    verifyImageOption=true) at verifyimage-zynqmp.cpp:55
    at main.cpp:73
---
 readimage-zynqmp.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/readimage-zynqmp.cpp b/readimage-zynqmp.cpp
index af6993d..17e5896 100755
--- a/readimage-zynqmp.cpp
+++ b/readimage-zynqmp.cpp
@@ -100,6 +100,7 @@ void ZynqMpReadImage::ReadBinaryFile(DumpOption::Type dump, std::string path)
     {
         LOG_ERROR("The option '-read/-dump' is not supported on mcs format file : %s", binFilename.c_str());
     }
+    ReadHeaderTableDetails();
     ReadPartitions();
 }
 /*******************************************************************************/
-- 
2.30.2
@c0d3d
Copy link

c0d3d commented Mar 18, 2024

@amworsley thanks, I had a different patch that I was going to submit, but yours looks better.
I just made the PR in the hopes that they will merge it sooner

@RamyaDarapuneni
Copy link
Collaborator

Hi, we have an internal bug reported on the same and we are reviewing this. We will make sure to close ASAP.

@embetrix
Copy link

This piece of Software is sadly released to customers without a minimal Test + Verification !!!

@c0d3d
Copy link

c0d3d commented Apr 23, 2024

@RamyaDarapuneni can you look at the PR I put up, it's just the change that @amworsley posted in the description of this issue. (here: #31)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants