Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1046926ybf; Fri, 28 Feb 2020 12:52:52 -0800 (PST) X-Google-Smtp-Source: APXvYqzsHNM3bU3gcDnnnkw8wKl/fbHuu1E/43mubI4HZwSwS2VK5m9nsL7tIR9d9WnqRqHfgMAZ X-Received: by 2002:a05:6830:1643:: with SMTP id h3mr4612579otr.70.1582923172144; Fri, 28 Feb 2020 12:52:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582923172; cv=none; d=google.com; s=arc-20160816; b=YO7ptGIQHDRPgCFbi2sQY4rEXVeKrSTffctjbG6JqusuQb+1OXAHuQqAEYlyLS21WM 6g4rwoZeE8Cx8em7kAloLJv4ID0rSNdsFpYs19ggKDopoVyFCvg6YQK4hi1fd+iJGgpc u/5l+TQcO7fSi8W0pwRJzaCGbIp/lhMoDubZiqt90MILRaDfkhn608aobDIlh1TgE8rN JkKGJY2EYm7bjAxUeBHLQ87fo5yaCfQ0RPSfxK6Zu3oj+f8++Y7rkD3/Uki7/yrYL1vb 7yByVGfC2Vo53Dw7bZMKQtmk7ONHSEyaUStQGKZosVs2xSaw4tm0aBCZNRJDELX7K/O/ tsSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=SitQuWaYJYljvcCrYj4fkHHkPc4o0vcrOMkYmOvH+dg=; b=XROeRKwicIPVCKPzCvfUGbDw2JS68YzPeplJpintjAbNvg2WoKpmEgKLS4WCVriKHK iShTTypMR6SIfjokcycWiDAJyKDtQvlYLYqtXu+Y+rwQz9T0iq3mnHgQuTDTlWlx7Uyu +AWaBdV7ksWxhHamCZ34Rtr3AqQnsehc3uEhyvcPtH5XKun+YOqdp0Pi5GAN2OXe6kkb EvYKHRCQugMKnUz4mqoxxn4Y4leufvnnZ7MVHLHky+ep/xW+pWZKVofwSDVt9PcxvZmO TUZ+tXr7Jk7TnPv0L2IKnhtmBjMWncKdkFFLwe+lI2PmcRMGlDWR8qmQvcx0awYViVDU lHwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="WsM/fb6y"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17si2166573otp.236.2020.02.28.12.52.37; Fri, 28 Feb 2020 12:52:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="WsM/fb6y"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726118AbgB1UvW (ORCPT + 99 others); Fri, 28 Feb 2020 15:51:22 -0500 Received: from mail-vs1-f68.google.com ([209.85.217.68]:35051 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgB1UvW (ORCPT ); Fri, 28 Feb 2020 15:51:22 -0500 Received: by mail-vs1-f68.google.com with SMTP id u26so2845717vsg.2 for ; Fri, 28 Feb 2020 12:51:21 -0800 (PST) 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=SitQuWaYJYljvcCrYj4fkHHkPc4o0vcrOMkYmOvH+dg=; b=WsM/fb6y5CGtFjZacOBZZYlUzkSwNVN+lgzwRpeO7kE0e/83uZ2+K3ZTNKkv0Q8dSI a+Cugxv8TY/rUcQjCqy8r8gHFh1GeAOUAEhTpt/68gti4/raIjNU9nV6YsuYTnE1pQg4 BjR09FkgavjN4CagxM8NdJbh77wJU1R5zT8YKoCpeYzhTXcpH67QL/XNAng5pvrnCqzW IlpTQwrR9LWfOP5fofMezihxVEIAGD6q+96J1skrj6gfpRAHBApVND96QkQOppRbBXCs AIgan+ocDu8aj28mHw/t5DZ9jenFbfBChKOdPnSbMKWlknHeyCJ9J8SDvVmB2tsmDd2F ZnZg== 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=SitQuWaYJYljvcCrYj4fkHHkPc4o0vcrOMkYmOvH+dg=; b=o9pUW2Tr4b1b4bPCz0kl/oOBavj6vWWUqKBrjkjNQOnJTFz1Dj4HX/bHa5oyu/QRbN hAgkqHxl6vVxL2+sFHZGIESTP1nPE0Zl30LAzilJf39jnwSZNWb6Xm+fZ17AEuevK4s4 FhPBen/qZOfD9ZNOddrW9YH2f/s2HB+4R+TahHw4neEfaayBpD9b9U2LOA/EoCIhlmmU dlIRREopjBJBW1fWilZHLOEHcHQyqMLmN+Os6/TYivJDXpbY9Z6b6ElFbPjnUTkDxosu o/OBcYML/TTYVMO6JtQ5r3SaLPTuTQFO1z/qXZNZlv5yG8IGttJyvgXOV8QXu4LWyTP5 LYEQ== X-Gm-Message-State: ANhLgQ1ngeqwQFtdZVKap/o7G7b85pMyn3Mri9hhnI6G14XXRO/xzhyE JrsQe5l5ZlBi3Ojf5h3EnzyK910kwDe3HWwY/PfqRQ== X-Received: by 2002:a67:fb8d:: with SMTP id n13mr309624vsr.15.1582923080404; Fri, 28 Feb 2020 12:51:20 -0800 (PST) MIME-Version: 1.0 References: <20191018161033.261971-1-samitolvanen@google.com> <20200225173933.74818-1-samitolvanen@google.com> <20200225173933.74818-11-samitolvanen@google.com> <56b82a54-044a-75ec-64e5-6ba25b19571f@arm.com> In-Reply-To: <56b82a54-044a-75ec-64e5-6ba25b19571f@arm.com> From: Sami Tolvanen Date: Fri, 28 Feb 2020 12:51:09 -0800 Message-ID: Subject: Re: [PATCH v9 10/12] arm64: implement Shadow Call Stack To: James Morse Cc: Will Deacon , Catalin Marinas , Steven Rostedt , Masami Hiramatsu , Ard Biesheuvel , Mark Rutland , Dave Martin , Kees Cook , Laura Abbott , Marc Zyngier , Nick Desaulniers , Jann Horn , Miguel Ojeda , Masahiro Yamada , clang-built-linux , Kernel Hardening , linux-arm-kernel , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 28, 2020 at 8:31 AM James Morse wrote: > > +#ifndef __ASSEMBLY__ > > As the whole file is guarded by this, why do you need to include it in assembly files at all? True, the include in head.S is not needed. I'll remove it in the next version. > > +static inline void scs_overflow_check(struct task_struct *tsk) > > +{ > > + if (unlikely(scs_corrupted(tsk))) > > + panic("corrupted shadow stack detected inside scheduler\n"); > > Could this ever catch anything with CONFIG_SHADOW_CALL_STACK_VMAP? > Wouldn't we have hit the vmalloc guard page at the point of overflow? With CONFIG_SHADOW_CALL_STACK_VMAP, even though we allocate a full page, SCS_SIZE is still 1k, so we should catch overflows here well before we hit the guard page. > It would be nice to have a per-cpu stack that we switch to when on the overflow stack. It shouldn't be a problem to add an overflow shadow stack if you think one is needed. > I can't work out why this needs to be before before idle_task_exit()... > It needs to run before init_idle(), which calls scs_task_reset(), but all that is on the > cpu_up() path. (if it is to pair those up, any reason core code can't do both?) At this point, the idle task's shadow stack pointer is only stored in x18, so we need to save it again to thread_info before the CPU shuts down, or we'll lose the pointer. Sami