From 5bd6f0c6946f06fdd8905b1cad8971e8d37d8fcc Mon Sep 17 00:00:00 2001 From: Wojciech Aleksander Woloszyn Date: Mon, 26 Aug 2024 14:30:33 +0100 Subject: [PATCH 1/2] Fix the incorrect call to memset in app/memcmp, causing undefined behavior The memset call did effectively nothing because it set zero bytes. --- app/memcmp/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/memcmp/main.c b/app/memcmp/main.c index 6e157d0..77b6ece 100644 --- a/app/memcmp/main.c +++ b/app/memcmp/main.c @@ -154,7 +154,7 @@ void register_signal_handler(int signo) struct sigaction act, old_act; /* Specify #PF handler with signinfo arguments */ - memset(&act, sizeof(sigaction), 0); + memset(&act, 0, sizeof(sigaction)); act.sa_sigaction = fault_handler; act.sa_flags = SA_RESTART | SA_SIGINFO; From 619a124e3a6936cc228083a7ce349aee720a2169 Mon Sep 17 00:00:00 2001 From: Wojciech Aleksander Woloszyn Date: Mon, 26 Aug 2024 14:52:58 +0100 Subject: [PATCH 2/2] Fix another memset causing UB --- app/aep-redirect/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/aep-redirect/main.c b/app/aep-redirect/main.c index f9de842..d494055 100644 --- a/app/aep-redirect/main.c +++ b/app/aep-redirect/main.c @@ -101,7 +101,7 @@ void attacker_config_page_table(void) { print_pte_adrs(code_pt); /* Specify #PF handler with signinfo arguments */ - memset(&act, sizeof(sigaction), 0); + memset(&act, 0, sizeof(sigaction)); act.sa_sigaction = fault_handler; act.sa_flags = SA_RESTART | SA_SIGINFO;