Commit Graph

21 Commits

Author SHA1 Message Date
Mintsuki
5df9958154 lib/pe: Validate SizeOfOptionalHeader is large enough 2026-04-02 22:21:54 +02:00
Mintsuki
01186e2051 lib/pe: Use uint64_t for sections offset calculation to prevent 32-bit overflow 2026-04-02 01:44:58 +02:00
Mintsuki
eb071a0121 misc: Add overflow checking to ALIGN_UP and DIV_ROUNDUP macros 2026-04-02 01:44:58 +02:00
Mintsuki
d7f0160ddc mm/pmm: Add ext_mem_alloc_counted(), use it everywhere for checked array allocations 2026-03-31 15:31:50 +02:00
Mintsuki
129e1b1ca8 lib/pe: Bounds-check import and relocation directory VirtualAddress against image_size 2026-02-09 13:02:39 +01:00
Mintsuki
f1167da7a9 misc: Fix wrong format specifiers for 64-bit arguments in print calls 2026-02-09 13:02:39 +01:00
Mintsuki
572e9f7116 lib/elf, lib/pe: Reject non-power-of-2 alignment values 2026-02-09 13:02:39 +01:00
Mintsuki
84299dd836 lib/pe: Validate OptionalHeader.Magic against PE32+ before parsing 2026-02-09 13:02:39 +01:00
Mintsuki
08bc777d17 lib/pe: Reject 32-bit relocations in higher-half PE images 2026-02-09 13:02:39 +01:00
Mintsuki
2f809815f6 lib/pe: Bounds-check per-entry relocation offset against image size 2026-02-09 13:02:38 +01:00
Mintsuki
5e052b30c2 lib/pe: Validate relocation block size against remaining directory size 2026-02-09 13:02:38 +01:00
Mintsuki
679b0d6c15 lib/pe: Validate NumberOfRvaAndSizes and relocation block VirtualAddress 2026-02-09 13:02:38 +01:00
Mintsuki
059bf6d79d lib/pe: Validate section VirtualAddress against SizeOfImage 2026-02-09 13:02:38 +01:00
Mintsuki
2da3c0ef7a lib/pe: Validate SizeOfHeaders against image size 2026-02-09 13:02:38 +01:00
Mintsuki
a1d6f0d2a7 pe: Add file size check to prevent integer underflow 2026-01-13 01:03:08 +01:00
Mintsuki
19eb9942aa pe: Add bounds check for e_lfanew offset in pe_bits 2026-01-13 01:03:08 +01:00
Mintsuki
a7054df925 pe: Validate relocation block size to prevent infinite loop and underflow 2026-01-11 23:45:22 +01:00
Mintsuki
7d811beee6 pe: Validate PE header offsets against file size 2026-01-11 23:45:22 +01:00
Qwinci
8a024b24e3 lib: Don't discard discardable sections for PE images
Code put to a discardable section like INIT might be intended to only be
discarded after early kernel init, not before the kernel is even loaded.
Leave reclaiming the discardable memory up to the kernel so it can choose
to do it after it is done using the memory.
2025-09-15 18:54:47 +03:00
Qwinci
30a3928e58 lib/pe: Map image headers 2025-02-19 10:36:18 +02:00
czapek
8b01ea3430 lib: Add support for loading PE images (#442)
* lib: Add support for loading PE images

* lib/pe: Use standard integer types

* lib/pe: Fix section alignment

* lib/pe: Properly iterate base relocation blocks

* lib/pe: Add missing machine types

* protos/limine: Add kernel format detection logic

* lib/pe: Fix integer to pointer conversion errors

* lib/elf: Add previously removed check

* lib/pe: Fix base relocation block iteration code

* lib/pe: Add missing machine types to pe_bits
2025-01-08 00:35:15 +01:00