5 ms·
> The crash is in parsing an executable file. In a context that doesn't involve executing it. On a Linux system, this functionality would probably be implement
by duskwuff 7y ago
> The crash is in parsing an executable file.
In a context that doesn't involve executing it. On a Linux system, this functionality would probably be implemented with libelf or libbfd, neither of which depends on the kernel.
- mike_hock 7y agoWhy does it matter if I'm gonna execute it? The parsing doesn't need to be done in kernel space in either case. Then again, the kernel already has such a gigantic attack surface that it doesn't matter if the ELF parser is part of it.
- duskwuff 7y agoA UNIX-style process spawning interface, like exec() or posix_spawn(), requires the kernel to have some awareness of the executable format so that it can create a process from an executable image. It doesn't have to support every feature of the format, though. A model in which this happens in userspace is conceivable, but it'd be pretty weird. Besides, it introduces a chicken-and-egg problem -- if you need a process to launch a process, you need some sort of special case for init.
- jchw 7y agoIIRC, the binfmt elf code in the Linux kernel basically only does enough elf parsing to map everything into memory and kick off the linker. Then the linker does the rest, in userland. It matters because the binfmt code can be very hardened and minimal, whereas the userspace can go and do whatever it wants. Of course the ELF parsing doesn't literally have to be done by the kernel, but there's no obvious good place to put it otherwise, considering it's a critical bit. If security is the real concern, then why wouldn't you just drop privileges while parsing ELF instead? I don't see the benefit to moving this code outside of the kernel. Maybe somehow moving it to a different protection ring would be helpful; but same for the rest of the binfmts. I believe the Windows loader that loads PE files, is in fact in the kernel, along with a lot of other stuff. At the end of the day, when the Windows NT kernel was architected, speed was really important and security practices were not matured. I mean, the kernel handles or at once handled a lot of stuff, especially related to the GUI and even network RPCs and network services.
- mike_hock 7y ago> Maybe somehow moving it to a different protection ring would be helpful; but same for the rest of the binfmts And goes for a lot of other kernel code.
- saagarjha 7y ago> IIRC, the binfmt elf code in the Linux kernel basically only does enough elf parsing to map everything into memory and kick off the linker. Even for statically linked executables?
- NieDzejkob 7y agoFor a statically linked executable, the minimal parsing is enough to kick off the executable directly. After all, the linker is "just" a statically linked executable...
- rkeene2 7y agoOne could use eBPF to do the parsing safely in the kernel ;-)
- Varriount 7y agoBut here's a question - supposing that this functionality was moved into a hypothetical library "pe.dll"/"pe.exe", how would the kernel load this library or executable? Wouldn't one run into a catch-22 situation?
- scintill76 7y agoI think they're saying that userland should handle whatever the mouseover is trying to do (another comment says it displays author and version info embedded in the exe). Things that actually require kernel privileges would remain in the kernel.
- paulddraper 7y agoThe kernel would probably statically link it.
- saagarjha 7y ago…wouldn’t that have the effect of bringing this code back into the kernel’s address space?
- paulddraper 7y agoThe code itself would be in the kernel, but the "parsing while mousing over" invocation would be on userspace code. That is, the parse logic could be a library linked by multiple application.
- Pick-A-Hill2019 7y agowouldn't you load/call it during boot or when the mouse driver loads? If you have a mouse, you are almost certainly going to generate an on-mouse-over event at some point. The advantage is that it isn't running in ring 0.