Add tst_get_hugepage_size() to LTP library
PATCH 1/2 Add tst_get_hugepage_size() to LTP library
Signed-off-by Martin Doucha <[email protected]>
---
Simple helper function for the Hugepage CoW test.
include/tst_hugepage.h | 5 +++++ lib/tst_hugepage.c | 9 +++++++++ 2 files changed, 14 insertions(+)
include/tst_hugepage.h +5 -0
@@ -12,6 +12,11 @@extern char *nr_opt;/* -s num Set the number of the been allocated hugepages */ extern char *Hopt;/* -H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs */ +/* +* Get the default hugepage size. Returns 0 if hugepages are not supported. +*/ +size_t tst_get_hugepage_size (void ); +/* * Try the best to request a specified number of huge pages from system, * it will store the reserved hpage number in tst_hugepages.
lib/tst_hugepage.c +9 -0
@@ -12,6 +12,15 @@ unsigned long tst_hugepages;char *nr_opt;char *Hopt; +size_t tst_get_hugepage_size (void ) +{ +if (access (PATH_HUGEPAGES ,F_OK )) { +return 0 ; + } + +return SAFE_READ_MEMINFO ("Hugepagesize:" ) *1024 ; +} +unsigned long tst_request_hugepages (unsigned long hpages) {unsigned long val, max_hpages;
Signature · 1 line
2.26.2
PATCH 2/2 Add test for CVE 2017-1000405
Fixes #316
Signed-off-by Martin Doucha <[email protected]>
--- runtest/cve | 1 + runtest/mm | 1 + testcases/kernel/mem/.gitignore | 1 + testcases/kernel/mem/thp/Makefile | 1 + testcases/kernel/mem/thp/thp04.c | 154 ++++++++++++++++++++++++++++++ 5 files changed, 158 insertions(+) create mode 100644 testcases/kernel/mem/thp/thp04.c
runtest/cve +1 -0
@@ -43,6 +43,7 @@ cve-2017-18075 pcrypt_aead01 cve-2017-1000111 setsockopt07 cve-2017-1000112 setsockopt05 cve-2017-1000380 snd_timer01 +cve-2017-1000405 thp04 cve-2018-5803 sctp_big_chunk cve-2018-7566 snd_seq01 cve-2018-8897 ptrace09
runtest/mm +1 -0
@@ -86,6 +86,7 @@ swapping01 swapping01 -i 5 thp01 thp01 -I 120 thp02 thp02 thp03 thp03 +thp04 thp04 vma01 vma01 vma02 vma02
testcases/kernel/mem/.gitignore +1 -0
@@ -65,6 +65,7 @@ /thp/thp01 /thp/thp02 /thp/thp03 +/thp/thp04 /tunable/max_map_count /tunable/min_free_kbytes /tunable/overcommit_memory
testcases/kernel/mem/thp/Makefile +1 -0
@@ -18,6 +18,7 @@ # top_srcdir ?= ../../../.. +thp04: LDLIBS += -lrt include $(top_srcdir)/include/mk/testcases.mk include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk
testcases/kernel/mem/thp/thp04.c new file +154 -0
154 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 2/2 Add test for CVE 2017-1000405
----- Original Message -----
testcases/kernel/mem/thp/thp04.c line 22
Quoted 5 lines
testcases/kernel/mem/thp/thp04.c new file +5
-0+ +#include <sys/mman.h> + +#include "tst_test.h" +#include "tst_fuzzy_sync.h"
We should also include lapi/mmap.h, and check MADV_HUGEPAGE support at runtime, since older distros might not have it.
Other than that, it looks good to me.