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

fixed bootloader method verify_image_sign to have dummy implementation… #2646

Closed

Conversation

ycoheNvidia
Copy link
Contributor

…n in father class

What I did

Fixed bootloader issue in sonic-installer

How I did it

Added dummy implementation of verify_image_sign in bootloader.py
Added tests to check it's available

How to verify it

Run sonic-utilities tests and see that they pass

Previous command output (if the output of a command-line utility has changed)

NONE

New command output (if the output of a command-line utility has changed)

NONE

@ycoheNvidia ycoheNvidia mentioned this pull request Feb 2, 2023
tests/installer_bootloader_aboot_test.py Outdated Show resolved Hide resolved
tests/installer_bootloader_uboot_test.py Outdated Show resolved Hide resolved
Staphylo
Staphylo previously approved these changes Feb 2, 2023
@@ -75,6 +75,10 @@ def supports_package_migration(self, image):
"""tells if the image supports package migration"""
return True

def verify_image_sign(self, image_path):
"""verify image signature is valid"""
return True
Copy link
Contributor

Choose a reason for hiding this comment

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

True

I do not understand the semantics of the return value, and why using True as default value. A unsecure normal image is considered not signed image, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unsecured normal image is considered not signed, yes

Copy link
Contributor

Choose a reason for hiding this comment

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

@ycoheNvidia try/except would be more appropriate?

        echo_and_log("Verifing image {} signature...".format(binary_image_version))
        try : 
               if not bootloader.verify_image_sign(image_path):
                        echo_and_log('Error: Failed verify image signature', LOG_ERR)
                        raise click.Abort()
                else:
                       echo_and_log('Verification successful')
           except AttributeError:
                     echo_and_log("Skip Verifing image {} signature...Not signed image".format(binary_image_version))
                      pass
                     

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure which lines you are referring to @prgeor, can you please elaborate?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ycoheNvidia @liat-grozovik instead of defining verify_image_sign() as NOP function in the bootloader.py can we try the except/catch block I showed above? So that if a bootloader does not implement verify_image_sign(), it won't crash here https://github.com/sonic-net/sonic-utilities/blob/master/sonic_installer/main.py#L582

@liat-grozovik
Copy link
Collaborator

@qiluo-msft can you approve so we can merge ?

@ycoheNvidia ycoheNvidia force-pushed the secure_upgrade-bootloader-fix branch 2 times, most recently from c527b5b to ccdd0c7 Compare February 23, 2023 06:57
Added try-catch wrapper for verify_image_sign to fix method not implemented in non-grub bootloaders.
raise click.Abort()
else:
echo_and_log('Verification successful')
except AttributeError:
Copy link
Contributor

Choose a reason for hiding this comment

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

except AttributeError:

This looks like a hack to workaround the logic error inside implementation.

Copy link
Contributor

Choose a reason for hiding this comment

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

@qiluo-msft whats in your mind? How do you want the fix ?

@liat-grozovik
Copy link
Collaborator

@qiluo-msft can you approve so we can merge ?

@ycoheNvidia
Copy link
Contributor Author

@qiluo-msft can you approve so we can merge ?

I thought there was an agreement to use #2698 instead, since original PR 2337 was reverted. 2698 includes both Secure upgrade original code and the fixes included in this PR

@liat-grozovik
Copy link
Collaborator

@ycoheNvidia can you please update the conflicts?
@qiluo-msft to avoid further conflicts can you please help to review?

@ycoheNvidia
Copy link
Contributor Author

I thought there was an agreement to use #2698 instead, since original PR 2337 was reverted. 2698 includes both Secure upgrade original code and the fixes included in this PR

@ycoheNvidia can you please update the conflicts? @qiluo-msft to avoid further conflicts can you please help to review?

This PR is irrelevant without 2337, can we move with #2698 instead? it has both original secure upgrade code and the fixes introduced here

@ycoheNvidia
Copy link
Contributor Author

This solution is part of a new PR #2698

@ycoheNvidia ycoheNvidia closed this Mar 8, 2023
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.

5 participants