From patchwork Wed Sep 9 19:30:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 7148361 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0A9EA9F1D3 for ; Wed, 9 Sep 2015 19:33:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2336220881 for ; Wed, 9 Sep 2015 19:33:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2A18B2087C for ; Wed, 9 Sep 2015 19:33:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZZl5G-0007Pk-Ue; Wed, 09 Sep 2015 19:31:06 +0000 Received: from smtp.outflux.net ([2001:19d0:2:6:c0de:0:736d:7470]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZZl5E-0007Ds-B0 for linux-arm-kernel@lists.infradead.org; Wed, 09 Sep 2015 19:31:04 +0000 Received: from www.outflux.net (serenity.outflux.net [10.2.0.2]) by vinyl.outflux.net (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id t89JURcj032679; Wed, 9 Sep 2015 12:30:27 -0700 Date: Wed, 9 Sep 2015 12:30:27 -0700 From: Kees Cook To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] selftests/seccomp: build on aarch64, document ABI Message-ID: <20150909193025.GA29244@www.outflux.net> MIME-Version: 1.0 Content-Disposition: inline X-MIMEDefang-Filter: outflux$Revision: 1.316 $ X-HELO: www.outflux.net X-Scanned-By: MIMEDefang 2.73 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150909_123104_528321_3016ED90 X-CRM114-Status: GOOD ( 10.83 ) X-Spam-Score: -4.0 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Will Drewry , Arnd Bergmann , linux-api@vger.kernel.org, Shuah Khan , Andy Lutomirski , Bamvor Zhang Jian , linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The syscall ABI is inconsistent on aarch64 compat, so at least we should document it in the seccomp_bpf tests. Signed-off-by: Kees Cook --- Can someone with access to native aarch64 double-check this for me? I think we need to change these tests to pass if it's expected, but the compat behavior seems bad. It means compat code will break under an aarch64 kernel, when dealing with syscalls, like through seccomp. --- tools/testing/selftests/seccomp/seccomp_bpf.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index 770f47adf295..866ff42e000d 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -33,6 +33,10 @@ #include #include +#if defined(__aarch64__) && !defined(__NR_poll) +# define __NR_poll 0x49 +#endif + #include "test_harness.h" #ifndef PR_SET_PTRACER @@ -2124,10 +2128,17 @@ TEST(syscall_restart) ASSERT_EQ(SIGTRAP, WSTOPSIG(status)); ASSERT_EQ(PTRACE_EVENT_SECCOMP, (status >> 16)); ASSERT_EQ(0, ptrace(PTRACE_GETEVENTMSG, child_pid, NULL, &msg)); - ASSERT_EQ(0x200, msg); + + /* + * FIXME: + * - native ARM does not expose true syscall. + * - compat ARM on ARM64 does expose true syscall. + * - native ARM64 hides true syscall even from seccomp. + */ + ASSERT_EQ(0x200, msg); /* This will fail on native arm64. */ ret = get_syscall(_metadata, child_pid); #if defined(__arm__) - /* FIXME: ARM does not expose true syscall in registers. */ + /* This will fail on arm64 in compat mode. */ EXPECT_EQ(__NR_poll, ret); #else EXPECT_EQ(__NR_restart_syscall, ret);