Skip to content

Commit

Permalink
tests: procfs: skip procfs tests if overmounting is blocked
Browse files Browse the repository at this point in the history
Future kernels will block this (making magic-link handling much safer)
so just skip the tests if we are running on one of those kernels. This
should make it into 6.12.

Link: <https://lore.kernel.org/all/[email protected]/>
Signed-off-by: Aleksa Sarai <[email protected]>
  • Loading branch information
cyphar committed Sep 13, 2024
1 parent 82e5725 commit 43b1026
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions procfs_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package securejoin

import (
"errors"
"fmt"
"os"
"path"
Expand Down Expand Up @@ -42,6 +43,13 @@ func doMount(t *testing.T, source, target, fsType string, flags uintptr) {
}

err := unix.Mount(sourcePath, targetPath, fsType, flags, "")
if errors.Is(err, unix.ENOENT) {
// Future kernels will block these kinds of mounts by marking all of
// these dentries with dont_mount(), which returns -ENOENT from mount.
// See <https://lore.kernel.org/all/[email protected]/>,
// which should make it into Linux 6.12. So ignore those errors.
t.Skipf("current kernel does not allow /proc overmounts -- all proc operations are implicitly safe")
}
require.NoErrorf(t, err, "mount(%s<%s>, %s<%s>, %s, 0x%x)", sourcePath, source, targetPath, target, fsType, flags)
}

Expand Down

0 comments on commit 43b1026

Please sign in to comment.