Skip to content

Add support for Physical KASLR#590

Open
NOTMASTER08 wants to merge 6 commits into
Limine-Bootloader:trunkfrom
NOTMASTER08:pkaslr
Open

Add support for Physical KASLR#590
NOTMASTER08 wants to merge 6 commits into
Limine-Bootloader:trunkfrom
NOTMASTER08:pkaslr

Conversation

@NOTMASTER08

Copy link
Copy Markdown

The limine protocol already doesn't give any guarantees about physical load address, all that's left is to just randomize the physical load address as well if kaslr is enabled.

Comment thread common/mm/pmm.s2.c Outdated
}
// Allocator potentially calling allocator is risky, but i'll just say it'll
// be *fine* for now since this is only used for PKASLR
uint64_t slot = (total_slots * (uint64_t)(rand32())) >> 32;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you use this symbol? it's a S3 export and you're modifying S2 code.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seemed to be the most appropriate option, don't know what to replace with(don't want to roll my own crypto).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rand32() is actually not (cryptographically) safe in the slightest; it's Mersenne Twister. hmm...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend pulling your fork and using newly exposed HW randomness instead.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did that, still has the s3/s2 problem, and i don't know how to fix that besides copying the allocation function into pmm.c, or rolling my own PRNG. Neither of which i want to do.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps renaming rand.c to rand.s2.c would help fix this? the MT19937 should go anyway and be replaced by some LCG.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to build now, at least. Not sure if that's the best solution but if it works it works ig.

Signed-off-by: NOTMASTER08 <41077257+NOTMASTER08@users.noreply.github.com>
Signed-off-by: NOTMASTER08 <41077257+NOTMASTER08@users.noreply.github.com>
Signed-off-by: NOTMASTER08 <41077257+NOTMASTER08@users.noreply.github.com>
Signed-off-by: NOTMASTER08 <41077257+NOTMASTER08@users.noreply.github.com>
Signed-off-by: NOTMASTER08 <41077257+NOTMASTER08@users.noreply.github.com>
Signed-off-by: NOTMASTER08 <41077257+NOTMASTER08@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants