|
| 1 | +From 3c241eeee132271e665bb29f2d1cb480a308c921 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Ben Cressey < [email protected]> |
| 3 | +Date: Thu, 13 Nov 2025 03:43:25 +0000 |
| 4 | +Subject: [PATCH] Set label for containerd overlayfs mounts |
| 5 | + |
| 6 | +--- |
| 7 | + daemon/containerd/image_snapshot.go | 11 +++++++++-- |
| 8 | + 1 file changed, 9 insertions(+), 2 deletions(-) |
| 9 | + |
| 10 | +diff --git a/daemon/containerd/image_snapshot.go b/daemon/containerd/image_snapshot.go |
| 11 | +index 3c61d98..f8154a1 100644 |
| 12 | +--- a/daemon/containerd/image_snapshot.go |
| 13 | ++++ b/daemon/containerd/image_snapshot.go |
| 14 | +@@ -151,13 +151,20 @@ func (l *rwLayer) mounts(ctx context.Context) ([]mount.Mount, error) { |
| 15 | + func (l *rwLayer) Mount(mountLabel string) (string, error) { |
| 16 | + ctx := context.TODO() |
| 17 | + |
| 18 | +- // TODO: Investigate how we can handle mountLabel |
| 19 | +- _ = mountLabel |
| 20 | + mounts, err := l.mounts(ctx) |
| 21 | + if err != nil { |
| 22 | + return "", err |
| 23 | + } |
| 24 | + |
| 25 | ++ // Apply SELinux mount label to overlay mounts (rootfs) only |
| 26 | ++ if mountLabel != "" { |
| 27 | ++ for i := range mounts { |
| 28 | ++ if mounts[i].Type == "overlay" { |
| 29 | ++ mounts[i].Options = append(mounts[i].Options, "context=\""+mountLabel+"\"") |
| 30 | ++ } |
| 31 | ++ } |
| 32 | ++ } |
| 33 | ++ |
| 34 | + var root string |
| 35 | + if root, err = l.refCountMounter.Mount(mounts, l.id); err != nil { |
| 36 | + return "", fmt.Errorf("failed to mount %s: %w", root, err) |
| 37 | +-- |
| 38 | +2.51.0 |
| 39 | + |
0 commit comments