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

add the fields for signing to crd #91

Merged
merged 1 commit into from Sep 30, 2022

Conversation

chr15p
Copy link
Contributor

@chr15p chr15p commented Sep 28, 2022

Add fields to the CRD to support kmod signing

This PR just adds the fields, the functionality to actually use them will come in a later PR. This is mostly intended for discussion, to ensure the actual code is built on foundations we agree on, and to try and keep the size of that future PR down to a reviewable and mergeable size (which my previous attempts have not been great at!)

Edit:
updated commit message to say

this add four fields to the crd in their own subsection:

FileList - a list of kmod files within the container to sign

KeySecret and CertSecret - these are the names of secrets containing the private and public keys respectivly that
will be used to sign the kmods. The public key should be the one added into the uefi moklist for secureboot,
and KeySecret is its private component. (See the kernel docs e.g.
https://www.kernel.org/doc/html/v4.15/admin-guide/module-signing.html#manually-signing-modules
for details of this process)

unsignedImage - the optional name of a dtk image containing the unsigned knods, used only if their is no build stage.

The expected workflow will be (not implemented in this commit):
if there is only a kernelmapping.build section it will produce the image kernelmapping.containerImage
(for the non-secureboot case)

if there is both km.build and km.sign then build will produce an intermediate image and sign will
consume that to produce km.containerImage

if there is only km.sign signing will consumse km.sign.unsignedImage and produce km.containerImage
(this is for the case where a vendor supplies prebuilt images that need signing)

the generation of the intermediate image name will be handled automatically within the controller
(again in a different commit) but will probably be something like km.containerImage + "-unsigned"

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 28, 2022
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 28, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @chr15p. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 28, 2022
@ybettan
Copy link
Contributor

ybettan commented Sep 28, 2022

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 28, 2022
@ybettan
Copy link
Contributor

ybettan commented Sep 28, 2022

@qbarrand We need to trigger the Github actions here as well. I don't think I have enough privileges to do it (can't see the workflow tab).

@ybettan
Copy link
Contributor

ybettan commented Sep 28, 2022

Can you please add a commit message describing those changes?

KeySecret *v1.LocalObjectReference `json:"keySecret"`

// a secret containing the public key used to sign kernel modules for secureboot
CertSecret *v1.LocalObjectReference `json:"certSecret"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need a public key for signing purposes?

@ybettan
Copy link
Contributor

ybettan commented Sep 28, 2022

Few questions:
What is the expected flow here? Can we have it in the commit message (and PR description as well)? Are we pulling from the unsignedImage, signing, and then what? pushing somewhere? are we overriding the unsigned image? pushing a new tag? using the same tag as the containerImage? Do we need to mention the new tag name in the Sign object as we do for the unsignedImage?

@chr15p
Copy link
Contributor Author

chr15p commented Sep 29, 2022

written a better commit message that hopefully explains my thinking (I've been staring at this stuff so long I forget it isn't obvious to other people! )

The signing process itself will use the sign-file binary distributed with the kernel source (see https://www.kernel.org/doc/html/v4.15/admin-guide/module-signing.html#manually-signing-modules) and that requires the public and private key, so the simple answer is we need both keys/certs as input parameters to that code. We could write our own signing code but that seems fragile.

@ybettan
Copy link
Contributor

ybettan commented Sep 29, 2022

Thanks for updating the commit message.

unsignedImage - the optional name of a dtk image containing the unsigned knods, used only if their is no build stage.

How DTK is related here? We don't have DTK u/s. I guess you meant "driver container" instead of "dtk"?! (If this is the case, please update the commit message as well).

Besides that, LGTM.

@ybettan
Copy link
Contributor

ybettan commented Sep 29, 2022

/approve
/cc @qbarrand in case he also have something to say.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chr15p, ybettan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 29, 2022
Copy link
Contributor

@qbarrand qbarrand left a comment

Choose a reason for hiding this comment

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

Two small comments, lgtm otherwise. Thanks!

api/v1beta1/module_types.go Outdated Show resolved Hide resolved
api/v1beta1/module_types.go Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Sep 29, 2022

Codecov Report

Base: 73.46% // Head: 73.46% // No change to project coverage 👍

Coverage data is based on head (9e40749) compared to base (2f48ff2).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #91   +/-   ##
=======================================
  Coverage   73.46%   73.46%           
=======================================
  Files          17       17           
  Lines        1771     1771           
=======================================
  Hits         1301     1301           
  Misses        404      404           
  Partials       66       66           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

this add four fields to the crd in their own subsection:

FileList - a list of kmod files within the container to sign

KeySecret and CertSecret - these are the names of secrets containing the private and public keys respectivly that
will be used to sign the kmods. The public key should be the one added into the uefi moklist for secureboot,
 and KeySecret is its private component. (See the kernel docs e.g.
https://www.kernel.org/doc/html/v4.15/admin-guide/module-signing.html#manually-signing-modules
for details of this process)

unsignedImage - the optional name of a dtk image containing the unsigned knods, used only if their is no build stage.

The expected workflow will be (not implemented in this commit):
if there is only a kernelmapping.build section it will produce the image kernelmapping.containerImage
(for the non-secureboot case)

if there is both km.build and km.sign then build will produce an intermediate image and sign will
consume that to produce km.containerImage

if there is only km.sign signing will consumse km.sign.unsignedImage and produce km.containerImage
(this is for the case where a vendor supplies prebuilt images that need signing)

the generation of the intermediate image name will be handled automatically within the controller
(again in a different commit) but will probably be something like km.containerImage + "-unsigned"
@qbarrand
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 30, 2022
@k8s-ci-robot k8s-ci-robot merged commit 4c6a77d into kubernetes-sigs:main Sep 30, 2022
qbarrand pushed a commit to qbarrand/kernel-module-management that referenced this pull request Jun 2, 2023
Signed-off-by: Michail Resvanis <mresvani@redhat.com>

Signed-off-by: Michail Resvanis <mresvani@redhat.com>
qbarrand pushed a commit to qbarrand/kernel-module-management that referenced this pull request Jun 2, 2023
…gs#92)

this add four fields to the crd in their own subsection:

FileList - a list of kmod files within the container to sign

KeySecret and CertSecret - these are the names of secrets containing the private and public keys respectivly that
will be used to sign the kmods. The public key should be the one added into the uefi moklist for secureboot,
 and KeySecret is its private component. (See the kernel docs e.g.
https://www.kernel.org/doc/html/v4.15/admin-guide/module-signing.html#manually-signing-modules
for details of this process)

unsignedImage - the optional name of a dtk image containing the unsigned knods, used only if their is no build stage.

The expected workflow will be (not implemented in this commit):
if there is only a kernelmapping.build section it will produce the image kernelmapping.containerImage
(for the non-secureboot case)

if there is both km.build and km.sign then build will produce an intermediate image and sign will
consume that to produce km.containerImage

if there is only km.sign signing will consumse km.sign.unsignedImage and produce km.containerImage
(this is for the case where a vendor supplies prebuilt images that need signing)

the generation of the intermediate image name will be handled automatically within the controller
(again in a different commit) but will probably be something like km.containerImage + "-unsigned"

Co-authored-by: Chris Procter <cprocter@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants