Linking and security
Posted: Sat Oct 03, 2020 8:27 am
Forked from another topic.
In a nutshell: I'm saying if dynamic linker is in the kernel, then it can be more secure, as it can enforce WNX and deny writing code from user level. Some architecture supports this in hardware (like ARM), while others needs carefully assigned page attributes (like x86). Nullplan seems do disagree, however it looks more like he doesn't get the concept in the first place.
And about "parsing attacker-controlled data", isn't that true for everything? How about your kernel loading the interpreter? Or how about ACPI or AML? You don't support power management because that would mean parsing data in kernel?
Cheers,
bzt
In a nutshell: I'm saying if dynamic linker is in the kernel, then it can be more secure, as it can enforce WNX and deny writing code from user level. Some architecture supports this in hardware (like ARM), while others needs carefully assigned page attributes (like x86). Nullplan seems do disagree, however it looks more like he doesn't get the concept in the first place.
In a monolithic kernel everything is in the kernel. Why not this one?nullplan wrote:We're just going to have to agree to disagree on that one. A dynamic linker is a complex piece of software parsing attacker-controlled data, and it is getting nowhere near my kernel.bzt wrote:A dynamic linker is not of a big complexity. Not simple, but not particularly complex either (typically no more than few hundred SLoC).
And about "parsing attacker-controlled data", isn't that true for everything? How about your kernel loading the interpreter? Or how about ACPI or AML? You don't support power management because that would mean parsing data in kernel?
Yes, I did. Read the specification. Having either executable or writable pages makes buffer-overflows impossible. There's not much to explain, either you understand this, or you don't. With WNX buffer overflows might modify data, but they can't inject code.nullplan wrote:Nice evade. You didn't actually answer my question.bzt wrote:Are you serious? What do you think, why did ARM implement WNX permission in hardware if its just a "nonsense"?
Because that's obvious. If you put the dynamic linker in userspace, then you must allow to write code from userspace. First, you must load the code into memory (memory must be writable), second, you must modify the code with relocations. You can only do that if pages are writable that will be executed later.nullplan wrote:And that page doesn't say why you shouldn't allow userspace to map executable pages.
This sentence convinced me you don't have the required knowledge. Yes, there are features that are more secure, like having an MMU and separated address spaces, or like denying writing executable pages. Are you really saying that an M68k without privilege levels of any kind is equally secure to an x86 with rings or ARM with ELs? Think it again.nullplan wrote:There is no dipstick for security, no pressure gauge, no measuring tape.
You only wish. There are architectures which does not support PIC at all (x86 protected mode being one of them), and there are special instructions that always need relocation records (like "movabs" in x86_64, and short distance intermediates on ARM). A purely PIC instruction encoding would be nice, I agree, but sadly current processors are not like that.nullplan wrote:Textrels are an awful hack only present in non-PIC code that has been linked dynamically. PIC code actually manages to put all the relocations into the data section, and the actual code section remains unaltered.
You are very, very very mistaken. Firefox is full of overflow problems which allow running arbitrary code (and this list is only for the last year). It even uses JIT compiled JavaScript, which by definition requires writeable *and* executable memory.nullplan wrote:No, no, and no. Malicious code already cannot modify existing code. For instance, here I am looking at all Firefox instances on my system
I beg to differ. Memory protection is per page. You can easily align GOT on page boundary, and have that read-only, while having all the rest of the data writable. It is YOUR kernel, you write the linker script and you write the dynamic linker! You can even put the GOT into its own segment if you wish!nullplan wrote:The GOT is in the same segment as the data section. You cannot write-protect one without write-protecting the other.
Cheers,
bzt