Secureboot: PDDF: Do not always use -f to load custom PDDF modules#23732
Secureboot: PDDF: Do not always use -f to load custom PDDF modules#23732lguohan merged 1 commit intosonic-net:masterfrom
Conversation
When in secureboot, -f will fail with a module signing issue even though the module is signed properly. This implies it is doing some module modification to force it to be loaded which invalidates the signing. First try to load custom modules without the -f flag, then on failure use the -f flag to maintain compatibility with the existing implementation.
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@DavidZagury @davidpil2002 @qiluo-msft please review |
|
@Yarden-Z any comments? |
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Here’s a review of the changes in PR #23732 for sonic-net/sonic-buildimage: SummaryThis PR refactors the handling of kernel object modules (KOS) in Key Changes1. Variable Refactoring
2. Module Loading Logic
3. Module Unloading Logic
Pros
Cons / Suggestions
Overall AssessmentThis is a solid refactor that improves the clarity and reliability of kernel module handling in the PDDF utilities. Recommendation: |
…s and bugfixes) (#23405) #### Why I did it The current sonic secureboot implementation assumes all assets are signed with the DB Key. There are roughly 3600 kernel modules that get signed in the process. Organizations may have varying security policy requirements where any signing requests may require signoff by one or more parties, this may simply be infeasible for that many requests. Given that the DB key may be a long-lived key, and only RSA 2048 is often used or available, it is a security best-practice to sign as few assets as possible with such a key. This PR is fully backwards compatible with any pre-existing usages. It introduces a new `rules/config` setting of `SECURE_UPGRADE_KERNEL_CAFILE` which is a path to a file for all trusted keys to embed into the kernel. If that setting is not specified, it defaults to `SECURE_UPGRADE_SIGNING_CERT`. There are no other infrastructure changes to support ephemeral keys for kernel module signing. It is up to the organization to generate the ephemeral keys and pass them into their own signing scripts as required. Dependent PR: * sonic-net/sonic-linux-kernel#499 Related PRs: * sonic-net/sonic-utilities#3989 * #23732 * #23733 * #23734 * #23735 * #23736 Fixes #23406 ##### Work item tracking #### How I did it Worked through production signing steps and hit issues when requiring signing approval with our HSM. This was the most elegant solution that required the minimal changes. This has been fully tested. #### How to verify it Since there are no provided production signing script examples this would require a vendor with an existing implementation to validate. Nexthop has validated this internally. #### Which release branch to backport (provide reason below if selected) #### Tested branch (Please provide the tested image version) master as of 20250721 #### Description for the changelog Secureboot: Production signing enhancement to allow ephemeral kernel module keys #### Link to config_db schema for YANG module changes N/A #### A picture of a cute animal (not mandatory but encouraged) Signed-off-by: Brad House <bhouse@nexthop.ai>
When in secureboot, -f will fail with a module signing issue even though the module is signed properly. This implies it is doing some module modification to force it to be loaded which invalidates the signing. First try to load custom modules without the -f flag, then on failure use the -f flag to maintain compatibility with the existing implementation. Signed-off-by: Feng Pan <fenpan@microsoft.com>
…s and bugfixes) (sonic-net#23405) #### Why I did it The current sonic secureboot implementation assumes all assets are signed with the DB Key. There are roughly 3600 kernel modules that get signed in the process. Organizations may have varying security policy requirements where any signing requests may require signoff by one or more parties, this may simply be infeasible for that many requests. Given that the DB key may be a long-lived key, and only RSA 2048 is often used or available, it is a security best-practice to sign as few assets as possible with such a key. This PR is fully backwards compatible with any pre-existing usages. It introduces a new `rules/config` setting of `SECURE_UPGRADE_KERNEL_CAFILE` which is a path to a file for all trusted keys to embed into the kernel. If that setting is not specified, it defaults to `SECURE_UPGRADE_SIGNING_CERT`. There are no other infrastructure changes to support ephemeral keys for kernel module signing. It is up to the organization to generate the ephemeral keys and pass them into their own signing scripts as required. Dependent PR: * sonic-net/sonic-linux-kernel#499 Related PRs: * sonic-net/sonic-utilities#3989 * sonic-net#23732 * sonic-net#23733 * sonic-net#23734 * sonic-net#23735 * sonic-net#23736 Fixes sonic-net#23406 ##### Work item tracking #### How I did it Worked through production signing steps and hit issues when requiring signing approval with our HSM. This was the most elegant solution that required the minimal changes. This has been fully tested. #### How to verify it Since there are no provided production signing script examples this would require a vendor with an existing implementation to validate. Nexthop has validated this internally. #### Which release branch to backport (provide reason below if selected) #### Tested branch (Please provide the tested image version) master as of 20250721 #### Description for the changelog Secureboot: Production signing enhancement to allow ephemeral kernel module keys #### Link to config_db schema for YANG module changes N/A #### A picture of a cute animal (not mandatory but encouraged) Signed-off-by: Brad House <bhouse@nexthop.ai> Signed-off-by: Feng Pan <fenpan@microsoft.com>
…s and bugfixes) (sonic-net#23405) #### Why I did it The current sonic secureboot implementation assumes all assets are signed with the DB Key. There are roughly 3600 kernel modules that get signed in the process. Organizations may have varying security policy requirements where any signing requests may require signoff by one or more parties, this may simply be infeasible for that many requests. Given that the DB key may be a long-lived key, and only RSA 2048 is often used or available, it is a security best-practice to sign as few assets as possible with such a key. This PR is fully backwards compatible with any pre-existing usages. It introduces a new `rules/config` setting of `SECURE_UPGRADE_KERNEL_CAFILE` which is a path to a file for all trusted keys to embed into the kernel. If that setting is not specified, it defaults to `SECURE_UPGRADE_SIGNING_CERT`. There are no other infrastructure changes to support ephemeral keys for kernel module signing. It is up to the organization to generate the ephemeral keys and pass them into their own signing scripts as required. Dependent PR: * sonic-net/sonic-linux-kernel#499 Related PRs: * sonic-net/sonic-utilities#3989 * sonic-net#23732 * sonic-net#23733 * sonic-net#23734 * sonic-net#23735 * sonic-net#23736 Fixes sonic-net#23406 ##### Work item tracking #### How I did it Worked through production signing steps and hit issues when requiring signing approval with our HSM. This was the most elegant solution that required the minimal changes. This has been fully tested. #### How to verify it Since there are no provided production signing script examples this would require a vendor with an existing implementation to validate. Nexthop has validated this internally. #### Which release branch to backport (provide reason below if selected) #### Tested branch (Please provide the tested image version) master as of 20250721 #### Description for the changelog Secureboot: Production signing enhancement to allow ephemeral kernel module keys #### Link to config_db schema for YANG module changes N/A #### A picture of a cute animal (not mandatory but encouraged) Signed-off-by: Brad House <bhouse@nexthop.ai> Signed-off-by: xiaweijiang <xiaweijiang@microsoft.com>
Why I did it
When in kernel modules are signed for secureboot, passing
-fto modprobe will fail with a module signing issue even though the module is signed properly. This appears to be due to some internal module modification to handle mismatched kernel versions which invalidates the signature.Work item tracking
How I did it
This modification first tries to load custom modules without the
-fflag, then if (and only if) that fails, try again with the-fflag. No attempt is made to determine if the kernel module is signed as it was not necessary and would only complicate the code further.It is not clear what the valid use-case is for using
modprobe -f, however this behavior has been maintained in this modification.How to verify it
Build a SONiC secure-boot enabled build and observe custom modules (like PDDF modules) load proper now, and previously failed without this patch.
Which release branch to backport (provide reason below if selected)
Tested branch (Please provide the tested image version)
master as of 20250817
Description for the changelog
Secureboot: PDDF: Do not always use -f to load custom PDDF modules
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)
Fixes: #23406
Signed-off-by: Brad House bhouse@nexthop.ai