Skip to content

Conversation

@bluca
Copy link
Member

@bluca bluca commented Jun 23, 2020

With kernel 5.4 and libcryptsetup 2.3.0, the verity root hash can be signed by a key in the kernel trusted keyring. Add support for this feature throughout the various components.

@bluca
Copy link
Member Author

bluca commented Jun 23, 2020

I have not pushed a commit with an update for the veritysetup-generator as I'm struggling a bit to get an image to test it - given Debian doesn't use dracut/systemd in the initramfs it's a bit difficult to produce one. The veritysetup binary can be used standalone though, and it works fine, so shouldn't be a blocker.

@bluca
Copy link
Member Author

bluca commented Jun 23, 2020

Note that I didn't exercise this functionality in TEST-50-DISSECT because, due to the variability of the test image, I don't know of a reliable way to check whether the kernel + cryptsetup provide the functionality. If anybody has any suggestion, I'm happy to work on that.

@bluca bluca force-pushed the root_verity_sig branch from b7696e9 to c729b2e Compare June 23, 2020 15:43
@poettering
Copy link
Member

Hmm, I thought Debian also shipped dracut? Maybe you can make things work with that?

@bluca bluca force-pushed the root_verity_sig branch from c729b2e to 02a3dc0 Compare June 24, 2020 15:29
Copy link
Member

@poettering poettering left a comment

Choose a reason for hiding this comment

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

nice! close!

@bluca bluca force-pushed the root_verity_sig branch 2 times, most recently from 6409feb to 0747596 Compare June 24, 2020 15:58
@bluca bluca force-pushed the root_verity_sig branch from 0747596 to 4fec17c Compare June 24, 2020 16:06
@poettering poettering added the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Jun 24, 2020
@bluca
Copy link
Member Author

bluca commented Jun 24, 2020

@bluca
Copy link
Member Author

bluca commented Jun 24, 2020

CI's quite unhappy today:

CentOS CI (Arch in KVM) has a failed networkd test, seems unrelated:

[RESULT] systemd-networkd-tests.py - FAIL (EC: 1) (log file: /build/vagrant-arch-testsuite.i5B/systemd-networkd-tests.py_FAIL.log)

CentOS CI (CentOS 7) has a failure in the dissect test which, although it tests a changed binary, fails before that, when creating a squashfs in the tmpfs:

Jun 24 17:43:19 systemd-testsuite testsuite-50.sh[465]: + mksquashfs /tmp/tmp.aoQmVM /tmp/tmp.aoQmVM.raw
Jun 24 17:43:19 systemd-testsuite testsuite-50.sh[470]: Write failed because Bad file descriptor
Jun 24 17:43:19 systemd-testsuite testsuite-50.sh[470]: FATAL ERROR:Failed to write to output filesystem

So it would seem unrelated? @mrc0mmand have you seen these before?

@mrc0mmand
Copy link
Member

CI's quite unhappy today:

CentOS CI (Arch in KVM) has a failed networkd test, seems unrelated:

[RESULT] systemd-networkd-tests.py - FAIL (EC: 1) (log file: /build/vagrant-arch-testsuite.i5B/systemd-networkd-tests.py_FAIL.log)

CentOS CI (CentOS 7) has a failure in the dissect test which, although it tests a changed binary, fails before that, when creating a squashfs in the tmpfs:

Jun 24 17:43:19 systemd-testsuite testsuite-50.sh[465]: + mksquashfs /tmp/tmp.aoQmVM /tmp/tmp.aoQmVM.raw
Jun 24 17:43:19 systemd-testsuite testsuite-50.sh[470]: Write failed because Bad file descriptor
Jun 24 17:43:19 systemd-testsuite testsuite-50.sh[470]: FATAL ERROR:Failed to write to output filesystem

So it would seem unrelated? @mrc0mmand have you seen these before?

The networkd fail is #16105, rescheduled. However, I've never seen the dissect one before.

@bluca
Copy link
Member Author

bluca commented Jun 24, 2020

CI's quite unhappy today:
CentOS CI (Arch in KVM) has a failed networkd test, seems unrelated:

[RESULT] systemd-networkd-tests.py - FAIL (EC: 1) (log file: /build/vagrant-arch-testsuite.i5B/systemd-networkd-tests.py_FAIL.log)

CentOS CI (CentOS 7) has a failure in the dissect test which, although it tests a changed binary, fails before that, when creating a squashfs in the tmpfs:

Jun 24 17:43:19 systemd-testsuite testsuite-50.sh[465]: + mksquashfs /tmp/tmp.aoQmVM /tmp/tmp.aoQmVM.raw
Jun 24 17:43:19 systemd-testsuite testsuite-50.sh[470]: Write failed because Bad file descriptor
Jun 24 17:43:19 systemd-testsuite testsuite-50.sh[470]: FATAL ERROR:Failed to write to output filesystem

So it would seem unrelated? @mrc0mmand have you seen these before?

The networkd fail is #16105, rescheduled. However, I've never seen the dissect one before.

I see, thank you - it's very weird, it looks like mksquashfs fails to write to a subdir of /tmp

@mrc0mmand
Copy link
Member

mrc0mmand commented Jun 24, 2020

CI's quite unhappy today:
CentOS CI (Arch in KVM) has a failed networkd test, seems unrelated:

