[PATCH] tomoyo: Drop FOLL_FORCE from tomoyo_dump_page()

From: Chris Down

Date: Sat Nov 28 2026 - 13:04:25 EST


tomoyo_dump_page() reads the argv and envp pages of the nascent exec mm
with get_user_pages_remote(..., FOLL_FORCE, ...). Its own comment says it
does the same thing as get_arg_page(bprm, pos, 0) in fs/exec.c, but
get_arg_page() stopped passing FOLL_FORCE in
commit cd57e443831d ("exec: Remove FOLL_FORCE for stack setup"), so the
two have drifted apart.

FOLL_FORCE only matters here if the page sits in a VMA that is not
readable. That can't happen: tomoyo_dump_page() is called from the
bprm_check_security hook, which runs before the binfmt handler calls
setup_arg_pages(), and at that point the only VMA in bprm->mm is the
stack VMA created by create_init_stack_vma() with VMA_STACK_FLAGS. Those
are built from the architecture's VMA_STACK_DEFAULT_FLAGS, which falls
back to VMA_DATA_DEFAULT_FLAGS. Every definition of either in the tree
is built from VMA_DATA_FLAGS_EXEC, VMA_DATA_FLAGS_TSK_EXEC or
VMA_DATA_FLAGS_NON_EXEC, and all three include VMA_READ_BIT and
VMA_MAYREAD_BIT. Reading without FOLL_FORCE therefore works for every
page tomoyo_dump_page() can be asked for.

FOLL_FORCE is being removed from callers that are not really ptrace so
that it can eventually be renamed to FOLL_PTRACE. Let's drop it here
too, which also brings the code back in line with its comment.

No functional change is intended.

Signed-off-by: Chris Down <chris@xxxxxxxxxxxxxx>
---
security/tomoyo/domain.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/security/tomoyo/domain.c b/security/tomoyo/domain.c
index eeaad421f15b..444e884722ee 100644
--- a/security/tomoyo/domain.c
+++ b/security/tomoyo/domain.c
@@ -925,8 +925,7 @@ bool tomoyo_dump_page(struct linux_binprm *bprm, unsigned long pos,
* (represented by bprm).
*/
mmap_read_lock(bprm->mm);
- ret = get_user_pages_remote(bprm->mm, pos, 1,
- FOLL_FORCE, &page, NULL);
+ ret = get_user_pages_remote(bprm->mm, pos, 1, 0, &page, NULL);
mmap_read_unlock(bprm->mm);
if (ret <= 0)
return false;

base-commit: 7cd8495c0f16275c4f9abe1cef09a7b5fcd6d046
--
2.56.1