Skip to content

Commit 6379b58

Browse files
lifubangsohankunkerkar
authored andcommitted
libcontainer: force apps to think fips is enabled/disabled for testing
The motivation behind this change is to provide a flexible mechanism for containers within a Kubernetes cluster to opt out of FIPS mode when necessary. This change enables apps to simulate FIPS mode being enabled or disabled for testing purposes. Users can control whether apps believe FIPS mode is on or off by manipulating `/proc/sys/crypto/fips_enabled`. Signed-off-by: Sohan Kunkerkar <[email protected]>
1 parent 5bfff6a commit 6379b58

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

libcontainer/rootfs_linux.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ func checkProcMount(rootfs, dest, source string) error {
602602
"/proc/slabinfo",
603603
"/proc/net/dev",
604604
"/proc/sys/kernel/ns_last_pid",
605+
"/proc/sys/crypto/fips_enabled",
605606
}
606607
for _, valid := range validProcMounts {
607608
path, err := filepath.Rel(filepath.Join(rootfs, valid), dest)

libcontainer/rootfs_linux_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ func TestCheckMountDestNsLastPid(t *testing.T) {
4646
}
4747
}
4848

49+
func TestCheckCryptoFipsEnabled(t *testing.T) {
50+
dest := "/rootfs/proc/sys/crypto/fips_enabled"
51+
err := checkProcMount("/rootfs", dest, "/proc")
52+
if err != nil {
53+
t.Fatalf("/proc/sys/crypto/fips_enabled should not return an error: %v", err)
54+
}
55+
}
56+
4957
func TestNeedsSetupDev(t *testing.T) {
5058
config := &configs.Config{
5159
Mounts: []*configs.Mount{

0 commit comments

Comments
 (0)