[RESULT] systemd-networkd-tests.py - FAIL (EC: 1) (log file: /build/vagrant-arch-testsuite.i5B/systemd-networkd-tests.py_FAIL.log)

CentOS CI (CentOS 7) has a failure in the dissect test which, although it tests a changed binary, fails before that, when creating a squashfs in the tmpfs:

Jun 24 17:43:19 systemd-testsuite testsuite-50.sh[465]: + mksquashfs /tmp/tmp.aoQmVM /tmp/tmp.aoQmVM.raw
Jun 24 17:43:19 systemd-testsuite testsuite-50.sh[470]: Write failed because Bad file descriptor
Jun 24 17:43:19 systemd-testsuite testsuite-50.sh[470]: FATAL ERROR:Failed to write to output filesystem

So it would seem unrelated? @mrc0mmand have you seen these before?

The networkd fail is #16105, rescheduled. However, I've never seen the dissect one before.

I see, thank you - it's very weird, it looks like mksquashfs fails to write to a subdir of /tmp

I'll reschedule the CentOS 7 build as well, to see if it's indeed a flake, but I'll note it in systemd/systemd-centos-ci#251 in case it comes back, so we can possibly debug it further.

Edit: I also rescheduled the LGTM run, even though it passed, just to have everything green. The new result should propagate once the run finishes (hopefully).

@bluca
Copy link
Member Author

bluca commented Jun 24, 2020

CI's quite unhappy today:
CentOS CI (Arch in KVM) has a failed networkd test, seems unrelated:

[RESULT] systemd-networkd-tests.py - FAIL (EC: 1) (log file: /build/vagrant-arch-testsuite.i5B/systemd-networkd-tests.py_FAIL.log)

CentOS CI (CentOS 7) has a failure in the dissect test which, although it tests a changed binary, fails before that, when creating a squashfs in the tmpfs:

Jun 24 17:43:19 systemd-testsuite testsuite-50.sh[465]: + mksquashfs /tmp/tmp.aoQmVM /tmp/tmp.aoQmVM.raw
Jun 24 17:43:19 systemd-testsuite testsuite-50.sh[470]: Write failed because Bad file descriptor
Jun 24 17:43:19 systemd-testsuite testsuite-50.sh[470]: FATAL ERROR:Failed to write to output filesystem

So it would seem unrelated? @mrc0mmand have you seen these before?

The networkd fail is #16105, rescheduled. However, I've never seen the dissect one before.

I see, thank you - it's very weird, it looks like mksquashfs fails to write to a subdir of /tmp

I'll reschedule the CentOS 7 build as well, to see if it's indeed a flake, but I'll note it in systemd/systemd-centos-ci#251 in case it comes back, so we can possibly debug it further.

Edit: I also rescheduled the LGTM run, even though it passed, just to have everything green. The new result should propagate once the run finishes (hopefully).

Thanks!

@bluca
Copy link
Member Author

bluca commented Jun 24, 2020

bionic-i386 seems to timeout when installing the packages to start the "upstream" test suite

@poettering
Copy link
Member

hmm, needs rebase

bluca added 3 commits June 25, 2020 08:44
Since cryptsetup 2.3.0 a new API to verify dm-verity volumes by a
pkcs7 signature, with the public key in the kernel keyring,
is available. Use it if libcryptsetup supports it in the
veritysetup helper binary.
Since cryptsetup 2.3.0 a new API to verify dm-verity volumes by a
pkcs7 signature, with the public key in the kernel keyring,
is available. Use it if libcryptsetup supports it.
Allow to explicitly pass root hash signature as a unit option. Takes precedence
over implicit checks.
@bluca bluca force-pushed the root_verity_sig branch from 4fec17c to d4d55b0 Compare June 25, 2020 07:47
@bluca
Copy link
Member Author

bluca commented Jun 25, 2020

hmm, needs rebase

rebased

@poettering poettering merged commit b7d81d1 into systemd:master Jun 25, 2020
@bluca bluca deleted the root_verity_sig branch June 25, 2020 11:54
@bluca
Copy link
Member Author

bluca commented Jun 25, 2020

@poettering would it be useful to think of a way to add support for signatures for the GPT images/discoverable partitions case? I don't plan to use it myself, but the story feels a bit incomplete otherwise

@poettering
Copy link
Member

poettering commented Jun 26, 2020

@bluca hmm, maybe. I mean we could define a partition type where one could place the signatures in, so that when dissecting such a disk image we could search for the signature and just use it. But most likely, in that case there should also be the root hash embedded into it. As I understand pkcs#7 actually optionally can contain both the signed data and the signature for it. So if we go that route we probably store a pkcs#7 signed root hash in the new partition table: whenever one of those is found everything else can be derived from it automatically...

But anyway, let's just wait until people show up who actually want something like that. Would be kinda cool though, i.e. a fully self-contained signed OS image to boot from.

@bluca
Copy link
Member Author

bluca commented Jun 26, 2020

Actually for some of my use cases (not all of them) I might be able to gently push toward the GPT model, so I might come back to this myself at some point. A new partition was the same thinking I had - I didn't consider the pkcs7 data+sig approach, I'll keep that in mind if I do get back to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cryptsetup dissect good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed pid1

Development

Successfully merging this pull request may close these issues.

3 participants