From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BA1BC43613 for ; Mon, 24 Jun 2019 15:02:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A393205C9 for ; Mon, 24 Jun 2019 15:02:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ChnBbYYc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727866AbfFXPCY (ORCPT ); Mon, 24 Jun 2019 11:02:24 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:37558 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726984AbfFXPCW (ORCPT ); Mon, 24 Jun 2019 11:02:22 -0400 Received: by mail-pl1-f193.google.com with SMTP id bh12so7033895plb.4 for ; Mon, 24 Jun 2019 08:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GtAdqPjW6ZZZnXrgGtz9dHnmmTnu4keB507Xrm18218=; b=ChnBbYYcZq0gQP/sJ3UOuMWBE4sFOJb179x3KxiYoIf9mz01hnbxknC2HoJWZ+GnKo I/gVcZavG+bqjHfCSPjI903PM2pF2P+rKnbbNQBP7YiqUkuVedhF+Zt+0nrsisSgO62h w1puy7E9AYi+Gooou5JDhG3yaU4cjhKpyOEpU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GtAdqPjW6ZZZnXrgGtz9dHnmmTnu4keB507Xrm18218=; b=jvOL1wblljGWdG8Ps+2hE5FSRCMJj8Quuy5lzRlNzyuyRTJTxbVYfcX2L5qDQaaYQB m/WcuMArjE58k5MUl+sta+AbU9wRpuVi5K1Qqi/lPVVWI148Mw7nNfT2YZy6/clruDw5 t0UOsRtGjgXRLdktU/SNvn6qB1R0vngtCHXLbH0KDvFrysmyMJywWJU9Vm5XK9uMSNaP /NP3tt38IYo6P62viscLGU1oFKAyR6p9s9Nde2tYvgaTMBfGktVhY+sx97BelagsSq38 zC+POjC2K2ILkpmT9SYnoYgmo7z9Dkh15HLh1SgWOzWSsLjrQrRRoQNEHj0/xnKmoVH7 i4Bg== X-Gm-Message-State: APjAAAWgeT54OhOYicsBIBQzKT75oN57uLr8sBq6eyaskJggiicQakvT cJPYvLQIvNoCWCRV1/xVtzO1lA== X-Google-Smtp-Source: APXvYqw9zabTal+i8jDaBfZR0QmoB7d+QTrClEOLwXBQMsgoLsFLEgEQhYNwi/8CLPRMNc9iVSjF6A== X-Received: by 2002:a17:902:7687:: with SMTP id m7mr67127539pll.310.1561388541281; Mon, 24 Jun 2019 08:02:21 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id e189sm5063967pfh.50.2019.06.24.08.02.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2019 08:02:20 -0700 (PDT) Date: Mon, 24 Jun 2019 08:02:19 -0700 From: Kees Cook To: Andrey Konovalov Cc: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-media@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, Catalin Marinas , Vincenzo Frascino , Will Deacon , Mark Rutland , Andrew Morton , Greg Kroah-Hartman , Yishai Hadas , Felix Kuehling , Alexander Deucher , Christian Koenig , Mauro Carvalho Chehab , Jens Wiklander , Alex Williamson , Leon Romanovsky , Luc Van Oostenryck , Dave Martin , Khalid Aziz , enh , Jason Gunthorpe , Christoph Hellwig , Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Robin Murphy , Kevin Brodsky , Szabolcs Nagy Subject: Re: [PATCH v18 15/15] selftests, arm64: add a selftest for passing tagged pointers to kernel Message-ID: <201906240802.29EB80F@keescook> References: <0999c80cd639b78ae27c0674069d552833227564.1561386715.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0999c80cd639b78ae27c0674069d552833227564.1561386715.git.andreyknvl@google.com> Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org On Mon, Jun 24, 2019 at 04:33:00PM +0200, Andrey Konovalov wrote: > This patch is a part of a series that extends 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 Acked-by: Kees Cook -Kees > --- > 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 | 29 +++++++++++++++++++ > 4 files changed, 53 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..22a1b266e373 > --- /dev/null > +++ b/tools/testing/selftests/arm64/tags_test.c > @@ -0,0 +1,29 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +#include > +#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) > +{ > + static int tbi_enabled = 0; > + struct utsname *ptr, *tagged_ptr; > + int err; > + > + if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0) == 0) > + tbi_enabled = 1; > + ptr = (struct utsname *)malloc(sizeof(*ptr)); > + if (tbi_enabled) > + tagged_ptr = (struct utsname *)SET_TAG(ptr, 0x42); > + err = uname(tagged_ptr); > + free(ptr); > + > + return err; > +} > -- > 2.22.0.410.gd8fdbe21b5-goog > -- Kees Cook