From patchwork Thu Nov 8 14:36:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10674371 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 9FC2914E2 for ; Thu, 8 Nov 2018 14:36:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EB5726C9B for ; Thu, 8 Nov 2018 14:36:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8264A2A34F; Thu, 8 Nov 2018 14:36:36 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 0090F26C9B for ; Thu, 8 Nov 2018 14:36:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727362AbeKIAMV (ORCPT ); Thu, 8 Nov 2018 19:12:21 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:52712 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727316AbeKIAMU (ORCPT ); Thu, 8 Nov 2018 19:12:20 -0500 Received: by mail-wm1-f68.google.com with SMTP id r11-v6so1495565wmb.2 for ; Thu, 08 Nov 2018 06:36:33 -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=rTcNvHgzBcnv8yHP5cVBE2DYrsiz3ttqK4qPmsK+xBo=; b=mP7BwUREcnEcGSgnJc1TDgXr13K42B6BP4F15hPXDeIHuQX2uOp8Snkbsq/rDAlE8d GSxzbR40FboXXdUWHFzDhkyUPKNmYpTbYubEcgFD0CeD80LjOR+XkyuSoGS0VJJv/LH/ U6bwKzwuc24ye0v6iPDL7C1rJ5l8CkubR7mup/yvtsiMkdMISH/cH5hOvczkzzBlrJ0p 6t1bLiFLEwT4ih2n9wtnExO7TRHpeETynQbzZK9MPILt2vlGyetQLGs6FdHqDdSjfj09 3QppCswB2VwG1hTqjfpGg82D4sfV1zFc5WOav3Zmp21ggvvVuSxtI+UVd6rkaY7vKPH0 +Gog== 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=rTcNvHgzBcnv8yHP5cVBE2DYrsiz3ttqK4qPmsK+xBo=; b=LqdZQx2KlFQWIn6fHgj6A+aS0v1KhmBF4fjAX1svEcoabONT/7mlyiMoQBoMpmPDvV pOOoDrze/yJMBqm0OXuxJ+UGzELokTILrbPHrvOJLf49hGMG6kCikht2x/PpZkbfvjPe 5Qsewj/gDY1WReOSGygy7NFFL/6g15pSfy/188IWkotoxnygAHKiEmp/nG+UYAXpjtsS EfD5ut4h933LH2h9DC4Fi/XLVPr7z90oAmTWitOxKgrMZhTH6d0GOuEqWCUFO8rLKhhj 3Qs0f8yapDxe0GgENgnO0zgOoCw7FdpOZON/wkwh89Yf4nePdn2fU0t1qCsdGSd/Msax /CIg== X-Gm-Message-State: AGRZ1gIgpBUhSX/fKLzRj51iiUIfG0a7GkkNiVU69GoDOL44KF8sHcX1 GzvC3EXd32c+duZwELBbfCLXZA== X-Google-Smtp-Source: AJdET5etM7uj3EUTtVycpWGYsbTyj7fUXc6thqPRDiCt2FdD9fuqZ1p8f/aw/QlkU3PTYPTHJhfbWQ== X-Received: by 2002:a7b:c0cc:: with SMTP id s12-v6mr1514540wmh.39.1541687792444; Thu, 08 Nov 2018 06:36:32 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id k5-v6sm5421068wre.82.2018.11.08.06.36.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 06:36:31 -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 , 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 v8 8/8] selftests, arm64: add a selftest for passing tagged pointers to kernel Date: Thu, 8 Nov 2018 15:36:15 +0100 Message-Id: <08e86fb73c3f0aeb60888939e34b0c0fa69063b5.1541687720.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-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; +}