Clang Linux Fosdem 19 PDF
Clang Linux Fosdem 19 PDF
SECTIONS {
.initcallearly.init : {
...
*(.initcallearly.init..init/do_mounts_rd.c) ;
*(.initcallearly.init..init/do_mounts_initrd.c) ;
*(.initcallearly.init..init/do_mounts_md.c) ;
...
prodkernel: ThinLTO + LLD
● Gold linker had too many bugs
● LLD works great ... but doesn't retain linking order when using LTO
● Need to hack around this:
SECTIONS {
.initcallearly.init : {
...
*(.initcallearly.init..init/do_mounts_rd.c) ;
*(.initcallearly.init..init/do_mounts_initrd.c) ;
*(.initcallearly.init..init/do_mounts_md.c) ;
...
Some Fun Bugs
● register long long foo asm("edx"); on 32b hosts
https://github.com/ClangBuiltLinux/linux/issues/22#issuecomment-417454144
● Explicit NULL ptr derefence unencodeable on aarch64 https://bugs.llvm.org/show_bug.cgi?id=33134
● __attribute__((gnu_inline)) https://lkml.org/lkml/2018/6/5/710
● Symbol clashes with C stdlib https://github.com/ClangBuiltLinux/linux/issues/59
● Making up your own calling convention with -fcall-saved-* and -fcall-used-*
https://github.com/ClangBuiltLinux/linux/issues/25
● Clang doesn’t support VLAiS, but all VLA’s were removed from the kernel and -Wvla was enabled.
● Relying on code that’s only valid at -O2. (Also, __attribute__((always_inline)) doesn’t mean “always inline”).
● -fno-remove-null-pointer-checks, -fno-strict-aliasing, -fno-strict-overflow: reasoning.
● member_address_is_nonnull()
● Stack alignment with VLAs.
● __builtin_constant_p() https://github.com/ClangBuiltLinux/linux/issues/7
__builtin_constant_p
● Linux frequently takes "slow" path if __builtin_constant_p() evaluates to 0
● Required for kernel hardening: CONFIG_HARDENED_USERCOPY=y
Bad or missing usercopy whitelist? Kernel memory exposure attempt detected from SLUB object 'task_struct'!
Stack
In sg_set_buf(): ...
s
unsigned int offset = (unsigned long) buf & ~(~((1UL << 12) - 1)); /* 0x0FFF */ d
<return addr>
Спасибо! Ευχαριστώ!
Danke!
ありがとう! 謝謝!
Thank you! !תודה רבה
Me hoovercraft zit vull mè poaling'n! ¡Gracias!