treewide: validate unified uImage.FIT images before flashing
Prevent flashing truncated or otherwise corrupted uImage.FIT images by verifying checksums and hashes of all sub-images before flashing using the newly packaged fit_check_sign tool. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
parent
5175d0a623
commit
29ec74b8c7
6 changed files with 19 additions and 15 deletions
|
@ -16,6 +16,7 @@ define Package/fitblk
|
||||||
SECTION:=base
|
SECTION:=base
|
||||||
CATEGORY:=Base system
|
CATEGORY:=Base system
|
||||||
TITLE:=fitblk firmware release tool
|
TITLE:=fitblk firmware release tool
|
||||||
|
DEPENDS:=+fit-check-sign
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/fitblk/description
|
define Package/fitblk/description
|
||||||
|
|
|
@ -61,3 +61,13 @@ fit_do_upgrade() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fit_check_image() {
|
||||||
|
local magic="$(get_magic_long "$1")"
|
||||||
|
[ "$magic" != "d00dfeed" ] && {
|
||||||
|
echo "Invalid image type."
|
||||||
|
return 74
|
||||||
|
}
|
||||||
|
|
||||||
|
fit_check_sign -f "$1" >/dev/null || return 74
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
REQUIRE_IMAGE_METADATA=1
|
REQUIRE_IMAGE_METADATA=1
|
||||||
RAMFS_COPY_BIN='fitblk'
|
RAMFS_COPY_BIN='fitblk fit_check_sign'
|
||||||
|
|
||||||
asus_initial_setup()
|
asus_initial_setup()
|
||||||
{
|
{
|
||||||
|
@ -224,11 +224,8 @@ platform_check_image() {
|
||||||
xiaomi,redmi-router-ax6000-ubootmod|\
|
xiaomi,redmi-router-ax6000-ubootmod|\
|
||||||
xiaomi,mi-router-wr30u-ubootmod|\
|
xiaomi,mi-router-wr30u-ubootmod|\
|
||||||
zyxel,ex5601-t0-ubootmod)
|
zyxel,ex5601-t0-ubootmod)
|
||||||
[ "$magic" != "d00dfeed" ] && {
|
fit_check_image "$1"
|
||||||
echo "Invalid image type."
|
return $?
|
||||||
return 1
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
;;
|
;;
|
||||||
nradio,c8-668gl)
|
nradio,c8-668gl)
|
||||||
# tar magic `ustar`
|
# tar magic `ustar`
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
REQUIRE_IMAGE_METADATA=1
|
REQUIRE_IMAGE_METADATA=1
|
||||||
RAMFS_COPY_BIN='fitblk'
|
RAMFS_COPY_BIN='fitblk fit_check_sign'
|
||||||
|
|
||||||
platform_do_upgrade() {
|
platform_do_upgrade() {
|
||||||
local board=$(board_name)
|
local board=$(board_name)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
REQUIRE_IMAGE_METADATA=1
|
REQUIRE_IMAGE_METADATA=1
|
||||||
RAMFS_COPY_BIN='fitblk'
|
RAMFS_COPY_BIN='fitblk fit_check_sign'
|
||||||
|
|
||||||
# Legacy full system upgrade including preloader for MediaTek SoCs on eMMC or SD
|
# Legacy full system upgrade including preloader for MediaTek SoCs on eMMC or SD
|
||||||
legacy_mtk_mmc_full_upgrade() {
|
legacy_mtk_mmc_full_upgrade() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
REQUIRE_IMAGE_METADATA=1
|
REQUIRE_IMAGE_METADATA=1
|
||||||
RAMFS_COPY_BIN='fitblk'
|
RAMFS_COPY_BIN='fitblk fit_check_sign'
|
||||||
|
|
||||||
platform_do_upgrade() {
|
platform_do_upgrade() {
|
||||||
local board=$(board_name)
|
local board=$(board_name)
|
||||||
|
@ -18,17 +18,13 @@ PART_NAME=firmware
|
||||||
|
|
||||||
platform_check_image() {
|
platform_check_image() {
|
||||||
local board=$(board_name)
|
local board=$(board_name)
|
||||||
local magic="$(get_magic_long "$1")"
|
|
||||||
|
|
||||||
[ "$#" -gt 1 ] && return 1
|
[ "$#" -gt 1 ] && return 1
|
||||||
|
|
||||||
case "$board" in
|
case "$board" in
|
||||||
*)
|
*)
|
||||||
[ "$magic" != "d00dfeed" ] && {
|
fit_check_image "$1"
|
||||||
echo "Invalid image type."
|
return $?
|
||||||
return 1
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue