don't leave parts of the bootloader in the kernel's address space
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Refactoring
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- rust
- Bereich
- operating-systems
Rechercherichtung
Beginne damit, src/binary/level_4_entries.rs rund um die erste 512GiB-Reservierung und src/binary/mod.rs rund um das context-switch- und GDT-Mapping zu lesen. Verfolge, wie die Seitentabelle des Kernels und Mappings erstellt werden; fertig ist die Aufgabe, wenn die Bootloader-Teile nicht mehr im Adressraum des Kernels verbleiben, das temporäre context-switch-Mapping behandelt wird und der Speicherort der GDT offengelegt oder konfigurierbar ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
While implementing finer granular ASLR I came across this comment:
https://github.com/rust-osdev/bootloader/blob/ac46d0455b41c11e5d316348d068df1c495ce0af/src/binary/level_4_entries.rs#L40
We mark the first 512GiB of the address space as unusable for dynamically generated addresses. I think we do this because we identity map the context switch code into kernel memory and this code most likely resides within the first 512GiB of the address space:
https://github.com/rust-osdev/bootloader/blob/a445433010960ec5d8a8b94a85fcac16a00489b5/src/binary/mod.rs#L166-L181
This causes a number of (admittedly small and unlikely) problems:
- The identity mapped pages could overlap with the kernel or other mappings
- We don't expose the identity mapped addresses to the kernel in
Mappings - An attacker could make use of the identity mapped pages to defeat ASLR
- We mark so a lot of usable memory as unusable and because of that we can't check for overlaps because there would be a lot of false positives. We currently just ignore overlaps.
We could probably work around those problems while still mapping parts of the bootloader into the kernel's address space, but I'd like to propose another solution: We use another very short lived page table to do the context switch. This page table would only map a few pages containing code that switches to the kernel's page table. Importantly, we would set the page table up in such a way that the kernel's entrypoint is just after the page table switch instruction, so we don't have to use any code to jump to the kernel, it would simply be the next instruction.
I don't think we could reliably map such code into the bootloader's address space because we'd have to map the code just before the kernel's entrypoint which could be close to bootloader's code, so that's why I want to use a short-lived page table.
We also identity map a GDT into the kernel's address space:
https://github.com/rust-osdev/bootloader/blob/a445433010960ec5d8a8b94a85fcac16a00489b5/src/binary/mod.rs#L183-L193
We should probably make the GDT's location configurable and expose it in Mappings.
I'd be happy to work on a pr for this.
- Vorherrschende Sprache
- Rust
- Sterne
- 1.7k
- Forks
- 240
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus rust-osdev/bootloader
-
help wanted
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 67/100
rust-osdev/bootloader#581 · 2 Kommentare ·
-
No boot on real hardware Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
rust-osdev/bootloader#573 · 5 Kommentare ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 20/100
rust-osdev/bootloader#555 · 2 Kommentare ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 30/100
rust-osdev/bootloader#534 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 38/100
rust-osdev/bootloader#525 ·
Alle Issues in rust-osdev/bootloader
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
BurntSushi/jiff#653 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
ZcashFoundation/zeeder#106 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
oxidize-rb/rb-sys#807 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
todo:ticket
Schwierigkeit 2/5 1-2 Tage Anfängerfreundlichkeit 74/100