From: Li Wang <liwang@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] hugeshmat04: fix long integer overflow on 32bit system
Date: Thu, 4 Apr 2019 11:09:19 +0800 [thread overview]
Message-ID: <20190404030919.32192-1-liwang@redhat.com> (raw)
To fix an obvious integer overflow when system(32bit) original nr_hugepages >= 512.
--- Error log ---
# grep -i hugepage /proc/meminfo
HugePages_Total: 512
HugePages_Free: 512
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
# readelf -h hugeshmat04 |grep -i ELF
ELF Header:
Class: ELF32
# ./hugeshmat04
tst_test.c:1085: INFO: Timeout per run is 0h 05m 00s
mem.c:814: INFO: set nr_hugepages to -1024
mem.c:823: BROK: nr_hugepages = 512, but expect -1024
mem.c:814: INFO: set nr_hugepages to 512
-----------------
Reported-by: Zhonghua Hao <zhao@redhat.com>
Signed-off-by: Li Wang <liwang@redhat.com>
---
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c
index b4dea53d1..d375810cb 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c
@@ -99,7 +99,7 @@ static void setup(void)
hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
- hugepages = (orig_hugepages * hpage_size + SIZE) / hpage_size;
+ hugepages = orig_hugepages + SIZE / hpage_size;
set_sys_tune("nr_hugepages", hugepages, 1);
}
--
2.20.1
next reply other threads:[~2019-04-04 3:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-04 3:09 Li Wang [this message]
2019-04-04 10:40 ` [LTP] [PATCH] hugeshmat04: fix long integer overflow on 32bit system Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190404030919.32192-1-liwang@redhat.com \
--to=liwang@redhat.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.