On Tue, Sep 08, 2026 at 10:51:11AM +0800, Hongfu Li wrote: > From: Hongfu Li <[email protected]> > > try_ptrace() treats PTRACE_PEEKDATA return value as a boolean > check. A successful read returns non-zero data (memory filled with > 0x55), causing the test to incorrectly report PASS when secret memory > protection is broken. > > Check the return value against -1 instead. The test should only pass > when PTRACE_PEEKDATA fails, which means secret memory protection works. > > Fixes: 76fe17ef588a ("secretmem: test: add basic selftest for > memfd_secret(2)") > Signed-off-by: Hongfu Li <[email protected]>
Acked-by: Mike Rapoport (Microsoft) <[email protected]> > --- > tools/testing/selftests/mm/memfd_secret.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/mm/memfd_secret.c > b/tools/testing/selftests/mm/memfd_secret.c > index c55d84c5e613..dd08a3a1ef14 100644 > --- a/tools/testing/selftests/mm/memfd_secret.c > +++ b/tools/testing/selftests/mm/memfd_secret.c > @@ -145,7 +145,7 @@ static void try_ptrace(int fd, int pipefd[2]) > exit(KSFT_FAIL); > } > > - if (ptrace(PTRACE_PEEKDATA, ppid, mem, 0)) > + if (ptrace(PTRACE_PEEKDATA, ppid, mem, 0) == -1) > exit(KSFT_PASS); > > exit(KSFT_FAIL); > -- > 2.54.0 > > -- Sincerely yours, Mike.

