From 0fef122f87f804037f4a16bbf4f41044d4d4e92c Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Tue, 1 Jun 2021 10:32:47 +1000 Subject: [PATCH] cgroup2: io: handle 64-bit values correctly on 32-bit architectures strconv.ParseUint(..., 0) is not really safe, because on 32-bit architectures it will trigger runtime errors when trying to parse large numbers (which in the case of the cgroupv2 io controller, is almost certainly going to happen). Fixes: 1932917b716d ("libcontainer: add initial support for cgroups v2") Signed-off-by: Aleksa Sarai --- libcontainer/cgroups/fs2/io.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libcontainer/cgroups/fs2/io.go b/libcontainer/cgroups/fs2/io.go index 166b05582..77174f437 100644 --- a/libcontainer/cgroups/fs2/io.go +++ b/libcontainer/cgroups/fs2/io.go @@ -101,11 +101,11 @@ func statIo(dirPath string, stats *cgroups.Stats) error { if len(d) != 2 { continue } - major, err := strconv.ParseUint(d[0], 10, 0) + major, err := strconv.ParseUint(d[0], 10, 64) if err != nil { return err } - minor, err := strconv.ParseUint(d[1], 10, 0) + minor, err := strconv.ParseUint(d[1], 10, 64) if err != nil { return err } @@ -142,7 +142,7 @@ func statIo(dirPath string, stats *cgroups.Stats) error { continue } - value, err := strconv.ParseUint(d[1], 10, 0) + value, err := strconv.ParseUint(d[1], 10, 64) if err != nil { return err }