Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkg/cdi/container-edits.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions pkg/cdi/container-edits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down