From c31e15cf6ae7cc53622aaca16fec57af0629632e Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 18 Sep 2025 17:36:40 +0200 Subject: [PATCH] Add ltp-patch to correct scanf address format for mmap04 --- auxprogs/Makefile.am | 3 +- ...-the-scanf-address-format-is-at-leas.patch | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 auxprogs/ltp-patches/0003-mmap04-Make-sure-the-scanf-address-format-is-at-leas.patch diff --git a/auxprogs/Makefile.am b/auxprogs/Makefile.am index e7ff5a5da..0ce348ef5 100644 --- a/auxprogs/Makefile.am +++ b/auxprogs/Makefile.am @@ -22,7 +22,8 @@ LTP_FILTERS = \ LTP_PATCHES = \ ltp-patches/0001-Make-sure-32-bit-powerpc-syscall-defs-don-t-leak-to-.patch \ - ltp-patches/0002-Introduce-LTP_QUIET-env-var.patch + ltp-patches/0002-Introduce-LTP_QUIET-env-var.patch \ + ltp-patches/0003-mmap04-Make-sure-the-scanf-address-format-is-at-leas.patch EXTRA_DIST = \ docs/valgrind-listener-manpage.xml \ diff --git a/auxprogs/ltp-patches/0003-mmap04-Make-sure-the-scanf-address-format-is-at-leas.patch b/auxprogs/ltp-patches/0003-mmap04-Make-sure-the-scanf-address-format-is-at-leas.patch new file mode 100644 index 000000000..7956999b3 --- /dev/null +++ b/auxprogs/ltp-patches/0003-mmap04-Make-sure-the-scanf-address-format-is-at-leas.patch @@ -0,0 +1,39 @@ +From 6c3a6a6f625b58e8dc611cc12bc6015dc8dd5b32 Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Thu, 18 Sep 2025 17:16:05 +0200 +Subject: [PATCH] mmap04: Make sure the scanf address format is at least 8 hex + chars + +The addresses in /proc/self/maps are at least 8 hex chars. Zeros are +added to the front of the address when shorter (both on 32bit and +64bit systems). + +Under valgrind the mmaps used in kernel/syscalls/mmap/mmap04.c come +out very low in the address space and might be shorter than 8 hex +chars. This causes the scanf to fail: +mmap04.c:62: TBROK: Expected 1 conversions got 0 FILE '/proc/self/maps' + +Fix this by using "%08" PRIxPTR when creating the fmt used. + +Signed-off-by: Mark Wielaard +--- + testcases/kernel/syscalls/mmap/mmap04.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/testcases/kernel/syscalls/mmap/mmap04.c b/testcases/kernel/syscalls/mmap/mmap04.c +index 4a050b7b50da..5b28180df29b 100644 +--- a/testcases/kernel/syscalls/mmap/mmap04.c ++++ b/testcases/kernel/syscalls/mmap/mmap04.c +@@ -58,7 +58,8 @@ static void run(unsigned int i) + + addr2 = SAFE_MMAP(addr1 + pagesize, pagesize, tc->prot, tc->flags | MAP_FIXED, -1, 0); + +- sprintf(fmt, "%" PRIxPTR "-%%*x %%s", (uintptr_t)addr2); ++ /* A /proc/self/maps address is at least 8 hex (left zero padded) */ ++ sprintf(fmt, "%08" PRIxPTR "-%%*x %%s", (uintptr_t)addr2); + SAFE_FILE_LINES_SCANF("/proc/self/maps", fmt, perms); + + if (!strcmp(perms, tc->exp_perms)) { +-- +2.51.0 + -- 2.47.3