Exploit databaseDownload repository ZIP
GH-da6010618e69c188f9d9c8e9cb803347
viper-boss/iqoo-neo5-temp-root
Sources for CVE-2026-43499
166 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files16
viper-boss/iqoo-neo5-temp-rootRevision 121d760703eb
- ↑..Parent directory
- kernelsnitch/
- targets/
- common.h
- diag_params.c
- fops.c
- main.c
- offset.h
- pipe.c
- preload.c
- root.c
- slide.c
- su_blob.S
- su_daemon.c
- util.c
- wallpaper_blob.S
- wallpaper_blob_stub.S
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit/src/diag_params.c
C · 11,397 bytes/*
* diag_params.c — read-only kernel parameter diagnostics for PD2055
*
* Purpose: verify the constants baked into target.h against what the running
* kernel actually reports, WITHOUT triggering any vulnerability, without
* writing to any partition, without touching SELinux, and without spawning
* or killing any system service.
*
* Everything here is either a pure computation or a read of a world-readable
* file (/proc/slabinfo, /sys/devices/system/cpu/possible). No futex syscall
* that exercises remove_waiter() is issued; the only futex use is the pure
* in-memory hash computation from futex_hash.h.
*
* Build (device): make diag
* Build (host): make diag-host && ./build/host/diag_params
* Exit code: 0 if every check passed, 1 otherwise.
*
* License: GPLv3
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <errno.h>
#include <sys/utsname.h>
/* Host-side build: skip the fsync log redirection so pr_* stays printf. */
#define KS_NO_EXLOG 1
#define DEBUG 1
#include "kernelsnitch/futex_hash.h"
/* Pull in the target header (via offset.h -> TARGET_CONFIG_H) so section 5 can
* echo the compiled-in constants and prove the target.h edits are in the
* binary. target.h is pure #defines, safe to include on a host build. */
#include "offset.h"
/* Report macros mirroring the repo's style */
static int g_checks;
static int g_passed;
static int g_failed;
static int g_skipped;
#define CHECK(cond, name, ...) do { \
g_checks++; \
if (cond) { \
g_passed++; \
printf(" [PASS] %s\n", name); \
} else { \
g_failed++; \
printf(" [FAIL] %s", name); \
if (sizeof(#__VA_ARGS__) > 1) { \
printf(" — "); \
printf(__VA_ARGS__); \
} \
printf("\n"); \
} \
} while (0)
#define SKIP(name, reason) do { \
g_skipped++; \
printf(" [SKIP] %s — %s\n", name, reason); \
} while (0)
#define INFO(fmt, ...) printf(" [info] " fmt "\n", ##__VA_ARGS__)
/* ---------- slabinfo parsing ---------- */
struct slab_row {
char name[64];
unsigned long active_objs;
unsigned long num_objs;
unsigned long objsize;
unsigned long objperslab;
unsigned long pagesperslab;
int found;
};
static int read_slab_row(const char *want, struct slab_row *out)
{
FILE *f = fopen("/proc/slabinfo", "r");
if (!f) {
return -1;
}
char line[512];
memset(out, 0, sizeof(*out));
while (fgets(line, sizeof(line), f)) {
if (line[0] == '#' || line[0] == '\n') {
continue;
}
struct slab_row r;
memset(&r, 0, sizeof(r));
int n = sscanf(line, "%63s %lu %lu %lu %lu %lu",
r.name, &r.active_objs, &r.num_objs,
&r.objsize, &r.objperslab, &r.pagesperslab);
if (n < 6) {
continue;
}
if (strcmp(r.name, want) == 0) {
r.found = 1;
*out = r;
fclose(f);
return 0;
}
}
fclose(f);
return -1;
}
/* ---------- cpu count ---------- */
static unsigned long count_possible_cpus(void)
{
FILE *f = fopen("/sys/devices/system/cpu/possible", "r");
if (!f) {
return (unsigned long)sysconf(_SC_NPROCESSORS_ONLN);
}
char line[128];
unsigned long n = 0;
if (fgets(line, sizeof(line), f)) {
char *p = line;
while (*p) {
unsigned long a = 0, b = 0;
if (*p >= '0' && *p <= '9') {
a = strtoul(p, &p, 10);
b = a;
if (*p == '-') {
p++;
b = strtoul(p, &p, 10);
}
n += b - a + 1;
} else {
p++;
}
}
}
fclose(f);
return n ? n : (unsigned long)sysconf(_SC_NPROCESSORS_ONLN);
}
/* ---------- platform detection ----------
*
* Several assertions below (mm_struct objsize == 960, slab order == 3) are
* specific to the PD2055 4.19.152-perf kernel. When this diagnostic is built
* and run on a development host (e.g. WSL Ubuntu with a 6.x kernel) those
* device-specific values will legitimately differ, so they must be SKIPPED,
* not FAILED. We detect "are we on the target?" from the kernel release string
* (uname -r): the PD2055 kernel reports something like "4.19.152-perf+".
*
* The algorithmic checks (futex hash matches v4.19 semantics, hash is
* mm-independent, hashsize formula) are platform-independent and are always
* asserted, because they validate the compiled-in code, not the host.
*/
static int running_on_target(void)
{
struct utsname u;
if (uname(&u) != 0) {
return 0;
}
printf(" [info] uname -r = %s (machine %s)\n", u.release, u.machine);
/* target = arm64 kernel in the 4.19 line */
int is_419 = (strstr(u.release, "4.19") != NULL);
int is_arm64 = (strstr(u.machine, "aarch64") != NULL) ||
(strstr(u.machine, "arm64") != NULL);
return is_419 && is_arm64;
}
int main(void)
{
printf("==========================================================\n");
printf(" PD2055 kernel parameter diagnostics (READ-ONLY)\n");
printf(" No exploit, no partition writes, no SELinux changes.\n");
printf("==========================================================\n\n");
int on_target = running_on_target();
printf(" [info] running on target device: %s\n\n",
on_target ? "YES" : "NO (host build — device-specific checks skipped)");
/* ---- 1. futex hash size ---- */
printf("=== 1. futex hash size ===\n");
unsigned long ncpu = count_possible_cpus();
unsigned long expect_buckets = 1;
while (expect_buckets < 256 * ncpu) {
expect_buckets <<= 1;
}
futex_init();
INFO("possible cpus = %lu", ncpu);
INFO("expected futex_hashsize = %lu (0x%lx)", expect_buckets, expect_buckets);
INFO("computed futex_hashsize = %lu (0x%lx)", futex_hashsize, futex_hashsize);
CHECK(futex_hashsize == expect_buckets,
"futex_hashsize matches roundup_pow_of_two(256 * num_possible_cpus())",
"expected %lu, got %lu", expect_buckets, futex_hashsize);
/* ---- 2. hash mm-dependency (necessary precondition for KernelSnitch) ---- */
printf("\n=== 2. futex hash vs mm dependency ===\n");
int dep = futex_hash_mm_dependent();
INFO("futex_hash_mm_dependent() = %d", dep);
if (dep) {
INFO("hash varies with mm -> KernelSnitch localization possible in principle");
INFO("(necessary but NOT sufficient: still needs correct mm size/slab/scan)");
} else {
INFO("hash ignores mm -> KernelSnitch localization CANNOT work (layout bug?)");
}
/*
* Linux v4.19 hash_futex() hashes [address_lo, address_hi, mm_lo, mm_hi],
* so the hash MUST depend on mm. If this ever reports 0, the userspace
* futex_key_t layout does not match the kernel (regression) — fail loudly.
* NOTE: this validates the compiled-in hash model, not the live kernel;
* whether vivo modified hash_futex() is an UNVERIFIED assumption (README §15).
*/
CHECK(dep == 1,
"hash is mm-DEPENDENT (matches Linux v4.19 hash_futex: [addr,mm])",
"hash does not vary with mm (%d) — futex_key_t layout regression?", dep);
/* ---- 3. mm_struct slab geometry ---- */
printf("\n=== 3. mm_struct slab geometry ===\n");
struct slab_row s;
if (read_slab_row("mm_struct", &s) == 0) {
INFO("mm_struct objsize = %lu (0x%lx)", s.objsize, s.objsize);
INFO("mm_struct objs/slab = %lu", s.objperslab);
INFO("mm_struct pages/slab = %lu", s.pagesperslab);
unsigned long order = 0, pages = 1;
while (pages < s.pagesperslab) {
pages <<= 1;
order++;
}
INFO("implied slab order = %lu (slab size %lu)",
order, s.objsize * s.objperslab);
/* objs/slab vs order/objsize is a pure arithmetic identity — always
* valid regardless of platform, so always assert it. */
CHECK(s.objperslab == (4096UL << order) / s.objsize,
"objs/slab consistent with order and objsize",
"objs/slab %lu vs %lu", s.objperslab,
(4096UL << order) / s.objsize);
if (on_target) {
/* Device-specific: these values are from PD2055's slabinfo. */
CHECK(s.objsize == 960,
"mm_struct objsize == 960 (target.h MM_STRUCT_SZ 0x3C0)",
"slabinfo reports %lu", s.objsize);
CHECK(order == 3,
"mm_struct slab order == 3 (target.h MM_ORDER)",
"implied order %lu", order);
} else {
SKIP("mm_struct objsize == 960",
"not running on PD2055 (host mm_struct differs by design)");
SKIP("mm_struct slab order == 3",
"not running on PD2055 (host slab geometry differs)");
}
} else {
SKIP("mm_struct slab geometry",
"/proc/slabinfo unreadable or has no mm_struct row "
"(on most hosts it needs root; judge this on-device)");
}
/* ---- 4. kmalloc cache presence (pipe primitive sanity) ---- */
printf("\n=== 4. kmalloc cache presence ===\n");
const char *caches[] = {"kmalloc-512", "kmalloc-1k", "kmalloc-2k", "kmalloc-4k"};
for (size_t i = 0; i < sizeof(caches) / sizeof(caches[0]); ++i) {
struct slab_row c;
if (read_slab_row(caches[i], &c) == 0) {
INFO("%-12s objsize=%lu objs/slab=%lu", c.name, c.objsize, c.objperslab);
} else {
INFO("%-12s (not present)", caches[i]);
}
}
/* vivo-specific reclaim caches — informational only */
struct slab_row rcl;
if (read_slab_row("kmalloc-rcl-1k", &rcl) == 0) {
INFO("kmalloc-rcl-1k present (vivo reclaim cache) objsize=%lu", rcl.objsize);
} else {
INFO("kmalloc-rcl-1k absent");
}
g_checks++;
g_passed++;
printf(" [PASS] kmalloc cache enumeration completed\n");
/* ---- 5. target.h constant sanity (compile-time) ---- */
printf("\n=== 5. compiled-in target constants ===\n");
#ifdef MM_STRUCT_SZ
INFO("MM_STRUCT_SZ = 0x%lx", (unsigned long)MM_STRUCT_SZ);
#endif
#ifdef MM_ORDER
INFO("MM_ORDER = %d", MM_ORDER);
#endif
#ifdef KIMAGE_TEXT_BASE
INFO("KIMAGE_TEXT_BASE = 0x%llx", (unsigned long long)KIMAGE_TEXT_BASE);
#endif
printf("\n==========================================================\n");
printf(" Result: %d/%d checks passed, %d failed, %d skipped\n",
g_passed, g_checks, g_failed, g_skipped);
printf("==========================================================\n");
return g_failed ? 1 : 0;
}