On Tue, Sep 15, 2026 at 7:04 PM Serge Hallyn (AMD) [off-list ref] wrote:
On Mon, Sep 07, 2026 at 11:00:17PM +0200, Jann Horn wrote:
quoted
+/**
+ * security_mem_foll_force() - Check if FOLL_FORCE is allowed
+ * @subject: credentials using which /proc/$pid/mem was opened
+ * @opened_by_owner: whether checks on open() were bypassed because the opener
+ * has the same MM as the target
+ *
+ * Check if FOLL_FORCE is allowed for accessing process memory through
+ * /proc/$pid/mem. opened_by_owner signals whether the opener's MM was the same
+ * as the target MM, meaning the security_ptrace_access_check() hook was
+ * bypassed on open().
+ * (Current current->mm does not matter for this; for example, if write() is
+ * called on an FD that was received from another process which obtained it with
+ * open("/proc/self/mem"), @opened_by_owner is still true.)
+ *
+ * Note that this hook is only designed to be useful in the opened_by_owner
+ * case, where the subject credentials effectively also describe the object.
Given this, would it make more sense to call the hook something
like `security_mem_foll_force_self()` and only call it in the
opened_by_owner==true case?
I only suggest it because it seems to lower the cognitive load
when looking at this code, so it might make it easier to maintain.
I agree with you, and that is what I did in the previous versions. :P
But given that two relevant maintainers disagreed with me, I changed
it in this version.