Re: [PATCH v5 1/3] selftests/mm: add a probe for FOLL_FORCE writes through /proc/self/mem

From: David Hildenbrand (Arm)

Date: Thu Dec 03 2026 - 10:28:50 EST


On 12/1/26 20:16, Nikolai Dokutovich wrote:
> mkdirty and the ksm PROT_NONE test write through /proc/self/mem into a
> mapping that is not writable. With CONFIG_PROC_MEM_FORCE_PTRACE such a
> write is only allowed for a caller that traces the target, so both tests
> fail instead of skipping on a distribution kernel.
>
> Add a helper that performs that write on a scratch mapping and caches the
> result.
>
> Signed-off-by: Nikolai Dokutovich <ndokutovich@xxxxxxxxx>

Reviewed-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

> bool detect_huge_zeropage(void);
>
> +/*
> + * Whether a write through /proc/self/mem into a mapping that is not writable
> + * is permitted. Probed once and cached; the permission depends on the kernel
> + * configuration and on whether the caller traces the target, not on the
> + * mapping.

I'll likely reduce that down to "Whether a write through /proc/self/mem into a
mapping that is not writable is currently permitted." when applying.

> + */
> +bool proc_mem_force_write_allowed(void);
> +
> /*
> * Plan 9 FS has bugs (at least on QEMU) where certain operations fail with
> * ENOENT on unlinked files. See


--
Cheers,

David