linux-hardened icon indicating copy to clipboard operation
linux-hardened copied to clipboard

use 48-bit address space via 4 level page tables on arm64 by default

Open thestinger opened this issue 2 years ago • 4 comments

Linux kernel defaults to 39-bit address space, providing far weaker ASLR entropy than x86_64 and also making it incompatible with hardened_malloc in the default configuration since there's not enough space. It also weakens other mitigations based on using large PROT_NONE gaps.

https://github.com/GrapheneOS/hardened_malloc

We change this in the defconfigs for Android Generic Kernel Images, but the defaults can be changed in the configuration setup instead:

https://github.com/GrapheneOS/kernel_common-5.15/commit/82c2afeb59b52d08f9f72b6c917703d3ffbabec2 https://github.com/GrapheneOS/kernel_common-5.15/commit/5a4ec3db69061aada94009b177154ce743ce5993

thestinger avatar Apr 22 '23 18:04 thestinger

We needed to develop https://github.com/GrapheneOS/kernel_common-5.15/commit/ff8f099e45334978ae34564c79f20c61e90b0f77 with a user-facing per-app toggle to work around certain apps (mostly games) being incompatible with the larger address space. I don't think that's going to be an issue anywhere else. It's almost entirely an issue with games and mostly with older versions of Unity. I think it was fixed in newer Unity. Some other games seem to have the same issue. I doubt that it's an issue for any widely used server software in practice especially since many servers are likely already using 48 bit or larger address space.

thestinger avatar Apr 22 '23 19:04 thestinger

Is there any way to probe address space compatibility from within the kernel to conditionally set ELF_ET_DYN_BASE dependent on the userspace caller's ability handle the 48B address space? Alternatively, is it feasible to perform these checks at the alloc/libc levels to then request the correct base from ring0?

sempervictus avatar Aug 27 '23 13:08 sempervictus

No, but nearly everything does work with a 48-bit address space. The issue is that some apps have integer overflows or try to use the "unused" bits for tagging points.

thestinger avatar Aug 27 '23 14:08 thestinger

Very few applications still have this compatibility issue since we got Unity to fix it years ago.

thestinger avatar Jan 08 '24 15:01 thestinger