Reproducer for ghostlock
v5 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 v5:
- reduced synchronization checkpoints from 5 to 3
- introduced and used SAFE_SCHED_SETATTR() in lapi/sched.h
- dropped unused PR_SET_MM_MAP_SIZE probe in setup()
- fixed duplicated -pthread entry in Makefile
- fixed CVE numerical ordering in runtest/cve
- Link to v4: https://lore.kernel.org/[email protected]
Changes in v4:
- handle runtime inside the test
- increase futext wait so we don't TBROK before runtime
- comment prctl() syscall
- move static vars out of the run function
- Link to v3: https://lore.kernel.org/[email protected]
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 (3):
lapi/sched: add SAFE_SCHED_SETATTR()
lapi/prctl: add more fallback definitions
cve: add CVE-2026-43499 reproducer
configure.ac | 2 + include/lapi/prctl.h | 25 +++++ include/lapi/sched.h | 19 ++++ runtest/cve | 1 + testcases/cve/.gitignore | 1 + testcases/cve/Makefile | 2 +- testcases/cve/ghostlock.c | 244 ++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 293 insertions(+), 1 deletion(-)
---
base-commit: 12724413534a6d4160ff9694ba6f09daa4ccb6bd
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 v5 1/3 lapi/sched: add SAFE_SCHED_SETATTR()
From: Andrea Cervesato <[email protected]>
Add a safe variant of sched_setattr() that breaks the test with TBROK on failure, so tests such as the CVE-2026-43499 reproducer do not have to open-code the TEST() + tst_brk() error handling.
--- include/lapi/sched.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
include/lapi/sched.h +19 -0
@@ -169,4 +169,23 @@ static inline int getcpu(unsigned *cpu, unsigned *node)# define CLONE_INTO_CGROUP 0x200000000ULL#endif +static inline int safe_sched_setattr (const char *file,const int lineno, +pid_t pid,const struct sched_attr *attr, +unsigned int flags) +{ +int ret; + + ret =sched_setattr (pid, attr, flags); + +if (ret ==-1 ) { +tst_brk_ (file, lineno,TBROK |TERRNO , +"sched_setattr(%i) failed" , pid); + } + +return ret; +} + +#define SAFE_SCHED_SETATTR (pid, attr, flags)\ + safe_sched_setattr(__FILE__, __LINE__, (pid), (attr), (flags)) +#endif /* LAPI_SCHED_H__ */
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] lapi/sched: add SAFE_SCHED_SETATTR()
Hi Andrea,
Quoted 1 line · Andrea Cervesato
lapi/sched: add
SAFE_SCHED_SETATTR()
--- [PATCH 1/3] ---
Quoted 7 lines
static inline int safe_sched_setattr(const char *file, const int lineno,
pid_tpid, const structsched_attr*attr, unsigned int flags){ int ret; ret = sched_setattr(pid, attr, flags);
glibc's sched_setattr() takes a non-const struct sched_attr pointer, so this discards const and fails with -Werror=discarded-qualifiers on the new glibc API. Match that prototype here and in the fallback declaration.
Quoted 2 lines
#define SAFE_SCHED_SETATTR(pid, attr, flags)\ safe_sched_setattr(__FILE__, __LINE__, (pid), (attr), (flags))
This new public macro needs a kernel-doc comment documenting its arguments and failure behavior.
--- [PATCH 2/3] ---
Quoted 9 lines
#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{
The fallback struct is unreachable when needed because PR_SET_MM_MAP is defined immediately before the condition. Gate it solely on HAVE_STRUCT_PRCTL_MM_MAP, otherwise the new CVE test fails to compile on systems lacking the struct.
--- [PATCH 3/3] ---
Quoted 5 lines
static struct
tst_testtest = {
.setup = setup,
.test_all = run,
.runtime = 180,
.needs_checkpoints = 1,
PR_SET_MM_MAP was added in Linux 3.18. Add .min_kver = "3.18"; otherwise 3.3--3.17 kernels with both requested configs reach setup and report TBROK for the unsupported operation.
Quoted 5 lines
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);The futex result is ignored, so expiry or another failure publishes CP_SPRAYED without establishing the PI topology and causes a spurious TBROK. Use an untimed blocking wait, or validate the result before the wake.
Quoted 3 lines
refluxfs
sctphantom
ghostlock
Keep the new .gitignore entry sorted by placing ghostlock before refluxfs.
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/sched: add SAFE_SCHED_SETATTR()
Quoted 3 lines
PR_SET_MM_MAPwas added in Linux 3.18. Add .min_kver = "3.18"; otherwise 3.3--3.17 kernels with both requested configs reach setup and report TBROK for the unsupported operation.
This can be ignored, the rest is valid. I will send a new version
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 2/3 lapi/prctl: add more fallback definitions
In reply to Andrea CervesatoFrom: 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
PATCH v5 3/3 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 | 244 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 247 insertions(+), 1 deletion(-)
runtest/cve +1 -0
@@ -88,6 +88,7 @@ cve-2023-1829 tcindex01 cve-2023-0461 setsockopt10 cve-2023-31248 nft02 cve-2023-52879 fanotify25 +cve-2026-43499 ghostlock cve-2026-53362 setsockopt11 cve-2026-64600 refluxfs # Tests below may cause kernel memory leak
testcases/cve/.gitignore +1 -0
@@ -18,3 +18,4 @@ cve-2025-21756 cve-2026-46331 refluxfs sctphantom +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 refluxfs: CFLAGS += -pthread +cve-2014-0196 cve-2016-7117 cve-2017-2671 cve-2017-17052 cve-2017-17053 ghostlock refluxfs: CFLAGS += -pthread cve-2014-0196 cve-2016-7117 cve-2017-2671: LDLIBS += -lrt ifneq ($(ANDROID),1)
testcases/cve/ghostlock.c new file +244 -0
244 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp