-
Notifications
You must be signed in to change notification settings - Fork 133
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
fdtdump.c: provide colored output #3
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A new command line option is added -c, --color <arg> Colorize, argument can be auto, never or always which defaults to auto. For colored output in pipes use 'always', e.g. fdtdump -c always file.dtb | less -R If you don't like colors use alias fdtdump="fdtdump -c none" Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
PeterPawn
added a commit
to PeterPawn/dtc
that referenced
this pull request
Jun 22, 2022
- This is the 1st commit message: fitdump: add some patches for a new utility 'fitdump', which may be used to dissect AVM's 'fit-image' files While the first magic (0xfeed000d) at offset 0x0 and the data length (uint32) following this magic are obvious, the meaning of the following 64 bytes (or 512 bits) is still unknown - due to its size and position, together with the length at offset 0x4 equal to the FDT payload size, it looks to me like an attempt to secure the whole image with any sort of cryptographic operation. And because it seems not to be a simple hash value from any algorithm with 512 bits output length (e.g. SHA(2)-512) and it's not an ASN.1 structure, too, I'd tend to think, it's an encrypted version of a hash value, while the bootloader carries a key necessary to decrypt it - on the other hand the length of 512 bits looks a bit too small for "traditional" (effective) public key methods like RSA. But more modern methods like ED25519 could result in 64 bytes of signature while maintaining a secure public key processing. But it looks like this value doesn't really matter (yet) - at least there was success replacing the firmware without any visible attempt to compute (and opt. sign) the value from offset 0x8 to 0x48 - this would imply, that the bootloader doesn't check it really (at least not yet). https://github.com/Freetz-NG/freetz-ng/issues/465 The task to find the public key in EVA code would remain ... if the thoughts above should be true at all. --- The 'fitdump' command loads the specified file as FIT image and creates a sub-directory `fit-dump` in the current working directory. It scans the input data automatically for the FDT signature and writes the structure needed to rebuild the image (only the FDT-formatted parts) to file 'image.its', which may be used later with U-boot's 'mkimage' utility. Any binary image data (with a size greater than 512 bytes) will be written to its own file (image_nnn.bin), while the 'its'-file gets a '/incbin/' item at this place to include the file. The sub-directory `fit-dump` has to be non-existent at time of call and will get created during processing. The file-names are held as easy as possible, each new file increments the number 'nnn' (it starts with 001) by one. If anyone would like more descriptive file-names, the 'image.its' file and the names of created BLOB files may be changed after this program was finished. TODO: enhance parameters with an option to define the output directory name and path - This is the commit message dgibson#2: fitdump: add comment with image size to /incbin/ statements - This is the commit message dgibson#3: fitdump.c: set access flags (0640) on created image BLOB files - This is the commit message dgibson#4: fitdump.c: add option '-n' to use image file names based on node names Example of output: vidar:/home/GitHub/YourFritz/fit_tools/fit-images/FB5590 $ grep -r incbin fit-dump/image.its; ls -l fit-dump data = /incbin/("qcaarmv8_HW272_kernel.image"); // size: 3390019 data = /incbin/("qcaarmv8_HW272_flat_dt_0.image"); // size: 16264 data = /incbin/("qcaarmv8_HW272_squashFS_filesystem.image"); // size: 28053504 data = /incbin/("prxB_HW0273_kernel.image"); // size: 1192159 data = /incbin/("prxB_HW0273_flat_dt_0.image"); // size: 1118 data = /incbin/("prxB_HW0273_ramdisk.image"); // size: 992871 data = /incbin/("prxI_HW273_kernel.image"); // size: 3343580 data = /incbin/("prxI_HW273_flat_dt_0_pon.image"); // size: 7130 data = /incbin/("prxI_HW273_flat_dt_0_aon.image"); // size: 7124 data = /incbin/("prxI_HW273_squashFS_filesystem.image"); // size: 7917568 total 43892 -rw-r--r-- 1 peh users 7551 Jun 22 12:51 image.its -rw-r----- 1 peh users 1118 Jun 22 12:51 prxB_HW0273_flat_dt_0.image -rw-r----- 1 peh users 1192159 Jun 22 12:51 prxB_HW0273_kernel.image -rw-r----- 1 peh users 992871 Jun 22 12:51 prxB_HW0273_ramdisk.image -rw-r----- 1 peh users 7124 Jun 22 12:51 prxI_HW273_flat_dt_0_aon.image -rw-r----- 1 peh users 7130 Jun 22 12:51 prxI_HW273_flat_dt_0_pon.image -rw-r----- 1 peh users 3343580 Jun 22 12:51 prxI_HW273_kernel.image -rw-r----- 1 peh users 7917568 Jun 22 12:51 prxI_HW273_squashFS_filesystem.image -rw-r----- 1 peh users 16264 Jun 22 12:51 qcaarmv8_HW272_flat_dt_0.image -rw-r----- 1 peh users 3390019 Jun 22 12:51 qcaarmv8_HW272_kernel.image -rw-r----- 1 peh users 28053504 Jun 22 12:51 qcaarmv8_HW272_squashFS_filesystem.image vidar:/home/GitHub/YourFritz/fit_tools/fit-images/FB5590 $
elmarco
added a commit
to elmarco/dtc
that referenced
this pull request
Feb 28, 2023
./dtc -I dts -O dtb -o aliases.dtb /home/elmarco/src/dtc/tests/aliases.dts ================================================================= ==882911==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000113 at pc 0x7f34ba0abf50 bp 0x7ffc8db22450 sp 0x7ffc8db21c00 READ of size 4 at 0x602000000113 thread T0 #0 0x7f34ba0abf4f in MemcmpInterceptorCommon(void*, int (*)(void const*, void const*, unsigned long), void const*, void const*, unsigned long) (/lib64/libasan.so.8+0xabf4f) #1 0x7f34ba0ac5e8 in memcmp (/lib64/libasan.so.8+0xac5e8) dgibson#2 0x4282dc in check_spi_bus_bridge ../checks.c:1110 dgibson#3 0x41b08d in check_nodes_props ../checks.c:140 dgibson#4 0x41b9c4 in run_check ../checks.c:180 dgibson#5 0x430a3b in process_checks ../checks.c:2056 dgibson#6 0x436a90 in main ../dtc.c:327 dgibson#7 0x7f34b964a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f) dgibson#8 0x7f34b964a5c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x275c8) dgibson#9 0x4025c4 in _start (/home/elmarco/src/dtc/build/dtc+0x4025c4) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
elmarco
added a commit
to elmarco/dtc
that referenced
this pull request
Feb 28, 2023
./dtc -I dts -O dtb -o overlay_base_manual_symbols.test.dtb /home/elmarco/src/dtc/tests/overlay_base_manual_symbols.dts ../data.c:109:2: runtime error: null pointer passed as argument 2, which is declared to never be null ================================================================= ==933317==ERROR: LeakSanitizer: detected memory leaks Direct leak of 24 byte(s) in 1 object(s) allocated from: #0 0x7f49a2aba6af in __interceptor_malloc (/lib64/libasan.so.8+0xba6af) #1 0x43183d in xmalloc ../util.h:45 dgibson#2 0x43482f in data_add_marker ../data.c:230 dgibson#3 0x449bb8 in get_node_phandle ../livetree.c:632 dgibson#4 0x421058 in fixup_phandle_references ../checks.c:627 dgibson#5 0x41b0ba in check_nodes_props ../checks.c:141 dgibson#6 0x41b1c8 in check_nodes_props ../checks.c:144 dgibson#7 0x41b9f1 in run_check ../checks.c:181 dgibson#8 0x430a68 in process_checks ../checks.c:2057 dgibson#9 0x436abd in main ../dtc.c:327 dgibson#10 0x7f49a30d850f in __libc_start_call_main (/lib64/libc.so.6+0x2750f) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
dgibson
pushed a commit
that referenced
this pull request
Mar 1, 2023
./dtc -I dts -O dtb -o aliases.dtb /home/elmarco/src/dtc/tests/aliases.dts ================================================================= ==882911==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000113 at pc 0x7f34ba0abf50 bp 0x7ffc8db22450 sp 0x7ffc8db21c00 READ of size 4 at 0x602000000113 thread T0 #0 0x7f34ba0abf4f in MemcmpInterceptorCommon(void*, int (*)(void const*, void const*, unsigned long), void const*, void const*, unsigned long) (/lib64/libasan.so.8+0xabf4f) #1 0x7f34ba0ac5e8 in memcmp (/lib64/libasan.so.8+0xac5e8) #2 0x4282dc in check_spi_bus_bridge ../checks.c:1110 #3 0x41b08d in check_nodes_props ../checks.c:140 #4 0x41b9c4 in run_check ../checks.c:180 #5 0x430a3b in process_checks ../checks.c:2056 #6 0x436a90 in main ../dtc.c:327 #7 0x7f34b964a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f) #8 0x7f34b964a5c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x275c8) #9 0x4025c4 in _start (/home/elmarco/src/dtc/build/dtc+0x4025c4) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
elmarco
added a commit
to elmarco/dtc
that referenced
this pull request
Mar 1, 2023
./dtc -I dts -O dtb -o overlay_base_manual_symbols.test.dtb /home/elmarco/src/dtc/tests/overlay_base_manual_symbols.dts ../data.c:109:2: runtime error: null pointer passed as argument 2, which is declared to never be null ================================================================= ==933317==ERROR: LeakSanitizer: detected memory leaks Direct leak of 24 byte(s) in 1 object(s) allocated from: #0 0x7f49a2aba6af in __interceptor_malloc (/lib64/libasan.so.8+0xba6af) #1 0x43183d in xmalloc ../util.h:45 dgibson#2 0x43482f in data_add_marker ../data.c:230 dgibson#3 0x449bb8 in get_node_phandle ../livetree.c:632 dgibson#4 0x421058 in fixup_phandle_references ../checks.c:627 dgibson#5 0x41b0ba in check_nodes_props ../checks.c:141 dgibson#6 0x41b1c8 in check_nodes_props ../checks.c:144 dgibson#7 0x41b9f1 in run_check ../checks.c:181 dgibson#8 0x430a68 in process_checks ../checks.c:2057 dgibson#9 0x436abd in main ../dtc.c:327 dgibson#10 0x7f49a30d850f in __libc_start_call_main (/lib64/libc.so.6+0x2750f) Only create data when necessary, and do not alias it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
dgibson
pushed a commit
that referenced
this pull request
Mar 1, 2023
./dtc -I dts -O dtb -o overlay_base_manual_symbols.test.dtb /home/elmarco/src/dtc/tests/overlay_base_manual_symbols.dts ../data.c:109:2: runtime error: null pointer passed as argument 2, which is declared to never be null ================================================================= ==933317==ERROR: LeakSanitizer: detected memory leaks Direct leak of 24 byte(s) in 1 object(s) allocated from: #0 0x7f49a2aba6af in __interceptor_malloc (/lib64/libasan.so.8+0xba6af) #1 0x43183d in xmalloc ../util.h:45 #2 0x43482f in data_add_marker ../data.c:230 #3 0x449bb8 in get_node_phandle ../livetree.c:632 #4 0x421058 in fixup_phandle_references ../checks.c:627 #5 0x41b0ba in check_nodes_props ../checks.c:141 #6 0x41b1c8 in check_nodes_props ../checks.c:144 #7 0x41b9f1 in run_check ../checks.c:181 #8 0x430a68 in process_checks ../checks.c:2057 #9 0x436abd in main ../dtc.c:327 #10 0x7f49a30d850f in __libc_start_call_main (/lib64/libc.so.6+0x2750f) Only create data when necessary, and do not alias it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> [dwg: Small fixup for a slightly different approach to adjacent cleanups] Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A new command line option is added
-c, --color Colorize, argument can be auto, never or always
which defaults to auto.
For colored output in pipes use 'always', e.g.
fdtdump -c always file.dtb | less -R
If you don't like colors use
alias fdtdump="fdtdump -c none"
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de