diff --git a/pkg/cdi/container-edits.go b/pkg/cdi/container-edits.go index 4744eff..450a84f 100644 --- a/pkg/cdi/container-edits.go +++ b/pkg/cdi/container-edits.go @@ -337,8 +337,10 @@ func ValidateIntelRdt(i *cdi.IntelRdt) error { // Validate validates the IntelRdt configuration. func (i *IntelRdt) Validate() error { - // ClosID must be a valid Linux filename - if len(i.ClosID) >= 4096 || i.ClosID == "." || i.ClosID == ".." || strings.ContainsAny(i.ClosID, "/\n") { + // ClosID must be a valid Linux filename. Exception: "/" refers to the root CLOS. + switch c := i.ClosID; { + case c == "/": + case len(c) >= 4096, c == ".", c == "..", strings.ContainsAny(c, "/\n"): return errors.New("invalid ClosID") } return nil diff --git a/pkg/cdi/container-edits_test.go b/pkg/cdi/container-edits_test.go index ace0fd2..c1fcfab 100644 --- a/pkg/cdi/container-edits_test.go +++ b/pkg/cdi/container-edits_test.go @@ -254,6 +254,14 @@ func TestValidateContainerEdits(t *testing.T) { }, }, }, + { + name: "valid rdt config, root clos", + edits: &cdi.ContainerEdits{ + IntelRdt: &cdi.IntelRdt{ + ClosID: "/", + }, + }, + }, { name: "invalid rdt config, invalid closID (slash)", edits: &cdi.ContainerEdits{