Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2528433imm; Thu, 19 Jul 2018 23:39:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfid7+DGSJ97TOGyJyDx0HjFMMkgHEOU2mv43xbrHGU2Fy6iKhMx7UPkrBv89h0w6dGpFk2 X-Received: by 2002:a17:902:bf0b:: with SMTP id bi11-v6mr843187plb.25.1532068792190; Thu, 19 Jul 2018 23:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532068792; cv=none; d=google.com; s=arc-20160816; b=Z6s/xu7PthGhoOFomHvUpNHegfoEqJfPoA2kqMBJwvTQERPzneryMmElrsBR5O0xnC QG4EcFfpbO02D4/zdgwRYMFaE5CwU3ZdI0JuPwTnry6gD9dtiF3vZ8fe/8oY3jd44pzd KdllHCYaLWNr/DOkztC3hCCtm4jrGIkXplodnpDX7aIUw/p3M+JtfjKcQc05WcFz5++K 2dTRrR4grPXIIM16Ji/kGWHEIgioarso1gQt3YGgU8YuQ6xAvvuqOZR1ov1qbyMNz4c/ sCa/qws1WZURbWmcAhwiemBn2nhBYmeHzCfo/xPQ0Ie1hIt9hSNkP0ieJlXPDegn+wBf shLA== 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:arc-authentication-results; bh=rHBi8WSYCFhgeA3BLVBxQxVzuV7BTXiz1mBa/uMdrVw=; b=lahCmM0IKmfBvE2tZlbs9XeidDfWwMco/CDiUtxid1SZ7li1Jad6fS30Tj7+aKLKnQ ulnrd9yceO0UUFPt1GMqN4jNI/FlVF7171q5BYfTYBV/piSW6kLvptPTQoGk4wC1QVFC hnvkuKEif0e/Av0RzX/35FjsTrEty9kqfgDcfDVXkFnk49tZlneLUFAIWE2mUzZqMIbk GtSPB6KA3n4yspMZXY/ukKstHs+MNJeOhrK2M3u1eKq5vfHdQ3VMJL6ymOIUWrXg3Ww6 +3p6pk1mjMNHR49IJ8HJzdUmY1Wk2kI6Q1bTn0916GP9u01aYRdqXye/2KOB1h3jvECB YztQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j72-v6si1150183pfe.187.2018.07.19.23.39.37; Thu, 19 Jul 2018 23:39:52 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727177AbeGTHZY (ORCPT + 99 others); Fri, 20 Jul 2018 03:25:24 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:58488 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726533AbeGTHZY (ORCPT ); Fri, 20 Jul 2018 03:25:24 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 94BB118A; Thu, 19 Jul 2018 23:38:42 -0700 (PDT) Received: from salmiak (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A3C973F246; Thu, 19 Jul 2018 23:38:40 -0700 (PDT) Date: Fri, 20 Jul 2018 07:38:37 +0100 From: Mark Rutland To: Laura Abbott Cc: Alexander Popov , Kees Cook , Ard Biesheuvel , kernel-hardening@lists.openwall.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Will Deacon , Catalin Marinas Subject: Re: [PATCHv2 1/2] arm64: Add stack information to on_accessible_stack Message-ID: <20180720063837.5c5nxypv4urumz2m@salmiak> References: <20180719232806.3397-1-labbott@redhat.com> <20180719232806.3397-2-labbott@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180719232806.3397-2-labbott@redhat.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 19, 2018 at 04:28:05PM -0700, Laura Abbott wrote: > > In preparation for enabling the stackleak plugin on arm64, > we need a way to get the bounds of the current stack. Extend > on_accessible_stack to get this information. > > Signed-off-by: Laura Abbott > --- > v2: Switched to using struct stack_info for argument passing. > on_accessible_stack is now the primary API. Split STACK_TYPE_SDEI > into STACK_TYPE_SDEI_NORMAL and STACK_TYPE_SDEI_CRITICAL. [...] > -static inline bool on_irq_stack(unsigned long sp) > +static inline bool on_irq_stack(unsigned long sp, > + struct stack_info *info) > { > unsigned long low = (unsigned long)raw_cpu_read(irq_stack_ptr); > unsigned long high = low + IRQ_STACK_SIZE; > @@ -47,46 +63,79 @@ static inline bool on_irq_stack(unsigned long sp) > if (!low) > return false; > > - return (low <= sp && sp < high); > + if (sp < low || sp >= high) > + return false; > + > + if (info) { > + info->low = low; > + info->high = high; > + info->type = STACK_TYPE_IRQ; > + } > + > + return true; > } [...] > -bool _on_sdei_stack(unsigned long sp) > +bool on_sdei_normal_stack(unsigned long sp, > + struct stack_info *info) > +{ > + unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_normal_ptr); > + unsigned long high = low + SDEI_STACK_SIZE; > + > + if (low <= sp && sp < high) { > + if (info) { > + info->low = low; > + info->high = high; > + info->type = STACK_TYPE_SDEI_NORMAL; > + } > + return true; > + } > + > + return false; > +} > + > +bool on_sdei_critical_stack(unsigned long sp, > + struct stack_info *info) > +{ > + unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_critical_ptr); > + unsigned long high = low + SDEI_STACK_SIZE; > + > + if (low <= sp && sp < high) { > + if (info) { > + info->low = low; > + info->high = high; > + info->type = STACK_TYPE_SDEI_CRITICAL; > + } > + return true; > + } > + > + return false; > +} Minor nit, but it would be good to avoid the nested conditionals for these two by bailing out early when the SP is out of bounds, as with the other on__stack() functions, e.g. bool on_sdei_normal_stack(unsigned long sp, struct stack_info *info) { unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_normal_ptr); unsigned long high = low + SDEI_STACK_SIZE; if (sp < low || sp >= high) return false; if (info) { info->low = low; info->high = high; info->type = STACK_TYPE_SDEI_NORMAL; } return true; } Otherwise, this all looks good to me. With that: Reviewed-by: Mark Rutland Thanks for working on this! Mark.