Bug 219227
Summary: | MDWE does not prevent read-only, executable, shared memory regions to be updated by backing file writes | ||
---|---|---|---|
Product: | Linux | Reporter: | Ali Polatel (alip) |
Component: | Kernel | Assignee: | Virtual assignee for kernel bugs (linux-kernel) |
Status: | NEW --- | ||
Severity: | normal | Flags: | mricon:
bugbot+
|
Priority: | P3 | ||
Hardware: | All | ||
OS: | Linux | ||
Kernel Version: | Subsystem: | MEMORY MANAGEMENT | |
Regression: | No | Bisected commit-id: |
Description
Ali Polatel
2024-09-03 15:51:47 UTC
I am sorry, I forgot to post the output of the PoC. On a system with Linux kernel 6.8 I get: ⇒ ./a.out [*] Mapped Content: malicious code [!] RX memory updated thru a backing file write under MDWE. Note, this is trivial to mitigate with a seccomp-bpf filter. Sample code in Rust. Given "ctx" is a seccomp filter context: // Prevent executable shared memory. ctx.add_rule_conditional( ScmpAction::KillProcess, ScmpSyscall::new("mmap"), // same applies for mmap2. &[scmp_cmp!($arg2 & PROT_EXEC == PROT_EXEC), scmp_cmp!($arg3 & MAP_SHARED == MAP_SHARED)], )?; This is what syd[1] does since version 3.15.1 [1]: https://man.exherbolinux.org/syd.7.html#Advanced_Memory_Protection_Mechanisms FTR, same PoC works on HardenedBSD, who have their own PaX implementation, even with private mappings: https://git.hardenedbsd.org/hardenedbsd/HardenedBSD/-/issues/107 Assigning to MM and invoking bugbot. |