From 52979da973f3c65b22c10e94b7d2e1357ab1ae63 Mon Sep 17 00:00:00 2001 From: Abel Barrera Duran Date: Sat, 19 Dec 2020 14:00:07 -0500 Subject: [PATCH] 32bit > 4GB integer overflow edge case fix --- cmd/kubeadm/app/preflight/checks_linux.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/kubeadm/app/preflight/checks_linux.go b/cmd/kubeadm/app/preflight/checks_linux.go index c89d6890136..7efc2757279 100644 --- a/cmd/kubeadm/app/preflight/checks_linux.go +++ b/cmd/kubeadm/app/preflight/checks_linux.go @@ -51,8 +51,8 @@ func (mc MemCheck) Check() (warnings, errorList []error) { errorList = append(errorList, errors.Wrapf(err, "failed to get system info")) } - // Totalram returns bytes; convert to MB - actual := uint64(info.Totalram) / 1024 / 1024 + // Totalram holds the total usable memory. Unit holds the size of a memory unit in bytes. Multiply them and convert to MB + actual := uint64(info.Totalram) * uint64(info.Unit) / 1024 / 1024 if actual < mc.Mem { errorList = append(errorList, errors.Errorf("the system RAM (%d MB) is less than the minimum %d MB", actual, mc.Mem)) }