Skip to content

Boot firmware updates alternative fixes#459

Merged
igoropaniuk merged 7 commits intofoundriesio:masterfrom
igoropaniuk:boot_firmware_updates_alternative_fixes
Nov 16, 2021
Merged

Boot firmware updates alternative fixes#459
igoropaniuk merged 7 commits intofoundriesio:masterfrom
igoropaniuk:boot_firmware_updates_alternative_fixes

Conversation

@igoropaniuk
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread meta-lmp-bsp/recipes-bsp/u-boot/u-boot-fio/imx8qm-mek/fw_env.config Outdated
@igoropaniuk igoropaniuk force-pushed the boot_firmware_updates_alternative_fixes branch from 17f88ba to ac8f3aa Compare November 12, 2021 15:41
@igoropaniuk
Copy link
Copy Markdown
Contributor Author

@mike-scott added additional fixes for reset cmd, this is what we discussed yesterday in Slack

Copy link
Copy Markdown
Contributor

@mike-scott mike-scott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@Tim-Anderson Tim-Anderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

run bootcmd_bootenv
if test -n "${fiovb_rpmb}"; then
fiovb write_pvalue bootupgrade_available 0;
fiovb write_pvalue bootfirmware_version ${bootfirmware_version};
Copy link
Copy Markdown
Contributor

@MrCry0 MrCry0 Nov 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd guard the variable ${bootfirmware_version} with double quotes - it comes from a file and might be a source of an attack on the u-boot level.
I.e. if someone compromises /usr/lib/firmware/version.txt and writes something like:
bootfirmware_version="0; ...{some hacking code}..."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, at first sight it might look like vulnaribility, but value "unfolding" works too simplistic (comparing to real interpreted languages) and can not trigger any code execution. I have even run some tests:

with wrapping:

=> setenv bootfirmware_version "0; echo hello"           
=> setenv bootfirmware_version "${bootfirmware_version}";
=> print bootfirmware_version                            
bootfirmware_version=0; echo hello

and without:

=> setenv bootfirmware_version "0; echo hello"
=> setenv bootfirmware_version ${bootfirmware_version};  
=> print bootfirmware_version                          
bootfirmware_version=0; echo hello

in both cases it did not result in execution of echo cmd. The only way to do that is use run explicitly:

=> run bootfirmware_version
Unknown command '0' - try 'help'
hello

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Now u-boot uses such a simple unfolding process. In the future, it can be replaced with a more advanced one. We can prevent possible side effects right now by just add a pair of quotes :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, makes sense.
Fixed that

Handle rollback for boot firmware in alternative boot upgrade path.
Restoring of old firmware now is also done during rollback.

Signed-off-by: Igor Opaniuk <[email protected]>
Drop CONFIG_BOOTCOUNT_LIMIT, as this is now handled in boot.cmd instead.

Signed-off-by: Igor Opaniuk <[email protected]>
Disable bootdelay for iMX8QM-MEK.

Signed-off-by: Igor Opaniuk <[email protected]>
Enable CONFIG_PSCI_BOARD_REBOOT, which enables reboot cmd for triggering
board reset (SC_PM_RESET_TYPE_BOARD).
Default reset cmd is doing SC_PM_RESET_TYPE_COLD, which doesn't force
BootROM to reload imx-boot firmware.

Signed-off-by: Igor Opaniuk <[email protected]>
Add possibility to re-define cmd for reseting board.

Signed-off-by: Igor Opaniuk <[email protected]>
Define custom do_reboot cmd.

Signed-off-by: Igor Opaniuk <[email protected]>
Guard with double quotes all imported variables from file, as it
might be a source of an attack on the U-Boot level.

Signed-off-by: Igor Opaniuk <[email protected]>
@igoropaniuk igoropaniuk force-pushed the boot_firmware_updates_alternative_fixes branch from 7f16179 to 7f2987a Compare November 16, 2021 16:16
@igoropaniuk igoropaniuk merged commit 39b55b1 into foundriesio:master Nov 16, 2021
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

Successfully merging this pull request may close these issues.

4 participants