Re: [PATCH 2/3] proc: query LSMs for introspective mem access (if PROC_MEM_FORCE_ALWAYS)
Jann Horn <[email protected]>
| Newsgroups | gmane.linux.file-systems,gmane.linux.kernel.lsm,gmane.linux.kernel.mm |
|---|---|
| Message-ID | <CAG48ez22J6tYZv6cG0TEoUFBrbhtWh6BHrZYBWuD-ee1hVr4ZA@mail.gmail.com> |
On Tue, Aug 25, 2026 at 3:13 PM Christian Brauner <[email protected]> wrote: > On Tue, Aug 18, 2026 at 09:51:06PM +0200, Jann Horn wrote: > > If the system is running with PROC_MEM_FORCE_ALWAYS, LSMs currently have no > > good opportunity to block a process from overwriting read-only code in its > > own address space through FOLL_FORCE writes via /proc/self/mem. > > The security_ptrace_access_check() LSM hook is bypassed when a process > > opens /proc/self/mem because this is considered "introspection". > > Useful. I ran into this issue just yesterday in: > > https://github.com/systemd/systemd/pull/43511 > > Btw, it's kinda annoying that PTRACE_POKE{TEXT,DATA} still allows foll > force writes even if PROC_MEM_FORCE_NEVER is enabled. So ideally there'd > also be a hook for that option. You need either /proc/$pid/mem or PTRACE_POKETEXT for installing software breakpoints. I think if you want to completely block FOLL_FORCE through ptrace, you're probably in a scenario where ptrace should either be blocked completely, or at least restricted to mostly-read-only operations? > The other thing - though not directly FOLL_FORCE related - is that > process_vm_writev() isn't subject to any security restrictions other > than seccomp filtering either. It does go through mm_access() and ptrace_may_access() unless the access is same-MM, so it can be blocked by LSMs like Yama.