Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5547830pxb; Mon, 14 Feb 2022 01:32:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWKLmSzgxva7dRXNw4YZJ88NW1KUPrM3H2wr9RqQJDw2BskYetgR3Sj3TlJK448xV7sZ4C X-Received: by 2002:a17:906:d54e:: with SMTP id cr14mr11060146ejc.692.1644831126600; Mon, 14 Feb 2022 01:32:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644831126; cv=none; d=google.com; s=arc-20160816; b=grhxl5jdEMso6OtnIYcl5ufgf8s+gF/pSFWwi3ancEE0kq5YOofI7Pn1RdQ391b5Vl ibMspR3LQSgXY5D2uAQ2DzUFeCzvrkjbsKCh295/60AmUVFp2xnm/s+Z8DAiFh7FXNnu NEWl6YvVsnfQrRNWCSMyrc0JsUFdLSshUkA/HPAOgniKS3a1DaYT+wXBn9xiT61BAz0P KkJUADXDuP0yOKxQ3BP5UPVhOSMMGpCO+VbpvLuj8e9PDpnVEpbpZ0XiZPP9ktVZw8Pz kxiZMpjXz1N3OZCtSXMErMc9B0Fb9VocnrF+Gj6zuv/tLswhd2/hkSNjNDRtLsRhggkS 7jJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=FbT5RxNSSBaYUNnpqt/QOhQpOxqNcOxviXJ4YQ/L/a4=; b=sEiVqV2FUsrEuoDN/5LDKZ0mEfHQB1dWh7dcGvk/v/OAFFAVnvqc9kINMALHjOANfb PONcQWBkD8ZHggD4Rzxy/f9y3+EFBC5dnfhWVjKXc403XRo7dqsmMO71OApRTOkIkeq2 ba9cAZraOQ6XzWdzP/+3G3+FQU18ju7bXzYQ6+VL8gKqrEZNtIdJRajxvwA1eu0x07/t 6AYVNsyIp7GYXstaDfepT2wBkRlmLwI1y/KEMcMhhUR5JnaCgvzglXziNAaA/I/1f7h+ 5cXvTTb+3Fbc97cS7LJUDGbPhWUgDMA4BNpdHGJc/dUek6S/uIzy9ClZ7uaMa3ywiDd8 Hpxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bA8qmWpk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz15si762100ejc.44.2022.02.14.01.31.43; Mon, 14 Feb 2022 01:32:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bA8qmWpk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1352409AbiBKRyP (ORCPT + 93 others); Fri, 11 Feb 2022 12:54:15 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236822AbiBKRyO (ORCPT ); Fri, 11 Feb 2022 12:54:14 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B43DCD5; Fri, 11 Feb 2022 09:54:12 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DFBD2B82B67; Fri, 11 Feb 2022 17:54:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD776C340E9; Fri, 11 Feb 2022 17:54:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644602049; bh=FsUOrelQNqNyH3UASN+ZGpPm+zrcDvNiCyxLZ2cOLHU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=bA8qmWpkMliRzgJ3/D9pIM4YRzkVL/VClVeC1kecwl9UuEu9syCd/L1k3aZIdb/Am yJzGeOckMjikcxRadLMZQOTt7482bDcDmr5xONcdduo38eNseusJ5YGl01Ba8r8uq+ a78UFF2SXihbjHiopc9bXzu2qEamaXka5zQH2+tjJPjec1yKSU4p9OMPYD6Q5XzQoM h90D38uKF3vQCcxPEFHtZvTcp2hrfQtuQmLQcS9gswYckPW/dGTzmWWKMG/V1nez9W ith2h10B661UAiRqaSjRW3oYRJpETjWEcruoh5PyobYIhQ+5YwXBOS8m9vM00Ixt+J 5F6X4GojvoE3g== Message-ID: Date: Fri, 11 Feb 2022 09:54:07 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH 18/35] mm: Add guard pages around a shadow stack. Content-Language: en-US To: "Edgecombe, Rick P" , "Hansen, Dave" Cc: "bsingharora@gmail.com" , "hpa@zytor.com" , "Syromiatnikov, Eugene" , "peterz@infradead.org" , "rdunlap@infradead.org" , "keescook@chromium.org" , "Yu, Yu-cheng" , "dave.hansen@linux.intel.com" , "kirill.shutemov@linux.intel.com" , "Eranian, Stephane" , "linux-mm@kvack.org" , "fweimer@redhat.com" , "nadav.amit@gmail.com" , "jannh@google.com" , "linux-arch@vger.kernel.org" , "kcc@google.com" , "bp@alien8.de" , "oleg@redhat.com" , "hjl.tools@gmail.com" , "Yang, Weijiang" , "linux-doc@vger.kernel.org" , "pavel@ucw.cz" , "arnd@arndb.de" , "Moreira, Joao" , "tglx@linutronix.de" , "mike.kravetz@oracle.com" , "x86@kernel.org" , "dave.martin@arm.com" , "john.allen@amd.com" , "mingo@redhat.com" , "Shankar, Ravi V" , "corbet@lwn.net" , "linux-kernel@vger.kernel.org" , "linux-api@vger.kernel.org" , "gorcunov@gmail.com" References: <20220130211838.8382-1-rick.p.edgecombe@intel.com> <20220130211838.8382-19-rick.p.edgecombe@intel.com> <4c216532-2b68-dd95-93f1-542df4786d7a@intel.com> From: Andy Lutomirski In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/10/22 15:40, Edgecombe, Rick P wrote: > On Thu, 2022-02-10 at 15:07 -0800, Andy Lutomirski wrote: >> On Thu, Feb 10, 2022 at 2:44 PM Dave Hansen >> wrote: >>> >>> On 1/30/22 13:18, Rick Edgecombe wrote: >>>> INCSSP(Q/D) increments shadow stack pointer and 'pops and >>>> discards' the >>>> first and the last elements in the range, effectively touches >>>> those memory >>>> areas. >>>> >>>> The maximum moving distance by INCSSPQ is 255 * 8 = 2040 bytes >>>> and >>>> 255 * 4 = 1020 bytes by INCSSPD. Both ranges are far from >>>> PAGE_SIZE. >>>> Thus, putting a gap page on both ends of a shadow stack prevents >>>> INCSSP, >>>> CALL, and RET from going beyond. >>> >>> What is the downside of not applying this patch? The shadow stack >>> gap >>> is 1MB instead of 4k? >>> >>> That, frankly, doesn't seem too bad. How badly do we *need* this >>> patch? > > Like just using VM_SHADOW_STACK | VM_GROWSDOWN to get a regular stack > sized gap? I think it could work. It also simplifies the mm->stack_vm > accounting. Seems not crazy. Do we want automatically growing shadow stacks? I don't really like the historical unix behavior where the main thread has a sort-of-infinite stack and every other thread has a fixed stack. > > It would no longer get a gap at the end though. I don't think it's > needed. > I may have missed something about the oddball way the mm code works, but it seems if you have a gap at one end of every shadow stack, you automatically have a gap at the other end.