are filesystems on linux just safer than the network subsystems or do filesystems just never expose any interface besides posix i/o so they have a much smaller and better-characterized attack surface?
Post
Why this can happen isn't necessarily important, but it has an important side effect for the application.
strikes immense fear into my heart
the "synchronous syscall with buffer" approach allows you to colocate request and response in the same thread, and synchronous blocking allows the kernel to schedule other work while waiting
ok i think i just ideologically do not believe in the page cache. i spent years in the mines carefully pipelining my threads and buffers and it turns out the kernel forces everything through the page cache bottleneck
microkernels because the user can always manage the memory hierarchy better than you
ok now i'm free. except i wanna check out openbsd's memory management
oh neat thanks openbsd https://blog.pr4tt.com/2016/02/23/OpenBSD-Virtual-Memory/ didn't realize how the cpu managed the page table although that makes perfect sense. a virtual address from userspace is loaded from the translated real address either in RAM or cpu cache. the kernel manages memory mappings per-process via the TLB, which is also a cpu feature
hm so a "thread" is mostly memory context? but then it's less of an "OS thread" than a "cpu thread" imho
the uvm phd dissertation begins with a tirade on copying and i feel i may have embarrassed myself saying zero-copy is ridiculous. but also this is 1998 and multicore wasn't a thing so each copy was a synchronous computation
Finally, data copying often flushes useful information out of the cache. Since the CPU accesses main memory through the cache, the process of copying data fills the cache with the data being copied — displacing potentially useful data that was resident in the cache before
the copy.
oh i'll be upset if the CPU manages the cache without me. i bet it does
so when people say memory bandwidth is often a limiting factor that's because the OS doesn't actually manage the cache? i guess this makes sense, especially with atomic coherency (i know that's in the cpu)
i was gonna say "what if they let me manage the cpu cache. just a little. as a treat" but x86 absolutely does have prefetch hint instructions! i remember this for reasons
see i will absolutely get all pouty and demand to control the kernel's i/o mechanics but the processor is cute it's trying its best i'm fine with a hint
so far it still seems that i am perfectly allowed to avoid linux's horrific decision to make entries in the "page cache" also act as a shared global mutable reference to a file region
i'm sorry i'm literally not doing that. global address space within a process? let's do it. the c standard gives me no choice. but also i can whisper in my cpu's ear and it remaps it! that's groovy. i'm with it.
but cross-process shared memory? accessible via uniform global path string? i will explicitly map a shared memory page if i want that!!!!
not only is "immediately globally visible" an excessively uncommon requirement, there is literally no alternative