mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 11:12:45 +00:00 
			
		
		
		
	Kernel: Add a 'disable_kaslr' kernel command line parameter
This parameter can be used to disable the KASLR mechanism.
This commit is contained in:
		
							parent
							
								
									54a12d34eb
								
							
						
					
					
						commit
						f9c6f37bac
					
				
					 2 changed files with 9 additions and 4 deletions
				
			
		|  | @ -96,10 +96,13 @@ extern "C" [[noreturn]] void init() | |||
|     FlatPtr default_kernel_load_base = 0x2000200000; | ||||
| #endif | ||||
| 
 | ||||
|     // KASLR
 | ||||
|     FlatPtr maximum_offset = (FlatPtr)KERNEL_PD_SIZE - MAX_KERNEL_SIZE - 2 * MiB; // The first 2 MiB are used for mapping the pre-kernel
 | ||||
|     FlatPtr kernel_load_base = default_kernel_load_base + (generate_secure_seed() % maximum_offset); | ||||
|     kernel_load_base &= ~(2 * MiB - 1); | ||||
|     FlatPtr kernel_load_base = default_kernel_load_base; | ||||
| 
 | ||||
|     if (__builtin_strstr(kernel_cmdline, "disable_kaslr") == nullptr) { | ||||
|         FlatPtr maximum_offset = (FlatPtr)KERNEL_PD_SIZE - MAX_KERNEL_SIZE - 2 * MiB; // The first 2 MiB are used for mapping the pre-kernel
 | ||||
|         kernel_load_base += (generate_secure_seed() % maximum_offset); | ||||
|         kernel_load_base &= ~(2 * MiB - 1); | ||||
|     } | ||||
| 
 | ||||
|     FlatPtr kernel_load_end = 0; | ||||
|     for (size_t i = 0; i < kernel_elf_header.e_phnum; i++) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Idan Horowitz
						Idan Horowitz