From patchwork Mon Aug 6 16:40:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10557423 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE04615A6 for ; Mon, 6 Aug 2018 16:41:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE02229945 for ; Mon, 6 Aug 2018 16:41:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0BCC2992E; Mon, 6 Aug 2018 16:41:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 356EE298DC for ; Mon, 6 Aug 2018 16:41:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387902AbeHFSvF (ORCPT ); Mon, 6 Aug 2018 14:51:05 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36281 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387812AbeHFSvD (ORCPT ); Mon, 6 Aug 2018 14:51:03 -0400 Received: by mail-wm0-f66.google.com with SMTP id w24-v6so14983690wmc.1 for ; Mon, 06 Aug 2018 09:41:09 -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=ZrhxEh1LXKnM2IrXVIXbI5DKlDD8oKDUSL0rMpxw/qU=; b=Ro3MVatE7Wpum1+4Kk+2wXZyHXWGz5DhEhdhzVDpd6n/5zWbox/Ku85U5aRyxxnzQJ 1J/xWvRyFAc03TrVnYRNw8OmHId2EwNePrTxpSWu1Ofv1SyERhzredl8WNaZAOK9NUox kdSLR0PzMNwDcdf8IDNrR/K6Rn2/Oq2YV3/c4uct4BnX14eyZ8BAMtfJTUrExgVGB4/D CVBWJPc3EidgI39apO4xklbv+Fl96U1MRR2IF/FLrVGIUHoTHo8+XdeER10wgCNAs+pz Ume8Ot7SFSHyWHNqaSQSC14cH5byqzRoQ0+VYrRQwYDbd2MRQJguQiz5Xk4ALJ4R63mL Zn3w== 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=ZrhxEh1LXKnM2IrXVIXbI5DKlDD8oKDUSL0rMpxw/qU=; b=fAjSFdilvkD2A29UwCkkNKm3E2qUot38LKeGDhATjI5M3vzLme9LJ/pAUqhoiULLYm 4AqwQm5BANH8j4fJ+JFw8nOpKNP+oZs2WPMqswDY+yqdLGIoiMbaZqExrwP/rJkK8A/r 2gyVbQPBftGaQVVys6P7teN49DQX0NK3qf09RtkrX+Y9Pq2qKi4sroFq01s8PjAAf4Za qeoGL0b5eA4rl/Kj5GJMH7huBL5igqjJolSqJeNtxobVh038JUNiSLWY4vudoNfOiwhq h0ZQOQERykygsNEMytzXQVx/GZT5g9TcCvnnuDGQv19khqvPR+Hbv7AsoIsFZ/LycMYt 2VVw== X-Gm-Message-State: AOUpUlE94QK/ZKXW0vLSPiAtySRrO7QSuPtl0ziH6swD3W1ImSabYCOC T4w9iuKpOwIQcA0v3FO4TI+2QQ== X-Google-Smtp-Source: AAOMgpcDi4MsvNpmW3WExVMPVjcfyNYV436aYUrVpmhZEgiIKgBhHcCGOm+96ozBcTKn96ws7pU/kw== X-Received: by 2002:a1c:8010:: with SMTP id b16-v6mr12985397wmd.9.1533573668058; Mon, 06 Aug 2018 09:41:08 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id 66-v6sm16385790wmw.34.2018.08.06.09.41.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 09:41:07 -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 v5 10/10] selftests, arm64: add a selftest for passing tagged pointers to kernel Date: Mon, 6 Aug 2018 18:40:45 +0200 Message-Id: <44c929e1128adfa5e84ed7db832d2b34edc55f19.1533573460.git.andreyknvl@google.com> X-Mailer: git-send-email 2.18.0.597.ga71716f1ad-goog In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; +}