Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1589594pxb; Thu, 4 Feb 2021 17:49:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJw1kZTBaQPJq1B/coeRMRtI80hkWeVxQ0VEN7htfbC/bjDfdGxYzLP01GDo7fYRIRqKZ+t+ X-Received: by 2002:a50:f19a:: with SMTP id x26mr1361025edl.354.1612489768863; Thu, 04 Feb 2021 17:49:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612489768; cv=none; d=google.com; s=arc-20160816; b=KByxATSmwIZd38fk514dbkmobh04P6eoftA0p+LSL8428xG7wGwUKR0rwCxqWBxGGV s6tPQbgLqEbZOkb5lppvui197R2JE0iECQC8jXPQBFSbLxHuqTyb1XpUXKCjBafGA77M 457hzl4SCgwY/G2p0eD3Q4cals2bKk3JyLwoY1jVWZcF8v9/p8U6FONwbUrAwRt89Uim wWx0IRYokF+eY/FHRXr3iEwKRgqOHf+OtMDjDhGQoGugE9h4EbDONmjCI7lM7tkInhWG 7iCzUM9BKiHQD+YltwIv5gF70PDgDLMVBYFjTvZWH6qUBAkIOxwOlbkKtlfVvO5SfbtG x4sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YiBh8kjoQsH+w1ie1OfB7U+mi5FxxL8KWnwrDiJ80SQ=; b=za/bV5L42xOYsJWqd2Cip6tbjWJgsVcS1Y5efOqjt1/l3aZq9ttOCWwY45Eot8GH3g 3Tw9f/3/u9wZXY3Jd7AKx6vUzMXOgamB23vwEPd7P4LfdfCsbI/G8TrfTfC76+aRcPtt MmhpA4QjwcSbooVL+eho5wUuZzq62uJV2YbPxJsHXKYFMBRAcm0zbgd0/KGLPAF3gCKP BvHRkd//rHcTucCBSOlVyjgOvBCFc6v3P4UkUtDZxKPEnSvzDGpN4zNt2ZtUK69JlwWy Mrji4DAoLtsjJUkWoY/V54bB6K2tgMQ6azW+GP64VxgQMcxqTWVuEZGlJOqMbzLnpKBF ttWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PPt+H4wq; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e22si5050140edu.45.2021.02.04.17.49.04; Thu, 04 Feb 2021 17:49:28 -0800 (PST) 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=@chromium.org header.s=google header.b=PPt+H4wq; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239482AbhBDUYp (ORCPT + 99 others); Thu, 4 Feb 2021 15:24:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240102AbhBDUY0 (ORCPT ); Thu, 4 Feb 2021 15:24:26 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCD04C0613D6 for ; Thu, 4 Feb 2021 12:24:11 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id cl8so2362721pjb.0 for ; Thu, 04 Feb 2021 12:24:11 -0800 (PST) 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=YiBh8kjoQsH+w1ie1OfB7U+mi5FxxL8KWnwrDiJ80SQ=; b=PPt+H4wqt1A6KWRSkPhPkxwMn/vw3TKT91vvsKmHebL+0nltYCjD9IrFeHTRAjQymj BUG3q3cW2DBZiH22qiC37rSeMW4mlApOQfqnOR82W1zU+j/au6dXILhqYy9A8+6Iv8qY bcd9AfXep4kZgB1Vmchd6yJteQKwVnKD37aR4= 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=YiBh8kjoQsH+w1ie1OfB7U+mi5FxxL8KWnwrDiJ80SQ=; b=jrHVQDOOKxO8QdSsMRkhMcHvt9genUvKhukVFcqCBTFyIj2v6Cn960LigdAFLdeHpf apV2MlKD2or0GLw/cuX/y85ZUYlw0hOypYc6XpD4BlUkAV6kEkW09uiTLdwj/oxcrmo/ 17QAmP4K73pKECrkuRk3rM2u1yM05RyFSfY2o8pfs3pyI/EduNNOfcOZZvAThrWENMG1 p50940QyqXcoehVG+ozRisqk+6GQrfP4MYvqRVb4gLqX8sgAYb3qOpiz83WOrTUnU4mr R1WCJKU3VgVULwpW5Ikd0R9uyEaar9zPMkXPemm9B4hK2hNTsGGTKOybQ5EwxcTd3oTK JHtg== X-Gm-Message-State: AOAM533Ov7kvNYCTFef27jewc8eGRUsercWZPBu3qhUGWpBTs8QjJsJp qp0l267jCjqgWpFtvTKs5IpRlA== X-Received: by 2002:a17:902:59dc:b029:e2:9e80:1537 with SMTP id d28-20020a17090259dcb02900e29e801537mr954553plj.66.1612470251540; Thu, 04 Feb 2021 12:24:11 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id k11sm6241168pfc.22.2021.02.04.12.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 12:24:10 -0800 (PST) Date: Thu, 4 Feb 2021 12:24:09 -0800 From: Kees Cook To: Yu-cheng Yu Cc: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu Subject: Re: [PATCH v19 16/25] mm: Add guard pages around a shadow stack. Message-ID: <202102041224.5D300A122B@keescook> References: <20210203225547.32221-1-yu-cheng.yu@intel.com> <20210203225547.32221-17-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210203225547.32221-17-yu-cheng.yu@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 03, 2021 at 02:55:38PM -0800, Yu-cheng Yu 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. > > Signed-off-by: Yu-cheng Yu Yay guard pages! :) Reviewed-by: Kees Cook -- Kees Cook