:: commit 4bebeba64b83601ed3e0bed3cc444a9de6d76fad

mintsuki <mintsuki@protonmail.com> — 2020-12-27 22:51

parents: 8bb0db92d0

kaslr: Update documentation

diff --git a/CONFIG.md b/CONFIG.md
index b4d7c975..9ee23e3f 100644
--- a/CONFIG.md
+++ b/CONFIG.md
@@ -84,6 +84,7 @@ Some keys take *URIs* as values; these are described in the next section.
   modules.
   The entries will be matched in order. E.g.: the 1st module path entry will be matched
   to the 1st module string entry that appear, and so on.
+  * `KASLR` - If set to `yes`, it enables Kernel Address Layout Randomisation for 64-bit relocatable kernels.
   * `RESOLUTION` - The resolution to be used should the kernel request a graphical framebuffer. This setting takes the form of `<width>x<height>x<bpp>` and *overrides* any resolution requested by the kernel, or automatic resolution requests. If the resolution is not available, Limine will pick another one automatically.
 * Chainload protocol:
   * `DRIVE` - The 1-based BIOS drive to chainload.
diff --git a/STIVALE.md b/STIVALE.md
index 4e4c288e..03705492 100644
--- a/STIVALE.md
+++ b/STIVALE.md
@@ -43,9 +43,8 @@ At entry, the bootloader will have setup paging mappings as such:
   0x0000000000000000   -                 0x80000000                 -> 0xffffffff80000000
 ```
 
-If the kernel is dynamic and not statically linked, the bootloader will relocate it.
-Furthermore if bit 2 of the flags field in the stivale header is set, the bootloader
-will perform kernel address space layout randomisation (KASLR).
+If the kernel is dynamic and not statically linked, the bootloader will relocate it,
+potentially performing KASLR (as specified by the config).
 
 The kernel should NOT modify the bootloader page tables, and it should only use them
 to bootstrap its own virtual memory manager and its own page tables.
@@ -145,10 +144,12 @@ struct stivale_header {
     uint16_t flags;   // Flags
                       // bit 0  0 = text mode, 1 = graphics framebuffer mode
                       // bit 1  0 = 4-level paging, 1 = use 5-level paging (if
-                                                        available)
-                                Ignored if booting a 32-bit kernel.
-                      // bit 2  0 = Disable KASLR, 1 = enable KASLR (up to 1GB slide)
-                                Ignored if booting a 32-bit or non-relocatable kernel
+                      //                                available)
+                      //        Ignored if booting a 32-bit kernel.
+                      // bit 2  Formerly used to indicate whether to enable KASLR,
+                      //        this flag is now reserved as KASLR is enabled in the
+                      //        bootloader configuration instead. Presently
+                      //        reserved and unused.
                       // All other bits undefined.
 
     uint16_t framebuffer_width;   // These 3 values are parsed if a graphics mode
diff --git a/STIVALE2.md b/STIVALE2.md
index 1243fc54..823d0680 100644
--- a/STIVALE2.md
+++ b/STIVALE2.md
@@ -43,9 +43,8 @@ At entry, the bootloader will have setup paging mappings as such:
   0x0000000000000000   -                 0x80000000                 -> 0xffffffff80000000
 ```
 
-If the kernel is dynamic and not statically linked, the bootloader will relocate it.
-Furthermore if bit 0 of the flags field in the stivale2 header is set, the bootloader
-will perform kernel address space layout randomisation (KASLR).
+If the kernel is dynamic and not statically linked, the bootloader will relocate it,
+potentially performing KASLR (as specified by the config).
 
 The kernel should NOT modify the bootloader page tables, and it should only use them
 to bootstrap its own virtual memory manager and its own page tables.
@@ -147,7 +146,10 @@ struct stivale2_header {
                             // 64-bit and 32-bit valid stacks must be at least 256 bytes
                             // in usable space and must be 16 byte aligned addresses.
 
-    uint64_t flags;         // Bit 0: if 1, enable KASLR
+    uint64_t flags;         // Bit 0: Formerly used to indicate whether to enable
+                            //        KASLR, this flag is now reserved as KASLR
+                            //        is enabled in the bootloader configuration
+                            //        instead. Presently reserved and unused.
                             // All other bits undefined
 
     uint64_t tags;          // Pointer to the first of the linked list of tags.
tab: 248 wrap: offon