Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1301991imm; Tue, 2 Oct 2018 06:13:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV61aC5mr3WXPuhTY7X97jwKt22PR6QZiJx8VR4s1Uqg04ABsA/bqlayEWmzm3x/HeXjjqnBB X-Received: by 2002:a62:7788:: with SMTP id s130-v6mr16408049pfc.189.1538486005460; Tue, 02 Oct 2018 06:13:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538486005; cv=none; d=google.com; s=arc-20160816; b=D9ylLNKuT9qFWhT9N2NrLBKny6Y+Kb+w/iMXdHz5D9WOBo7QmHf7BQlVHxRXMQSKDJ oiMqnpYIhklAp1sccO8UYAEpjD7ySUzMxW4X153cEakH/zMNfC5EIgdWi0If1H4haTrS DHGXlWXpE4FgJ4o2tstfAz005UKwZWmX/CITeo4aJ5k/hMjK6dDY4tIkX2ccysVLHORn Ya8ojIIU3DuXgFnB1tmenyc6MqMT94UwsJeUVGyroXK1nsMFnHYroHEcCZTcdqjgNPGP yrXW29gl3Z2Z1nrfS8A3MilWSK4izDAGizPxpT6HK7fW1P7I0Ey9qoA7e0cSizeHSjqh vXfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jKYsVlgDfkccan6ieeKzVaMnn6OiwgAPoKEMH6GgvtQ=; b=ubKWdAQhk2RCorN2hX1bi9sbI3bYGt4TSdr9P9LaskiZnOXs4uxH7WcNbP0r9siKMs Y9VVDS6REfye7vZqW+A9EA0pHRDDOWiPU+4YrLxnPusjSWe80NVObrX9YBbxi8WN9WjE uLtSFnJvFtCHW04rxXgVjFG+4oBFWszeIYx3WaOOD41g7Iuxfse29tTaJ03E24lpqlGb MnpenUbxHg3ERiMhMzy4rgYqbQuglMFSonl2ujiKNYi4JlkAeu1XUM/o0h9753UzCmc1 lA+vwFVnPVDDIv3phekFvv9Qi3770J1EPb9i604/IJr/jRYm2BW1lYd1W77Xp/6xCBYK 05qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dCBVcCGf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k25-v6si6502370pgl.239.2018.10.02.06.13.09; Tue, 02 Oct 2018 06:13:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dCBVcCGf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728177AbeJBT4S (ORCPT + 99 others); Tue, 2 Oct 2018 15:56:18 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35786 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727829AbeJBT4R (ORCPT ); Tue, 2 Oct 2018 15:56:17 -0400 Received: by mail-wm1-f66.google.com with SMTP id o18-v6so2164268wmc.0 for ; Tue, 02 Oct 2018 06:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jKYsVlgDfkccan6ieeKzVaMnn6OiwgAPoKEMH6GgvtQ=; b=dCBVcCGfEkOp2yZaISW/VbCXrMw/roS3ig2VtB55vdMEYEdcc/N0JZvN/VK0XUG/vE q8IQc15Veee7CyQPFcN4SsbYldChP/FYEqamRzfm+EMDwScW4NnC7+nL/WVcXY4YkxXH IaLDvKPYeiZLSd6eTTyOwGRK7yY7FV+zz24fER4CRRtpt6fdP7FHKNa+sGQGNFp4xqiT 2ikGu6YSkQfB33XL8xLyxL9AM7V5tbcy1QM6XaN4QBbjg/hZJkmhb7/WqbYk+Q0i72PC 1E3XO0yS2UZtrhy8q6K5bwYxsqbd2crZpd+uOHwvRVP1OGBqcxh74WmYSqKcp9Zs8/Nq KaDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jKYsVlgDfkccan6ieeKzVaMnn6OiwgAPoKEMH6GgvtQ=; b=ZMqziKXe7DcTcsnHLRrWhp9GIdZd463fcSsreigtCvL4mzY2Tq/KZqd3+wIkBjKMA+ qH+CHtQhXXYJFCnGgleoln0eKA/9j/NWj8Nmuh8R5MAlldaokh5gvhHP6d8/J8z/qYBo CTuM6M0MpaHHqlNQJwvpJGstVq5/5IxdbzIoLr9ehznL1rH7/kTiHvCfvR+IrA7UCRRP jCcDKg5UQHDbzb/bE+Xhqjy/tbSKYgCLoyiPq0Awmb0riiJwP1+fJPhLf9Zybq2I3tvf CTX6s9nmiMF8K0LF40weKp8VQOxWRXDILX0n1NjriPtPiV3hnYw0kQnTchLrSvmqyI1Q ZDkw== X-Gm-Message-State: ABuFfohbEuAVDY8kdX4KBG57C83YE1v1ySQULKSYdBHGMv5n5hQEbL19 dvw51urmIbR85jl1JzRm5N3U/w== X-Received: by 2002:a1c:8bcc:: with SMTP id n195-v6mr1947045wmd.118.1538485977684; Tue, 02 Oct 2018 06:12:57 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id v10-v6sm17458681wrp.0.2018.10.02.06.12.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 06:12:56 -0700 (PDT) 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 , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@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 , Andrey Konovalov Subject: [PATCH v7 8/8] selftests, arm64: add a selftest for passing tagged pointers to kernel Date: Tue, 2 Oct 2018 15:12:43 +0200 Message-Id: <3a2c0a6b2499a328cc9471d4095ae36f0f05252d.1538485901.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 19 +++++++++++++++++++ 4 files changed, 43 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..1452ed7d33f9 --- /dev/null +++ b/tools/testing/selftests/arm64/tags_test.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 + +#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 utsname; + void *ptr = &utsname; + void *tagged_ptr = (void *)SET_TAG(ptr, 0x42); + int err = uname(tagged_ptr); + return err; +} -- 2.19.0.605.g01d371f741-goog