mirror of
https://github.com/dgibson/dtc.git
synced 2026-04-11 16:37:42 -04:00
libfdt: Verify alignment of sub-blocks in dtb
Some checks failed
Build test / build-make (alpine) (push) Has been cancelled
Build test / build-make (archlinux) (push) Has been cancelled
Build test / build-make (fedora) (push) Has been cancelled
Build test / build-make (ubuntu) (push) Has been cancelled
Build test / build-meson (alpine) (push) Has been cancelled
Build test / build-meson (archlinux) (push) Has been cancelled
Build test / build-meson (fedora) (push) Has been cancelled
Build test / build-meson (ubuntu) (push) Has been cancelled
Build test / clang64 (push) Has been cancelled
Build test / mingw32 (push) Has been cancelled
Build test / mingw64 (push) Has been cancelled
Build test / ucrt64 (push) Has been cancelled
Some checks failed
Build test / build-make (alpine) (push) Has been cancelled
Build test / build-make (archlinux) (push) Has been cancelled
Build test / build-make (fedora) (push) Has been cancelled
Build test / build-make (ubuntu) (push) Has been cancelled
Build test / build-meson (alpine) (push) Has been cancelled
Build test / build-meson (archlinux) (push) Has been cancelled
Build test / build-meson (fedora) (push) Has been cancelled
Build test / build-meson (ubuntu) (push) Has been cancelled
Build test / clang64 (push) Has been cancelled
Build test / mingw32 (push) Has been cancelled
Build test / mingw64 (push) Has been cancelled
Build test / ucrt64 (push) Has been cancelled
A dtb is considered malformed if its structural elements (not things within property values) are not naturally aligned. This means that the structure block must be aligned to a 32-bit boundary, the reserve map must be aligned to 64-bit boundary and the whole thing must be loaded at a 64-bit aligned address. We currently verify that lasat condition in fdt_check_header() but not the other cases. Reported-by: Owen Sanzas (Ze Sheng) 盛泽 <zesheng@tamu.edu> Link: https://github.com/dgibson/dtc/issues/178 Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
a26ef6400b
commit
8d15a63e84
1 changed files with 8 additions and 0 deletions
|
|
@ -110,6 +110,14 @@ int fdt_check_header(const void *fdt)
|
|||
|| (fdt_totalsize(fdt) > INT_MAX))
|
||||
return -FDT_ERR_TRUNCATED;
|
||||
|
||||
/* memrsv block must be 8 byte aligned */
|
||||
if (fdt_off_mem_rsvmap(fdt) % sizeof(uint64_t))
|
||||
return -FDT_ERR_ALIGNMENT;
|
||||
|
||||
/* Structure block must be 4 byte aligned */
|
||||
if (fdt_off_dt_struct(fdt) % FDT_TAGSIZE)
|
||||
return -FDT_ERR_ALIGNMENT;
|
||||
|
||||
/* Bounds check memrsv block */
|
||||
if (!check_off_(hdrsize, fdt_totalsize(fdt),
|
||||
fdt_off_mem_rsvmap(fdt)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue