Skip to content

Commit 19fba9b

Browse files
committed
procfs: do not use RHEL 8 backported fsopen(2)
There appears to be an insanely difficult to debug performance pathology with their backport (which I've struggled to debug for many weeks now). It's time to just cut our losses and not bother trying to use this feature on kernels that tried to backport it. Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
1 parent 422c59f commit 19fba9b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

procfs_linux.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"golang.org/x/sys/unix"
2222

2323
"github.com/cyphar/filepath-securejoin/internal/gocompat"
24+
"github.com/cyphar/filepath-securejoin/internal/kernelversion"
2425
)
2526

2627
func fstat(f *os.File) (unix.Stat_t, error) {
@@ -75,7 +76,7 @@ func verifyProcRoot(procRoot *os.File) error {
7576

7677
var hasNewMountAPI = gocompat.SyncOnceValue(func() bool {
7778
// All of the pieces of the new mount API we use (fsopen, fsconfig,
78-
// fsmount, open_tree) were added together in Linux 5.1[1,2], so we can
79+
// fsmount, open_tree) were added together in Linux 5.2[1,2], so we can
7980
// just check for one of the syscalls and the others should also be
8081
// available.
8182
//
@@ -91,7 +92,12 @@ var hasNewMountAPI = gocompat.SyncOnceValue(func() bool {
9192
return false
9293
}
9394
_ = unix.Close(fd)
94-
return true
95+
96+
// RHEL 8 has a backport of fsopen(2) that appears to have some very
97+
// difficult to debug performance pathology. As such, it seems prudent to
98+
// simply reject pre-5.2 kernels.
99+
isNotBackport, _ := kernelversion.GreaterEqualThan(kernelversion.KernelVersion{5, 2})
100+
return isNotBackport
95101
})
96102

97103
func fsopen(fsName string, flags int) (*os.File, error) {

0 commit comments

Comments
 (0)