Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp1498181imp; Fri, 22 Feb 2019 04:56:07 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia7xqitXN/VcOtMnI3RhR9fJiAZelmaekV563n4ZziKsWw29LRrGaXGATap3tq/yaVEr7Qx X-Received: by 2002:a17:902:e3:: with SMTP id a90mr4129406pla.82.1550840167243; Fri, 22 Feb 2019 04:56:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550840167; cv=none; d=google.com; s=arc-20160816; b=t6fpB/T+UHxmCtvKyZqHifVweRqvu0bjk558uAU+qWEU7kvgyktcFgOmsUYbIjmPUv LPRFHUgxIiZGZGrDqFZN4zXoKY+kNA+LGTRzyHnXLF3pGdhAQt3MVrB4N+eH3yNUDs9D aPK/VrrMSS57CPvcy6AbOXreeJGCl3gDejgXUASMfSlNCzX7fb5R/CjHHg5pryrZVn3V JRKCp4qUeo6SsmCgsyHcXx0XHh2f2oAfKqhF+JLbSaFc3hdAiGVcilmydxZV3zyk9xKs iUpxKCBmBhh3gXS+Z/MGVAIubT14u+UODWeOtPVVwzSRJgqD3kxcJ+qmq7TQkoqosU1s E/CQ== 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=xP0EP9+s7jJBuNL20aZNoIWDJO0QH7KitwsXHnWrFcE=; b=HS7l5lXdYuudMMCAn1e6aocZ7QeNo9JFxf733bUlLsvdMOY2f5Gd8OpVsKwhKvHgSm knWVxixRzhnfLXdQyHfhbdkP1PfpiKVOCcqnglU5PqFiS0xRl1eLn8FgxxWXVjenSGOD sMPi+ZzARnApeh7gCG3Dzz3EF6IemPCdEUc0S3wqACMlZ7vfIInKuORuVTtGPlKyB2jH ZpnNtHE2rH3sIN2fqiuFzNpvniekObgtN3vKpmH+CsW1d+e4Lhou5Q24bDpuuJaBuuFw 7WW6+EnmEyk3u8laYJn6ws62Zwyky4dGLk3BKYjtk10UvwVhQFtL6Inhs8YkQwoJ8unI +2lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ngTaPZFj; 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 d16si1286845pll.236.2019.02.22.04.55.52; Fri, 22 Feb 2019 04:56:07 -0800 (PST) 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=ngTaPZFj; 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 S1727377AbfBVMx6 (ORCPT + 99 others); Fri, 22 Feb 2019 07:53:58 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:36771 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727349AbfBVMxz (ORCPT ); Fri, 22 Feb 2019 07:53:55 -0500 Received: by mail-wm1-f66.google.com with SMTP id j125so1876812wmj.1 for ; Fri, 22 Feb 2019 04:53:54 -0800 (PST) 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=xP0EP9+s7jJBuNL20aZNoIWDJO0QH7KitwsXHnWrFcE=; b=ngTaPZFjbMr8UVnv+XHv855CtRTNvKpoDmCRTtKsyfuCSVAX1fHkkeEopamnkFNUkO 2AxeqdOMs5OS1aAzAdqqAMH6oIYxxx7HXZvCiuu5mGrP4+JLSS3N1MvyfwgLIUpYg7XA 36WRCDQmvGeM5dFPaSlrAtGT6lqE+t1iYacqOuNf0WL0AvYMXookG0ZRXOCwQj/yAJ64 Ava6JpCXLFI/teW898eqAG2k52RXgpD4kz9ufk+Lk99Zo8v2WsRFs8gVa3BZjwmle1GK pfRIrNVVanNCc8AEbJlDtvFhw5/QlKpS67K/2EsIOQEy8hvKVuwcPksCJr25OCE/XBBn QqYg== 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=xP0EP9+s7jJBuNL20aZNoIWDJO0QH7KitwsXHnWrFcE=; b=VZdDYHF4eJdn/ZeGrRNmi1EC5nxSSZch8KwhCWrM6Av0XzqWQ42riNTsdsaj8Hy690 XRWqQ+G7woAn/1vlerYN5+ALo4lTabGLi3cBAcpnwoBEzLYloq8WSonJ4erjnmrBrTpr 6qU8jIedhP5M8RzuXMifqIklct0veN+lb+z49aouF3gENOg3xlt6f/nVqC5vfDd2ziJX paubDDDsrfUbN5XFobJeHTjY9b1kekMJJp3MX2p/qcmb2SwysTATsBVNJ0gUnPSt3moa A/ZEb55vm+Y1vNDogIPj+UAPCSA3vYbB8OftYmc/sJ5Ul+NutiZdALB4w/HNO5m4Kkm5 O4wg== X-Gm-Message-State: AHQUAua7lccorcbLjdCYfwZ8u3S3HrJqGVayGVaAkC2B/XY0cFQtGjez ebXL9LJTMLdtpSgQBlZ/Vxo0Qg== X-Received: by 2002:a7b:c457:: with SMTP id l23mr2410289wmi.2.1550840033285; Fri, 22 Feb 2019 04:53:53 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:13:8ce:d7fa:9f4c:492]) by smtp.gmail.com with ESMTPSA id o14sm808209wrp.34.2019.02.22.04.53.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Feb 2019 04:53:52 -0800 (PST) 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 , 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 , Dave Martin , Kevin Brodsky , Szabolcs Nagy , Andrey Konovalov Subject: [PATCH v10 12/12] selftests, arm64: add a selftest for passing tagged pointers to kernel Date: Fri, 22 Feb 2019 13:53:24 +0100 Message-Id: <8c08cda0dfdef1b062695241a6f6594487eaa3cb.1550839937.git.andreyknvl@google.com> X-Mailer: git-send-email 2.21.0.rc0.258.g878e2cd30e-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.21.0.rc0.258.g878e2cd30e-goog