Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3799037ybz; Mon, 4 May 2020 09:55:53 -0700 (PDT) X-Google-Smtp-Source: APiQypKzEvGyFFq7IFspk3hHz7zA8bHHAtmmHkF+76f4vEtUsgItRYc9aOP5gpKFfpeU/OCxP8j4 X-Received: by 2002:a17:906:82d2:: with SMTP id a18mr15512883ejy.373.1588611352703; Mon, 04 May 2020 09:55:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588611352; cv=none; d=google.com; s=arc-20160816; b=wzVtR2vjqvRF0tIa+Dpe+EG5N+japRepZeoJOZhL6f1Hc+bfzasx14F8kDtd5lGFGm 5pY2OWTn/RQFw38QKfYtwZfp4kym3JtmaKR2tAzJ0BdwiM06ZD1TYoGXWmJMiM/syrP5 0Kc16t4unjv4O8+3L6nNoSnzrRjxF1ygBIGUqGA10QYiykmVHSOiuQ+jttUkfOBiVeGr N6MP0ceVQg/N4zjqBpBUqGYmvpYxF5cMNcjNb8RWMORA9wtAfNqnUIpeJOixbRzM1Mav sbOv81Xa2NLwxcNtLbJSPgmHLRodlg8kpMlezHCU5m5NjmjK5kwqIKujjWuyXiQ2hsHb w+tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=oC+ESnzVQCxKbjADJvWYjCJ5RJvcKVP50R8qXsMX4qM=; b=VDaI6BJOjVRze/DD2BzHni687J0KHy0RICfU/wSO3L/jKnTDTf0++MLTkC/JhbMxSB aNxtGHUUg5ihxQJceO7WU8TMv9aZzDToex8oaHhx7YmXUz10cJscdbnaSP/XnWCdNSQ1 CWgQpA5CZ4RicTofiSWPZXGfJrnnSeZXcWm1ep721Mr81iw0gPiHHebb/+bodXgDqns/ zlCyjuXD1RLo699vDVCRxjrNHzuwVxY1lnUP4Xt4krCmjyfg6a9K+dt/OkBVHaY2U+Ey XUZOMt5oKqLNA8Z3cPF2kzjXYMd1AXX2yMZS5IC5OSVpikh29DvfxNnkiFpm3xevN+VO OdZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uyMa7may; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bq14si6891732ejb.42.2020.05.04.09.55.30; Mon, 04 May 2020 09:55:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uyMa7may; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729855AbgEDQwg (ORCPT + 99 others); Mon, 4 May 2020 12:52:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:34388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729740AbgEDQwg (ORCPT ); Mon, 4 May 2020 12:52:36 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C292E20721; Mon, 4 May 2020 16:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588611155; bh=pHevdodwKI9AchWwf20bTvyMZmY/KXT51VAk5UHfloY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uyMa7mayYmQKcwMDm+GOx012e1zqDeyv+W5L6bDtfpKFAZ+E7dHLgSdsy/T09kHTW ixd15enHaJKKfVWzOVcZQBM4JTXKH1eXGREFx5btkK873B8qrSEX32IqtAqg24KSMC y7A6s2xNnFeJRxYbjVN/DbsKn+VXK3WbXoGH2kNQ= Date: Mon, 4 May 2020 17:52:28 +0100 From: Will Deacon To: Sami Tolvanen Cc: Kees Cook , Catalin Marinas , James Morse , Steven Rostedt , Ard Biesheuvel , Mark Rutland , Masahiro Yamada , Michal Marek , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dave Martin , Laura Abbott , Marc Zyngier , Masami Hiramatsu , Nick Desaulniers , Jann Horn , Miguel Ojeda , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v11 01/12] add support for Clang's Shadow Call Stack (SCS) Message-ID: <20200504165227.GB1833@willie-the-truck> References: <20191018161033.261971-1-samitolvanen@google.com> <20200416161245.148813-1-samitolvanen@google.com> <20200416161245.148813-2-samitolvanen@google.com> <20200420171727.GB24386@willie-the-truck> <20200420211830.GA5081@google.com> <20200422173938.GA3069@willie-the-truck> <20200422235134.GA211149@google.com> <202004231121.A13FDA100@keescook> <20200424112113.GC21141@willie-the-truck> <20200427204546.GA80713@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200427204546.GA80713@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 27, 2020 at 01:45:46PM -0700, Sami Tolvanen wrote: > On Fri, Apr 24, 2020 at 12:21:14PM +0100, Will Deacon wrote: > > Also, since you mentioned the lack of redzoning, isn't it a bit dodgy > > allocating blindly out of the kmem_cache? It means we don't have a redzone > > or a guard page, so if you can trigger something like a recursion bug then > > could you scribble past the SCS before the main stack overflows? Would this > > clobber somebody else's SCS? > > I agree that allocating from a kmem_cache isn't ideal for safety. It's a > compromise to reduce memory overhead. Do you think it would be a problem if we always allocated a page for the SCS? > > The vmap version that I asked Sami to drop > > is at least better in this regard, although the guard page is at the wrong > > end of the stack and we just hope that the allocation below us didn't pass > > VM_NO_GUARD. Looks like the same story for vmap stack :/ > > SCS grows up and the guard page is after the allocation, so how is it at > the wrong end? Am I missing something here? Sorry, I'd got the SCS upside-down in my head (hey, that second 'S' stands for 'Stack'!). But I think I'm right about vmap stack, which feels a little fragile even though it seems to work out today with the very limited uses of VM_NO_GUARD. > > If we split the pointer in two (base, offset) then we could leave the > > base live in the thread_info, not require alignment of the stacks (which > > may allow for unconditional redzoning?) and then just update the offset > > value on context switch, which could be trivially checked as part of the > > existing stack overflow checking on kernel entry. > > I sent out v13 with split pointers, but I'm not sure it's convenient to > add an overflow check to kernel_ventry where the VMAP_STACK check is > done. I suppose I could add a check to kernel_entry after we load x18 > from tsk. Thoughts? I'll take a look at v13, since at this stage I'm keen to get something queued up so that we can use it as a base for further improvements without you having to repost the whole stack every time. Cheers, Will