Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp617153img; Mon, 18 Mar 2019 10:20:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxJKtlZ9zO7yqBH0CodCrMM4RoWaH/98uUDB3fDco0Aa1Rs+26mbwiUTLfUOqyBETchIGj X-Received: by 2002:a63:7403:: with SMTP id p3mr18439151pgc.343.1552929621051; Mon, 18 Mar 2019 10:20:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552929621; cv=none; d=google.com; s=arc-20160816; b=yQlDYbUO0PFh859kQldANwYjY6V0EWYJNMZlzK5bFWmgQZlk/YHL0LwMWTF4slOXpQ O3/B967+BHN4DfXd+o33b5YhYJln1Syolqj8MoKSk6mrzwka4vuW5fWgUpvJOkoxdbd8 EiVP8rYNNJ4QK/4nf5fHbycO0cTM7kuqCr2Vf7bwE798iMU41IM3VbVVgPBIO/Aigmj7 SCJkSsy4fgHYtycyCBVYPUtmN2cKhSr1Dx6eaijBwjw/V/XqA0ZjCEyvKVlndoD6n2xe VzX1pyayxeBzkS2x2fONSKkpHc0bJrocfFuc1V5XgzAGCVm9gJF5pr2e410tLL3lsgTV M/9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=SY+rnApq6/oVhWiUcTCOnBf6TcIl5V0rPtZOMhbp5Gs=; b=diC/X4Ug+eJd0dw4CRbanBmJMjQ4AuuS16CGUQaUO05+E2NbH9ESMOANZ2JG6LaivX aplJKKUOBllOK71sXlMuobtM161pzoIhjw6xG41gjotLEpW8+yjBRAnqHw02IhfBhvQF pI85hzElrgJf2Au5aqklb4hP+m1j36Ff8E1mNAWhLz9FaQNwkJPiJ063ohle/SK2SVfM PnWVUBkuhiPzSN3o+ulKu814cQdg4YCZ145Zfpk6fNGPRFrpKsOSZQN9NphgfjPB1Mwf vfZf2Q7DJ5W63cCUmu4b7dM08vq9buHIJmmLB8Gjf/JMwNcrvmdgSRG4O1KRouIDGclW DMDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=oy4XANA3; 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 p9si9565010pls.151.2019.03.18.10.20.05; Mon, 18 Mar 2019 10:20:21 -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=oy4XANA3; 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 S1728082AbfCRRSd (ORCPT + 99 others); Mon, 18 Mar 2019 13:18:33 -0400 Received: from mail-yw1-f74.google.com ([209.85.161.74]:38519 "EHLO mail-yw1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728059AbfCRRSa (ORCPT ); Mon, 18 Mar 2019 13:18:30 -0400 Received: by mail-yw1-f74.google.com with SMTP id i203so8401079ywa.5 for ; Mon, 18 Mar 2019 10:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=SY+rnApq6/oVhWiUcTCOnBf6TcIl5V0rPtZOMhbp5Gs=; b=oy4XANA3tbe0/ZzrN3csQScarn1wlppfqaNsYi+hu9yuogoof3toGpiFXztOXvuSIL sBMFi0kVcDXhngeXsQ7F8TmpGE5J+YQspuv0IpgE54s+w7Cg2pGhzbc2pvAhwbRlgRSf xxwSPdpD5FpRcK2p/HjiDpbPI1EyCU7DiI66uatDv7wNJCkN8c1ymIFnrzCAUJy1zI9w EBzcRuRAINzPha2QHRdT3Y/yumtuj6+oKyiMBKvPeEcFGxcVQSEWK2xmW+D8MpHwLMzD P1fusntFSsCEjlr/dNu9pSGP243BnVEPFZOFUAmm90Toh6sJXriJra44fSRj/3Svjc/P //6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=SY+rnApq6/oVhWiUcTCOnBf6TcIl5V0rPtZOMhbp5Gs=; b=ctdX8EAWwGrQ6ONP8I3ghokOz9KNgZ8qg4ScHOSXtGPdZbQ/+jD7+WXIYTaVqR4sHs H8j2qMZ5lD2/rNwtNLwIliKEKGr9E5pjE6knxN0nvglW2hWNv/xGIqLdePibZf6TEpOQ l+vBUzvUuhTvwwsrdsPg4GvZR+64xG3NJVT807QgqfCTdCQQd5ELwH8BwzULhefwy5+J qapbNTKG8Hl4mOed6mCg5/DY7jpUXCkpNysx0ZAnHkHZc1sAhnPF31eQ2sNcBE2NRqvs 3pCnqz6KgLOtif6fDeZ6YBUscQMH5iyO2b4RZeoRntQSA/f6h/Fdxw5Ihp4r1HYod+8F cxcQ== X-Gm-Message-State: APjAAAV/CpmwdnLHdQFX0eHmGjAI/0O5NvKgs1XgUhhW0VdhuzLZSp4H c+CC01tjlDm9s05FsSP5bTSqueCvzaAjjtGS X-Received: by 2002:a81:6184:: with SMTP id v126mr9643066ywb.17.1552929509203; Mon, 18 Mar 2019 10:18:29 -0700 (PDT) Date: Mon, 18 Mar 2019 18:17:45 +0100 In-Reply-To: Message-Id: <0b4d5fb8364a30a51868b6691fff503878d3d82b.1552929301.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.21.0.225.g810b269d1ac-goog Subject: [PATCH v12 13/13] selftests, arm64: add a selftest for passing tagged pointers to kernel 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 , Eric Dumazet , "David S. Miller" , Alexei Starovoitov , Daniel Borkmann , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Arnaldo Carvalho de Melo , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org, bpf@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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch is a part of a series that extends arm64 kernel ABI to allow to pass tagged user pointers (with the top byte set to something else other than 0x00) as syscall arguments. 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 | 21 +++++++++++++++++++ 4 files changed, 45 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..2bd1830a7ebe --- /dev/null +++ b/tools/testing/selftests/arm64/tags_test.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#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 *ptr = (struct utsname *)malloc(sizeof(*ptr)); + void *tagged_ptr = (void *)SET_TAG(ptr, 0x42); + int err = uname(tagged_ptr); + + free(ptr); + return err; +} -- 2.21.0.225.g810b269d1ac-goog