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=-1.0 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 D3F4EC282CE for ; Wed, 22 May 2019 23:10:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7FD3A206BA for ; Wed, 22 May 2019 23:10:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SYw24KXc"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="igi2ZowC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7FD3A206BA Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Vo4kP/trUn/BraqpvOVR+QGJ6thLDFcrhboHU9AUHeM=; b=SYw24KXc8zAfZD gDTcLOtdlL3yNJI/QiGEVHk2Bu3Yv+JCQzxRbG7CT8RNUXNjkFkwolM5WKJmMsg+sPoE2tpuYinmk z1dnCdz7SRCgwJn9M7NLHQujmzrGWLtb78zZkP110Zgu8bMlcZBaWCnTxnrH6YVlnkeLFxyzF6vwk WMBWCOTuS9XMMMZfvtJxxQ8VkgL98Fwh5vEJbBMl7IDtwly6aDRZcupKZazMi+HVy+QPkxVu8+Kpl PWT4Tg/TPSQUiUR1OY9N3sLSbWGtaBx567IvQb2jf4vqiWuEHeWWAfd6sOSTMne8JVYf6TmgmQbxk aaoPIloq9vNum2CJQoCQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hTaMr-0000La-Lb; Wed, 22 May 2019 23:09:53 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hTaMn-0000KI-Jr for linux-arm-kernel@lists.infradead.org; Wed, 22 May 2019 23:09:51 +0000 Received: by mail-lj1-x243.google.com with SMTP id e13so3620969ljl.11 for ; Wed, 22 May 2019 16:09:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Zo0ta7cFHgMRhNj415CGcWxBRhsPIdMQaFfQkNGZDyg=; b=igi2ZowCRR3eZ9/0nTV8cXZJb9K3GEJ6nM7xrdpCgyuIedU5DlpD8BYtYq2g7fhIK6 FMPk+pIR3l66HCoBcqnR8RLDUlNVKBoDdSOOKbybJMa8cIyuAzuBD0XVwoayLR91TP1S Or9Vm+AM1MqvKUg9+c3gOd7GP47AnzQE07FfPqL0gIQFQsaz6/Wtl6TltaTcvzbkWmzx nUHyczH55lHnf4QLfD7YMKsWm2P4/KbXTCsRnYy/LgXeL0UQ2MOisKGH9I79sJSp7fTc mCIju+QQoBZwdM0ZHmLkXpay4k0e/6JiSlhqZI0PrF8znz18Mpt9AP9bfE2L3yEv2l8R 69MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Zo0ta7cFHgMRhNj415CGcWxBRhsPIdMQaFfQkNGZDyg=; b=UoFElRxp1A2qkVsbnd7G9SJ9+D7g2S2/OgPcpEKH4lfXM+qRjd9pkW1bGjgl6Lr79K KNtSEBqQFttlVisaNrvF9+jq+se56N3y5GZ7KTI6lrh0EVxGRc3MXeyUYLmdeSKTdeIV GY1eZ/Q/pUGh/o9MXrqVhK+z2v7fB3SXJ6jC4MCD0Lfr302+YGMixM9d3J5gsVds6gcd XUiCQypdV9V+HgTedaswDxg6woJCCK+QUXH6jXyt3irN0fbmKf8k5R59oOyh0dxjU55i 5RcD+/xzrHIp3mZ4RDiv+BoZr6UH3ZiHT6KXP6D8jhb8ZTfwd99zCErqyuB/EsYoBy4Y Mtpw== X-Gm-Message-State: APjAAAWW7b9tPS4A9CU1/31nZs4Sj+Iy60HPtpUdDQB0jomLQiYqoxQU YhXcH0uA69o5v6aSgUzAma0OmnUjHvinVTZj1nkDew== X-Google-Smtp-Source: APXvYqyzdpKdhtViUHlA5ZulCPuE1mR7dT316mPXUNWFyB1kZFy9VtMEAzPhqeN7WBqyKU4f463JOkqzDuNZUlPEoK8= X-Received: by 2002:a2e:885a:: with SMTP id z26mr2119940ljj.35.1558566583161; Wed, 22 May 2019 16:09:43 -0700 (PDT) MIME-Version: 1.0 References: <20190517144931.GA56186@arrakis.emea.arm.com> <20190521182932.sm4vxweuwo5ermyd@mbp> <201905211633.6C0BF0C2@keescook> <20190522101110.m2stmpaj7seezveq@mbp> <20190522163527.rnnc6t4tll7tk5zw@mbp> <201905221316.865581CF@keescook> In-Reply-To: From: enh Date: Wed, 22 May 2019 16:09:31 -0700 Message-ID: Subject: Re: [PATCH v15 00/17] arm64: untag user pointers passed to the kernel To: Evgenii Stepanov X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190522_160949_657763_C0B85866 X-CRM114-Status: GOOD ( 32.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , kvm@vger.kernel.org, Szabolcs Nagy , Catalin Marinas , Will Deacon , dri-devel@lists.freedesktop.org, Linux Memory Management List , Khalid Aziz , "open list:KERNEL SELFTEST FRAMEWORK" , Felix Kuehling , Vincenzo Frascino , Jacob Bramley , Leon Romanovsky , linux-rdma@vger.kernel.org, amd-gfx@lists.freedesktop.org, Dmitry Vyukov , Dave Martin , linux-media@vger.kernel.org, Kevin Brodsky , Kees Cook , Ruben Ayrapetyan , Andrey Konovalov , Ramana Radhakrishnan , Alex Williamson , Mauro Carvalho Chehab , Linux ARM , Kostya Serebryany , Greg Kroah-Hartman , Yishai Hadas , LKML , Jens Wiklander , Lee Smith , Alexander Deucher , Andrew Morton , Robin Murphy , Christian Koenig , Luc Van Oostenryck Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, May 22, 2019 at 4:03 PM Evgenii Stepanov wrote: > > On Wed, May 22, 2019 at 1:47 PM Kees Cook wrote: > > > > On Wed, May 22, 2019 at 05:35:27PM +0100, Catalin Marinas wrote: > > > The two hard requirements I have for supporting any new hardware feature > > > in Linux are (1) a single kernel image binary continues to run on old > > > hardware while making use of the new feature if available and (2) old > > > user space continues to run on new hardware while new user space can > > > take advantage of the new feature. > > > > Agreed! And I think the series meets these requirements, yes? > > > > > For MTE, we just can't enable it by default since there are applications > > > who use the top byte of a pointer and expect it to be ignored rather > > > than failing with a mismatched tag. Just think of a hwasan compiled > > > binary where TBI is expected to work and you try to run it with MTE > > > turned on. > > > > Ah! Okay, here's the use-case I wasn't thinking of: the concern is TBI > > conflicting with MTE. And anything that starts using TBI suddenly can't > > run in the future because it's being interpreted as MTE bits? (Is that > > the ABI concern? I feel like we got into the weeds about ioctl()s and > > one-off bugs...) > > > > So there needs to be some way to let the kernel know which of three > > things it should be doing: > > 1- leaving userspace addresses as-is (present) > > 2- wiping the top bits before using (this series) > > 3- wiping the top bits for most things, but retaining them for MTE as > > needed (the future) > > > > I expect MTE to be the "default" in the future. Once a system's libc has > > grown support for it, everything will be trying to use MTE. TBI will be > > the special case (but TBI is effectively a prerequisite). > > > > AFAICT, the only difference I see between 2 and 3 will be the tag handling > > in usercopy (all other places will continue to ignore the top bits). Is > > that accurate? > > > > Is "1" a per-process state we want to keep? (I assume not, but rather it > > is available via no TBI/MTE CONFIG or a boot-time option, if at all?) > > > > To choose between "2" and "3", it seems we need a per-process flag to > > opt into TBI (and out of MTE). For userspace, how would a future binary > > choose TBI over MTE? If it's a library issue, we can't use an ELF bit, > > since the choice may be "late" after ELF load (this implies the need > > for a prctl().) If it's binary-only ("built with HWKASan") then an ELF > > bit seems sufficient. And without the marking, I'd expect the kernel to > > enforce MTE when there are high bits. > > > > > I would also expect the C library or dynamic loader to check for the > > > presence of a HWCAP_MTE bit before starting to tag memory allocations, > > > otherwise it would get SIGILL on the first MTE instruction it tries to > > > execute. > > > > I've got the same question as Elliot: aren't MTE instructions just NOP > > to older CPUs? I.e. if the CPU (or kernel) don't support it, it just > > gets entirely ignored: checking is only needed to satisfy curiosity > > or behavioral expectations. > > MTE instructions are not NOP. Most of them have side effects (changing > register values, zeroing memory). no, i meant "they're encoded in a space that was previously no-ops, so running on MTE code on old hardware doesn't cause SIGILL". > This only matters for stack tagging, though. Heap tagging is a runtime > decision in the allocator. > > If an image needs to run on old hardware, it will have to do heap tagging only. > > > To me, the conflict seems to be using TBI in the face of expecting MTE to > > be the default state of the future. (But the internal changes needed > > for TBI -- this series -- is a prereq for MTE.) > > > > -- > > Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel