From patchwork Fri Mar 15 19:51:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 1057223 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="cM+Q7dAj"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44LbpG3cQTz9sDB for ; Sat, 16 Mar 2019 06:52:38 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727613AbfCOTwg (ORCPT ); Fri, 15 Mar 2019 15:52:36 -0400 Received: from mail-yw1-f74.google.com ([209.85.161.74]:39888 "EHLO mail-yw1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727584AbfCOTw3 (ORCPT ); Fri, 15 Mar 2019 15:52:29 -0400 Received: by mail-yw1-f74.google.com with SMTP id f67so13134619ywa.6 for ; Fri, 15 Mar 2019 12:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=eZ7BHJXyN3220x7rl2oUpgQUqTcJDNuGZqyhRO+ZCi8=; b=cM+Q7dAjoclAUX9rjqJjU67fQhDAumMVHtRttx9Zyi+ZIB2DGBobAtyISQHWCe9SMA PZHknNkYe0zmRuTP34LxQfpP1xwZBreBZ0NXH/qnk7oR3nj566n4N1rsgxomhNTEh0Ty SDOfq37fZf5Cao/sGRM/bhdUdzoFls7cguuH3/lWtp/1jJdgVLG8lRoWShZq4z4XO9vT iGHxQ7GSrXCjG8EjxrW3Y9yARtTuqQUdg+mDtAYxXQ4FY7FbCfCGcfBBG46s71wuDA8g bS9aqYheYMuj6UjyFgDP+dwDAvq3VA5uUamhfzLklNEwcMfGzHMrGe5/jZLh7MutPKEK 1ixA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=eZ7BHJXyN3220x7rl2oUpgQUqTcJDNuGZqyhRO+ZCi8=; b=EUxS9VxWasYPTCq3Z5zh1t/6EX3O9BVadonhKy8TmpZD/2uDt/ggNzp6hR/obwFt6G hoViKlUdBBcQmO0mclpwCbwPIdj6rM/rHOD6yjyrcDs6Hd85J+npZ879So9f7UBW7/3A NqD3PAedAoa5AWKVibax+bYrytSLhm0aM9AbChsSFXyy2zuP3zb91hpYwpfpZueUnohY l/q88FuoOK7DneRuumM4fiegmleHuH3sAWWm5dYTWk1zkrZ0txjLHy61vftlzzcOpJob ruUhMpN45iy31sLqAcvLliP1PIZ0HQkAoqa06g6UTGoRTjjVHDLZkjov4KbZonnv3Sd7 WfaA== X-Gm-Message-State: APjAAAWLpmQxclyFkeg8D1sZKX94qTZwbHMjRlEvem566FtpuOngqJVB xG/sRdOeLOWli2S8/Uiago/MqBDUyijEncfY X-Google-Smtp-Source: APXvYqz3F3hQJGqQ71GxABRK7OAGTM1YeC9p7knGv+mSIqj4Is7OoPrLZZdfGBYcCn7qYvsKmLT0kaCoS+EB48D+ X-Received: by 2002:a81:7acf:: with SMTP id v198mr2397024ywc.16.1552679548119; Fri, 15 Mar 2019 12:52:28 -0700 (PDT) Date: Fri, 15 Mar 2019 20:51:38 +0100 In-Reply-To: Message-Id: <8e7bfcb3812ae2a1f558864f56eec71a8f78fa2e.1552679409.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.21.0.360.g471c308f928-goog Subject: [PATCH v11 14/14] selftests, arm64: add a selftest for passing tagged pointers to kernel From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , Vincenzo Frascino , Eric Dumazet , "David S. Miller" , Alexei Starovoitov , Daniel Borkmann , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Arnaldo Carvalho de Melo , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya , Luc Van Oostenryck , Dave Martin , Kevin Brodsky , Szabolcs Nagy , Andrey Konovalov Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch is a part of a series that extends arm64 kernel ABI to allow to pass tagged user pointers (with the top byte set to something else other than 0x00) as syscall arguments. This patch adds a simple test, that calls the uname syscall with a tagged user pointer as an argument. Without the kernel accepting tagged user pointers the test fails with EFAULT. Signed-off-by: Andrey Konovalov --- tools/testing/selftests/arm64/.gitignore | 1 + tools/testing/selftests/arm64/Makefile | 11 ++++++++++ .../testing/selftests/arm64/run_tags_test.sh | 12 +++++++++++ tools/testing/selftests/arm64/tags_test.c | 21 +++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 tools/testing/selftests/arm64/.gitignore create mode 100644 tools/testing/selftests/arm64/Makefile create mode 100755 tools/testing/selftests/arm64/run_tags_test.sh create mode 100644 tools/testing/selftests/arm64/tags_test.c diff --git a/tools/testing/selftests/arm64/.gitignore b/tools/testing/selftests/arm64/.gitignore new file mode 100644 index 000000000000..e8fae8d61ed6 --- /dev/null +++ b/tools/testing/selftests/arm64/.gitignore @@ -0,0 +1 @@ +tags_test diff --git a/tools/testing/selftests/arm64/Makefile b/tools/testing/selftests/arm64/Makefile new file mode 100644 index 000000000000..a61b2e743e99 --- /dev/null +++ b/tools/testing/selftests/arm64/Makefile @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0 + +# ARCH can be overridden by the user for cross compiling +ARCH ?= $(shell uname -m 2>/dev/null || echo not) + +ifneq (,$(filter $(ARCH),aarch64 arm64)) +TEST_GEN_PROGS := tags_test +TEST_PROGS := run_tags_test.sh +endif + +include ../lib.mk diff --git a/tools/testing/selftests/arm64/run_tags_test.sh b/tools/testing/selftests/arm64/run_tags_test.sh new file mode 100755 index 000000000000..745f11379930 --- /dev/null +++ b/tools/testing/selftests/arm64/run_tags_test.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +echo "--------------------" +echo "running tags test" +echo "--------------------" +./tags_test +if [ $? -ne 0 ]; then + echo "[FAIL]" +else + echo "[PASS]" +fi diff --git a/tools/testing/selftests/arm64/tags_test.c b/tools/testing/selftests/arm64/tags_test.c new file mode 100644 index 000000000000..2bd1830a7ebe --- /dev/null +++ b/tools/testing/selftests/arm64/tags_test.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include +#include + +#define SHIFT_TAG(tag) ((uint64_t)(tag) << 56) +#define SET_TAG(ptr, tag) (((uint64_t)(ptr) & ~SHIFT_TAG(0xff)) | \ + SHIFT_TAG(tag)) + +int main(void) +{ + struct utsname *ptr = (struct utsname *)malloc(sizeof(*ptr)); + void *tagged_ptr = (void *)SET_TAG(ptr, 0x42); + int err = uname(tagged_ptr); + + free(ptr); + return err; +}