* [LTP] [PATCH] hugeshmat04: fix long integer overflow on 32bit system
@ 2019-04-04 3:09 Li Wang
2019-04-04 10:40 ` Cyril Hrubis
0 siblings, 1 reply; 2+ messages in thread
From: Li Wang @ 2019-04-04 3:09 UTC (permalink / raw)
To: ltp
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [LTP] [PATCH] hugeshmat04: fix long integer overflow on 32bit system
2019-04-04 3:09 [LTP] [PATCH] hugeshmat04: fix long integer overflow on 32bit system Li Wang
@ 2019-04-04 10:40 ` Cyril Hrubis
0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2019-04-04 10:40 UTC (permalink / raw)
To: ltp
Hi!
Good catch, applied, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-04 10:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-04 3:09 [LTP] [PATCH] hugeshmat04: fix long integer overflow on 32bit system Li Wang
2019-04-04 10:40 ` Cyril Hrubis
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.