Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: limin <limin100@huawei.com>
To: <shuah@kernel.org>, <mic@digikod.net>,
	<linux-kselftest@vger.kernel.org>,
	<linux-security-module@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Cc: <hannes@cmpxchg.org>, <mhocko@kernel.org>,
	<roman.gushchin@linux.dev>, <shakeelb@google.com>,
	<songmuchun@bytedance.com>, <tj@kernel.org>,
	<lizefan.x@bytedance.com>
Subject: [PATCH -next] selftests/landlock: Fix selftest ptrace_test run fail
Date: Mon, 28 Nov 2022 10:04:09 +0800	[thread overview]
Message-ID: <20221128020409.1545717-1-limin100@huawei.com> (raw)

Tests PTRACE_ATTACH and PTRACE_MODE_READ on the parent,
trace parent return -1 when child== 0
How to reproduce warning:
$ make -C tools/testing/selftests TARGETS=landlock run_tests

Signed-off-by: limin <limin100@huawei.com>
---
 tools/testing/selftests/landlock/ptrace_test.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/landlock/ptrace_test.c b/tools/testing/selftests/landlock/ptrace_test.c
index c28ef98ff3ac..88c4dc63eea0 100644
--- a/tools/testing/selftests/landlock/ptrace_test.c
+++ b/tools/testing/selftests/landlock/ptrace_test.c
@@ -267,12 +267,11 @@ TEST_F(hierarchy, trace)
 		/* Tests PTRACE_ATTACH and PTRACE_MODE_READ on the parent. */
 		err_proc_read = test_ptrace_read(parent);
 		ret = ptrace(PTRACE_ATTACH, parent, NULL, 0);
+		EXPECT_EQ(-1, ret);
+		EXPECT_EQ(EPERM, errno);
 		if (variant->domain_child) {
-			EXPECT_EQ(-1, ret);
-			EXPECT_EQ(EPERM, errno);
 			EXPECT_EQ(EACCES, err_proc_read);
 		} else {
-			EXPECT_EQ(0, ret);
 			EXPECT_EQ(0, err_proc_read);
 		}
 		if (ret == 0) {
-- 
2.33.0


             reply	other threads:[~2022-11-28  2:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28  2:04 limin [this message]
2022-11-28 19:44 ` [PATCH -next] selftests/landlock: Fix selftest ptrace_test run fail Mickaël Salaün
2022-11-29  1:42   ` limin
2022-11-29 11:03     ` Mickaël Salaün
2022-11-29 12:00       ` limin
2022-11-30  3:40       ` limin
     [not found]       ` <2bc18685-f975-497f-9c20-da99dbc296c0@huawei.com>
2022-11-30 19:32         ` Mickaël Salaün
2022-11-30 19:47           ` Jeff Xu
2023-07-31 14:37           ` Mickaël Salaün

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=20221128020409.1545717-1-limin100@huawei.com \
    --to=limin100@huawei.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=lizefan.x@bytedance.com \
    --cc=mhocko@kernel.org \
    --cc=mic@digikod.net \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeelb@google.com \
    --cc=shuah@kernel.org \
    --cc=songmuchun@bytedance.com \
    --cc=tj@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox