* [PATCH] tomoyo: Drop FOLL_FORCE from tomoyo_dump_page()
@ 2026-11-28 18:04 Chris Down
2026-11-28 18:06 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Chris Down @ 2026-11-28 18:04 UTC (permalink / raw)
To: Kentaro Takeda, Tetsuo Handa
Cc: Paul Moore, James Morris, Serge E. Hallyn, linux-security-module,
tomoyo-users_en, tomoyo-users_ja, linux-kernel
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@chrisdown.name>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tomoyo: Drop FOLL_FORCE from tomoyo_dump_page()
2026-11-28 18:04 [PATCH] tomoyo: Drop FOLL_FORCE from tomoyo_dump_page() Chris Down
@ 2026-11-28 18:06 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-28 18:06 UTC (permalink / raw)
Cc: linux-security-module
> 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@chrisdown.name>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/3c1a731469fb589685dd2168f7c8def736d806cf.1795863061.git.chris@chrisdown.name?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-28 18:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 18:04 [PATCH] tomoyo: Drop FOLL_FORCE from tomoyo_dump_page() Chris Down
2026-11-28 18:06 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox