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

feat: udev: label device nodes #9779

Merged
merged 1 commit into from
Nov 22, 2024
Merged

Conversation

dsseng
Copy link
Member

@dsseng dsseng commented Nov 21, 2024

Use udev rules to assign basic device file labels based on their subsystem

Signed-off-by: Dmitry Sharshakov [email protected]

Dockerfile Outdated
@@ -731,6 +731,7 @@ COPY --chmod=0644 hack/containerd.toml /rootfs/etc/containerd/config.toml
COPY --chmod=0644 hack/cri-containerd.toml /rootfs/etc/cri/containerd.toml
COPY --chmod=0644 hack/cri-plugin.part /rootfs/etc/cri/conf.d/00-base.part
COPY --chmod=0644 hack/udevd/80-net-name-slot.rules /rootfs/usr/lib/udev/rules.d/
COPY --chmod=0644 hack/udevd/xx-selinux.rules /rootfs/usr/lib/udev/rules.d/
Copy link
Member Author

Choose a reason for hiding this comment

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

In what place in order should we place it? Perhaps 99?

Copy link
Member

Choose a reason for hiding this comment

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

I thought 99 is for user rules? @frezbo ?

So probably somewhere below it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Set 90 now

Copy link
Member

Choose a reason for hiding this comment

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

90 feels good, maybe we should also do a validation that the user doesn't override these?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, user is the Talos admin, not the k8s admin who we protect the system from. Perhaps should be okay

Copy link
Member

Choose a reason for hiding this comment

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

I guess it's fine, on second thoughts I believe we allow overwriting existing udev rules, so should be okay

internal/pkg/selinux/policy/selinux/services/udev.cil Outdated Show resolved Hide resolved
hack/udevd/xx-selinux.rules Outdated Show resolved Hide resolved
@@ -0,0 +1,11 @@
SUBSYSTEM=="*",SECLABEL{selinux}="system_u:object_r:device_t:s0"
Copy link
Member

Choose a reason for hiding this comment

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

are these labels like standard? I guess devices can have standard labels

Copy link
Member Author

Choose a reason for hiding this comment

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

Apparently (fsuse trans devtmpfs (system_u object_r device_t (systemLow systemLow))) is not sufficient for this to be default

// Devices labeled by subsystems, labeled by udev
expectedLabelsDevices := map[string]string{
"/dev/rtc0": "system_u:object_r:rtc_device_t:s0",
"/dev/tpm0": "system_u:object_r:tpm_device_t:s0",
Copy link
Member

Choose a reason for hiding this comment

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

hmm /dev/tpm is not available by default on our qemu tests, right? only for secureboot i believe

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. I added an option for test to ignore when file doesn't exist

Copy link
Member

Choose a reason for hiding this comment

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

actually let's just enable tpm2 for all tests in CI, it shouldn't hurt, better than trying to match on error, probably can do in a different PR

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do

Use udev rules to assign basic device file labels based on their subsystem

Signed-off-by: Dmitry Sharshakov <[email protected]>
@dsseng
Copy link
Member Author

dsseng commented Nov 22, 2024

/m

@talos-bot talos-bot merged commit a13f82c into siderolabs:main Nov 22, 2024
50 checks passed
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.

4 participants