Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp511153imm; Thu, 30 Aug 2018 04:43:25 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbzCyfxQjuuA+i4oekFudUYM79RVjDlzPMOlGs2WGqANe9fuz+zrljgEWO3tmmxxEqrYBG4 X-Received: by 2002:a63:d70e:: with SMTP id d14-v6mr9549964pgg.110.1535629405111; Thu, 30 Aug 2018 04:43:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535629405; cv=none; d=google.com; s=arc-20160816; b=p+U5WYXTFqcYkKQdSPJtvaiYwAStrUpqfoBoCf0qe5fPaXLuf5mxAr4OlDD7EXo5VB bwLXqVyhEhezXgM3zAgikbsnQPgZSUzLHcrsV7ed+pwS1nGdvqNH54hamqU670FXJOgO fLNZS45LLMkPQzYEtc74MVyqKq/V9X+UEahBHHHx083Mfb+pTOruhGXLVN+3d4YbPBof SH553q1RjZJTkFSlUaweYlMpxQ4g9nhnqHivrNh99ytw9TFlJyAx1QCip43+U6DmSL6g 2h9VMn+YMrxOtuN6Gtf53hWuyphC1A1TAKTqczE9kwgP3BqxkhswZh7QBDoNiUVqYhkm rrPg== 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:arc-authentication-results; bh=7j7XmdTnSVmbmp015wk6qie+oiQQcCjLk4bzMit5h2s=; b=v3hrod7XOPfIk3RvD4KHtjGdgmfzaCQ4cky/fzsnnRiVaoNdbLf8HRkbOF961+B7vO hX/eOJ+BUGkzU2WwL7IqScjJXuAdUo45QQCfCHcsAiat2Vy2b5T75gleqKuwYHyNG1/j V89M9BAL6jpqID/kviUTeIuEjpu5KA6xDvNa8g0E9dttkFpz5IBYcNaDJpQckD7cRQ9b sZ/qvF5vZE01+20tmElU0jrcrIF3sNKHBTyKAEW3pY4pyilOtkfEUzL1tW758c6ZG3yb 0GU4EYOi5hkAloXV2K4M0vQxIbe0naxPI0YpnPLMopfSEDtIyoXvA77TJJvfXMSQQtLX Ep7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BVW0OkFl; 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 28-v6si6336426pgn.498.2018.08.30.04.43.10; Thu, 30 Aug 2018 04:43: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=BVW0OkFl; 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 S1728698AbeH3PnU (ORCPT + 99 others); Thu, 30 Aug 2018 11:43:20 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:37768 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728667AbeH3PnT (ORCPT ); Thu, 30 Aug 2018 11:43:19 -0400 Received: by mail-wr1-f67.google.com with SMTP id u12-v6so7743315wrr.4 for ; Thu, 30 Aug 2018 04:41:36 -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=7j7XmdTnSVmbmp015wk6qie+oiQQcCjLk4bzMit5h2s=; b=BVW0OkFljrINNZdwpZG1fLFvC/nUNg+PNl5V7e4irtxMf/8ds5fOmDiRg0jiFxSrpC AoYJuALMe+AwwNcfL+XFZr5OzegbBxhqq4zyR3efYXh1fkP+iudAXgQaGXgjA0W+3l/D WukQPVBIbghbxssWNq1MCLUOyqolxuuPzS34fFrWgLDrwmu1SE0O2z3sdJMrXC1j3irA q1hnmunuGfmDepy467DjEY/c1lMVlc9uRJcbBb/wHYMZetaFrAnnEbaGp+N/IU4nvYzN ELf+B+wUUsGUHENjxGoO9fJ1uoV7CDg40dpQ2QR74jOyv51pz1LyZw4GDWYM8APpnIYu zuMA== 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=7j7XmdTnSVmbmp015wk6qie+oiQQcCjLk4bzMit5h2s=; b=O6J5AniwCkSpZ4/SsRKUQ7dMtOebacyusGVGrU5gS2Ver8AMCSALVtXNZ5UVpITDVO kYxvVCbGt23o6tD2Q01TpjsmvFVJSaKtRxrxcJ3sMGvT3QM9cvllKNMIhdC8/gBx30Q8 hJKL84JxL21r1BgAG25b30byviOU0C43NIYTMLFr3C9mDyEv80DzoirjiZNtNDN0pXmU BPUH0iHYUiKwNDIaReV17DjN8isVuahoL5VjSsXvsIda5zL61tOL/KthMjBon76j+CCi cEYYTmvnsmDHGo7vqvOoj/ZOw6X4y1SltnwXxSG51yuyr1HTati36gvIRMLcbfae4sM7 pG7A== X-Gm-Message-State: APzg51DHwdj/wg/6/WlhrUFwRqSYOnxLrdV09tMdYV5wCsaJ9uI/1dqP 5E1IZBxbg5yprku/1JFAcEMphw== X-Received: by 2002:adf:ad8e:: with SMTP id w14-v6mr7818521wrc.178.1535629295169; Thu, 30 Aug 2018 04:41:35 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id z184-v6sm2175218wmz.0.2018.08.30.04.41.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 04:41:34 -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 v6 10/11] selftests, arm64: add a selftest for passing tagged pointers to kernel Date: Thu, 30 Aug 2018 13:41:15 +0200 Message-Id: <087a7b141ae275a2ea2b53c9df96a1fbce9dc79a.1535629099.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-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.rc0.228.g281dcd1b4d0-goog