Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp904608imm; Wed, 20 Jun 2018 08:25:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLf8Ice5Wp0E0nhs7z1XyQ3N7j9SPwefca+dNQ+U4TSmW21T+seBh5yUp51FugIIAmtdOmV X-Received: by 2002:a63:7a48:: with SMTP id j8-v6mr19071716pgn.415.1529508346700; Wed, 20 Jun 2018 08:25:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529508346; cv=none; d=google.com; s=arc-20160816; b=0ejB+XoM0oe52HEyFaGkNQKNMgFXcPLelTJ2wu82PNOTHLmQ7N3xCppavbThwB1Ig/ loOSRCAOsZXn3v3VnzJoYGKwlzmJ3BHpJ7hzHbCKcXae1mmEpiNK4WICrpyb0iIj+jJF MwoZE+DcW7zH2Trv7b0V5QJ7tKg9Mhc5eJ7dROzTL5FCVcinY+1zchXUc6C5rfMG9hVT 1h+6aaM/hrH4yn6yI9UFWTTJiduszPryYXr1Ai9y9MK0XrjCWfKzKiQZx2tEt7p8M77B 0VVWnbysiCGa532T3O+j6or6/KC3nHEoA3k7JLQ6tHYKsSQ3xPSxX12dSyf3YXFe+hEB zM+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=lPw14ir5b4WYyY1IhNATkeAXJBB+IrqZlAw0DjD5TTM=; b=Rq1UELZZRD8w9v33qeoUfRsxsll5Y/8RiJAuLgRBuVf3Kq6QxbSQW+pctb/Xa8OGQF Ys9KNkNwivtmdhYQTSZ9yuRcTSA9lahCwYu8mtij+1zw8KT7gSstxbjSwMQ2GzmcdTAR HvirscYQuqefAotdEPdeZ3wJfhoPhiRw1L2YE5FpK2fmHqTsx0L7+UqfCSzrYIJz2RV+ yToWeHD+d4w8mn01RTlCll7XuHRWBEp5f5qQBnyJ0a97tFj4mFJki47H0GbHcEaXljjg PNtOTzhKpsIwLVwA6kmIbrtBmPN1FHON4UWwOHq6HlYFCkFGJttvd6udk0cKEuzKujz7 VlaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=J3yTQZ1f; 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 n23-v6si2129110pgc.366.2018.06.20.08.25.31; Wed, 20 Jun 2018 08:25:46 -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=J3yTQZ1f; 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 S932475AbeFTPYu (ORCPT + 99 others); Wed, 20 Jun 2018 11:24:50 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:39199 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932425AbeFTPYm (ORCPT ); Wed, 20 Jun 2018 11:24:42 -0400 Received: by mail-wm0-f67.google.com with SMTP id p11-v6so204066wmc.4 for ; Wed, 20 Jun 2018 08:24:41 -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; bh=lPw14ir5b4WYyY1IhNATkeAXJBB+IrqZlAw0DjD5TTM=; b=J3yTQZ1f7n+TJHf/9o+PbNCwiTIqOpqcpuAZAjAp4VpJr8b+6IVZWEChhyNuHzW5CN x4oTUXoG5gTru7+EZlpV0+yD73A92yWwf5YfPQlHQ9zLiJBc7LkRrzmsPwt3uYEf2/oM LVz3auXNJFbsfhnHnD2X82eqtqNWbBwp7AnDAnaCaJ6UmhDUhGQOMMkyHutfpiMe9lW/ SgUJY7JoHljiZD4AiI0oiW2yOirlZlqQ+BAXvs2qMnbx9TOq5w9vrg/smy9Hjul2PGzM VJByaKeRy33kp2BTwa/XsKcjG8HODhxRMyjGREC+8atPHrPzl1ne28mb7DDD8HLxdk4Q MXSQ== 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; bh=lPw14ir5b4WYyY1IhNATkeAXJBB+IrqZlAw0DjD5TTM=; b=HJVGayG/xfEb4zYNHjoNTfiNwI7CMCOIFQNF0JUifJ5RepPsT3/6gvyMyyMfzTJHE5 2ggzPeG/fb22xyc4N0EBfd8DEbsVVTtuuDUUGa8519QOT9W1sKJ+28Ct2K2JEKFSNYLb 23ulpQgtpa5AgTEUEsgBV3hdxnuzZ3wB8aJh0330tJ9gIrSWgYRPHWgDrRFwP4hcqy/T 5bkjJu+h2nuoAKYsNsMzySZVppXbR9IFzKyw6etvhofh3Qe1F+2wQA6NV6VRQzxxGYjq 2YKyYY3O5sU481HJRSANroCu3MhjiFJlbO7noWzOT2KuaKfzuAtiihvup7pEDO5jgzHg XXLw== X-Gm-Message-State: APt69E1K/og86/BbLzHHRi4r44hb1n5Sn3Tr59d+QFyEcYdZAt1HsnWb wqhg2Qi/TP/+IjgXkHn6QJcCUA== X-Received: by 2002:a1c:7212:: with SMTP id n18-v6mr2173331wmc.5.1529508280581; Wed, 20 Jun 2018 08:24:40 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id c11-v6sm3959244wrm.65.2018.06.20.08.24.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 08:24:39 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Andrey Konovalov , 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 Subject: [PATCH v4 7/7] selftests, arm64: add a selftest for passing tagged pointers to kernel Date: Wed, 20 Jun 2018 17:24:26 +0200 Message-Id: <22a2fd7189189d0b67ea82e44f28a69627a6199e.1529507994.git.andreyknvl@google.com> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: References: 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.18.0.rc1.244.gcf134e6275-goog