From: xu.xin@linux.dev
To: ndokutovich@gmail.com
Cc: akpm@linux-foundation.org, david@kernel.org, liam@infradead.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-mm@kvack.org, mhocko@suse.com, rppt@kernel.org,
shuah@kernel.org, vbabka@kernel.org, Xu Xin <xu.xin@linux.dev>
Subject: Re: [PATCH v3 2/3] selftests/mm: skip the mkdirty ptrace write tests without FOLL_FORCE
Date: Tue, 1 Dec 2026 15:06:12 +0800 [thread overview]
Message-ID: <20261201070612.517724-1-xu.xin@linux.dev> (raw)
In-Reply-To: <20261130173950.41003-3-ndokutovich@gmail.com>
> mkdirty writes through /proc/self/mem into read-only PTEs and expects the
> kernel to force the write. Under the default CONFIG_PROC_MEM_FORCE_PTRACE
> policy that is only allowed when the writing task is tracing the target
> task, which is not the case here, so the setup write fails and the test
> reports a failure instead of skipping:
>
> not ok 1 write() failed
>
> Check the permission at the entry of the two ptrace write tests and skip
> them when it is denied. A kernel built with
> CONFIG_PROC_MEM_ALWAYS_FORCE or booted with proc_mem.force_override=always
> still runs them for real, so a genuine failure is still reported.
>
> Commit a3907a3169d0 ("selftests/mm: specify requirement for
> PROC_MEM_ALWAYS_FORCE=y") asks for CONFIG_PROC_MEM_ALWAYS_FORCE=y in
> mm/config, which applies once that fragment is merged into the kernel
> configuration; this skip additionally keeps an installed binary from
> failing on a kernel that was not built that way.
>
> The remaining subtests do not depend on the forced write and keep running.
>
> Signed-off-by: Nikolai Dokutovich <ndokutovich@gmail.com>
> ---
> tools/testing/selftests/mm/mkdirty.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
Reviewed-by: Xu Xin (vivo) <xu.xin@linux.dev>
>
> diff --git a/tools/testing/selftests/mm/mkdirty.c b/tools/testing/selftests/mm/mkdirty.c
> index 68dd447a5454..333d450d4ff3 100644
> --- a/tools/testing/selftests/mm/mkdirty.c
> +++ b/tools/testing/selftests/mm/mkdirty.c
> @@ -91,6 +91,11 @@ static void test_ptrace_write(void)
>
> ksft_print_msg("[INFO] PTRACE write access\n");
>
> + if (!proc_mem_force_write_allowed()) {
> + ksft_test_result_skip("FOLL_FORCE write probe returned EIO\n");
> + return;
> + }
> +
> mem = mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE|MAP_ANON, -1, 0);
> if (mem == MAP_FAILED) {
> ksft_test_result_fail("mmap() failed\n");
> @@ -128,6 +133,11 @@ static void test_ptrace_write_thp(void)
>
> ksft_print_msg("[INFO] PTRACE write access to THP\n");
>
> + if (!proc_mem_force_write_allowed()) {
> + ksft_test_result_skip("FOLL_FORCE write probe returned EIO\n");
> + return;
> + }
> +
> mem = mmap_thp_range(PROT_READ, &mmap_mem, &mmap_size);
> if (mem == MAP_FAILED)
> return;
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-12-01 7:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 17:39 [PATCH v3 0/3] selftests/mm: skip tests when FOLL_FORCE writes are denied Nikolai Dokutovich
2026-11-30 17:39 ` [PATCH v3 1/3] selftests/mm: add a probe for FOLL_FORCE writes through /proc/self/mem Nikolai Dokutovich
2026-12-01 7:04 ` xu.xin
2026-12-01 16:22 ` David Hildenbrand (Arm)
2026-11-30 17:39 ` [PATCH v3 2/3] selftests/mm: skip the mkdirty ptrace write tests without FOLL_FORCE Nikolai Dokutovich
2026-12-01 7:06 ` xu.xin [this message]
2026-12-01 16:23 ` David Hildenbrand (Arm)
2026-11-30 17:39 ` [PATCH v3 3/3] selftests/mm: skip the ksm PROT_NONE test " Nikolai Dokutovich
2026-12-01 7:07 ` xu.xin
2026-12-01 7:15 ` xu.xin
2026-12-01 16:23 ` David Hildenbrand (Arm)
2026-12-01 19:17 ` Nikolai Dokutovich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201070612.517724-1-xu.xin@linux.dev \
--to=xu.xin@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=ndokutovich@gmail.com \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
--cc=vbabka@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.