Exploit databaseDownload repository ZIP
GH-b2682eea148b61d664fff913b24cc4d4
lw5959/xring-cve-2026-98260
Sources for CVE-2026-98260
60 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files5
lw5959/xring-cve-2026-98260Revision 8b404774be19
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
tools/kmem_callsite_probe.c
C · 3,200 bytes/* kmem_callsite_probe: 在新内核上实测 CVE-2026-98260 适配所需的
* kmem_cache_alloc 调用点(call_site)与对象名。
*
* 通过 tracefs 的 rss_stat trigger 启用 kmem:kmem_cache_alloc 事件,
* 依次触发 fork(task_struct)、timer_create(k_itimer / posix_timers_cache)、
* setresuid(struct cred / cred_jar),再读取 trace 文本,输出本进程相关的
* 事件行。输出用于与静态反汇编结果交叉核对 TIMER_LINK / TASK_LINK / CRED_LINK。
*
* 只读/普通 syscall,不触发 UAF。
*/
#define _GNU_SOURCE 1
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
#define TRACE "/sys/kernel/tracing"
#define TRIGGER TRACE "/events/kmem/rss_stat/trigger"
static int wf(const char *path, const char *text)
{
int fd = open(path, O_WRONLY | O_CLOEXEC);
int rc;
if (fd < 0) {
fprintf(stderr, "open %s: %s\n", path, strerror(errno));
return -1;
}
rc = (int)write(fd, text, strlen(text));
close(fd);
if (rc < 0) {
fprintf(stderr, "write %s: %s\n", path, strerror(errno));
return -1;
}
return 0;
}
int main(void)
{
char ver[512], *tracebuf, *line, *save;
char pidpat[32];
ssize_t got;
pid_t self = getpid();
pid_t child;
timer_t tid;
struct sigevent sev;
int fd, st, rc;
fd = open("/proc/version", O_RDONLY | O_CLOEXEC);
rc = (fd < 0) ? -1 : (int)read(fd, ver, sizeof(ver) - 1);
if (fd >= 0)
close(fd);
if (rc > 0) {
ver[rc] = 0;
printf("version: %s", ver);
}
wf(TRACE "/tracing_on", "0\n");
wf(TRACE "/trace", "0\n");
wf(TRACE "/buffer_size_kb", "8192\n");
if (wf(TRIGGER, "enable_event:kmem:kmem_cache_alloc\n"))
return 2;
wf(TRACE "/tracing_on", "1\n");
/* 1) fork => copy_process 分配 task_struct */
child = fork();
if (child == 0)
_exit(0);
if (child > 0)
waitpid(child, &st, 0);
/* 2) POSIX timer => alloc_posix_timer 分配 k_itimer */
memset(&sev, 0, sizeof(sev));
sev.sigev_notify = SIGEV_NONE;
errno = 0;
rc = timer_create(CLOCK_MONOTONIC, &sev, &tid);
printf("timer_create rc=%d errno=%d\n", rc, rc ? errno : 0);
if (rc == 0)
timer_delete(tid);
/* 3) setresuid(-1,-1,-1) => prepare_creds 分配 struct cred */
errno = 0;
{
long r = syscall(SYS_setresuid, (uid_t)-1, (uid_t)-1, (uid_t)-1);
printf("setresuid rc=%ld errno=%d\n", r, r < 0 ? errno : 0);
}
usleep(300000);
wf(TRACE "/tracing_on", "0\n");
fd = open(TRACE "/trace", O_RDONLY | O_CLOEXEC);
if (fd < 0) {
perror("open trace");
return 3;
}
tracebuf = malloc(16U << 20);
if (!tracebuf)
return 4;
got = read(fd, tracebuf, 16U << 20);
close(fd);
if (got <= 0) {
perror("read trace");
return 5;
}
tracebuf[got - 1] = 0;
snprintf(pidpat, sizeof(pidpat), "-%d ", (int)self);
printf("trace bytes=%zd self=%d\n", got, (int)self);
line = strtok_r(tracebuf, "\n", &save);
while (line) {
if (strstr(line, pidpat) && strstr(line, "kmem_cache_alloc:"))
printf("%s\n", line);
line = strtok_r(NULL, "\n", &save);
}
free(tracebuf);
wf(TRIGGER, "disable_event:kmem:kmem_cache_alloc\n");
return 0;
}