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

[wip] sign kernel modules #78

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft

[wip] sign kernel modules #78

wants to merge 2 commits into from

Conversation

iurly
Copy link
Contributor

@iurly iurly commented Feb 23, 2023

This is a WIP/Proof-of-Concept change to introduce kernel module signing.
The actual signing is performed by the in-tree script sign-file.
The private key and the certificate must be provided in the same directory as the libs/ checkout, under a specially created directory signed-key/, i.e.

  • agent-libs
    • cmake
    • driver
    • proposals
    • signing-key <-----
    • test
    • userspace

and must be called:

  • key.priv (private key in PEM format)
  • key.der (certificate in DER format)

NOTE: this was done in order not to create any additional paths to mount as volume, (first to the outer container, and then to the specific container).

ALSO NOTE: on newer kernels the sign-file would be a C program which also accepts a PEM textual file for the certificate but older kernels use a perl script which can only read a DER binary file, so for compatibility reason this must be a binary file.

The top-level python script must be called with the '-x/--sign' flag in order for module signing to be enabled.
Since different kernels might use a different hashing algorithm (sha256, sha512, etc..), the one chosen by the target kernel is read from the kernel config file under CONFIG_MODULE_SIG_HASH.

This value is then passed over to the downstream builder as SIGN_FILE_HASH_ALGO.
When '-x/--sign' is not specified, this is left empty and the module is NOT signed.

This is a WIP/Proof-of-Concept change to introduce kernel
module signing.
The actual signing is performed by the in-tree script
sign-file.
The private key and the certificate must be provided in
the same directory as the libs/ checkout, under a specially
created directory signed-key/, i.e.

 + agent-libs
   + cmake
   + driver
   + proposals
   + signing-key   <-----
   + test
   + userspace

and must be called:
   + key.priv (private key in PEM format)
   + key.der  (certificate in DER format)

NOTE: this was done in order not to create any additional
paths to mount as volume, (first to the outer container,
and then to the specific container).

ALSO NOTE: on newer kernels the sign-file would be a C program which
also accepts a PEM textual file for the certificate but older kernels
use a perl script which can only read a DER binary file,
so for compatibility reason this _must_ be a binary file.

The top-level python script must be called with the '-x/--sign' flag
in order for module signing to be enabled.
Since different kernels might use a different hashing algorithm
(sha256, sha512, etc..), the one chosen by the target kernel is
read from the kernel config file under CONFIG_MODULE_SIG_HASH.

This value is then passed over to the downstream builder
as SIGN_FILE_HASH_ALGO.
When '-x/--sign' is not specified, this is left empty and the
module is NOT signed.
gnosek
gnosek previously approved these changes Feb 23, 2023
Copy link
Contributor

@gnosek gnosek left a comment

Choose a reason for hiding this comment

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

I'm not 100% thrilled about adding stuff to the agent-libs checkout but I see why you went that way.

LGTM!

@mavimo mavimo marked this pull request as draft October 13, 2023 12:39
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.

3 participants