From feff2c451ecd2d27ac176da522380a472848bd2e Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 24 Jun 2021 17:14:06 -0700 Subject: [PATCH] libct/intelrdt: fix potential nil dereference In case getIntelRdtData() returns an error, d is set to nil. In case the error returned is of NotFoundError type (which happens if resctlr mount is not found in /proc/self/mountinfo), the function proceeds to call d.join(), resulting in a nil deref and a panic. In practice, this never happens in runc because of the checks in intelrdt() function in libcontainer/configs/validate, which raises an error in case any of the parameters are set in config but the IntelRTD itself is not available (that includes checking that the mount point is there). Nevertheless, the code is wrong, and can result in nil dereference if some external users uses Apply on a system without resctrl mount. Fix this by removing the exclusion. Signed-off-by: Kir Kolyshkin --- libcontainer/intelrdt/intelrdt.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcontainer/intelrdt/intelrdt.go b/libcontainer/intelrdt/intelrdt.go index bc01310e7..0ab762300 100644 --- a/libcontainer/intelrdt/intelrdt.go +++ b/libcontainer/intelrdt/intelrdt.go @@ -547,7 +547,7 @@ func (m *intelRdtManager) Apply(pid int) (err error) { return nil } d, err := getIntelRdtData(m.config, pid) - if err != nil && !IsNotFound(err) { + if err != nil { return err }