Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1342378pxm; Thu, 24 Feb 2022 00:56:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0lIWeIPtujlM9sfPfZ17KpqCOLW7UogT7I/AzWYpxZJ1A/VTtt6Mp8ZeM5DfSGehlNJJS X-Received: by 2002:a17:906:93f7:b0:6cc:6319:6c43 with SMTP id yl23-20020a17090693f700b006cc63196c43mr1507793ejb.176.1645692985079; Thu, 24 Feb 2022 00:56:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645692985; cv=none; d=google.com; s=arc-20160816; b=rctjhkosqyQitLeLm66UHe1ZxMu2vs4n/g6XTHM17Dd3ORTbHzHqbe8gh4cLSO56JT DRliwoZKhUdQE2yoeJV+GwL+fC2C6X1rL1TDgGv5qUtXLcO7SBs3YZbO44ncuwscLrHl i+PYjuT8WYfN8fLinv/8vEMLE3A2SGhV1Yyqn1AkwxcVXwTddz9kIpS4mmWrI/k3DWu2 TyHdYOmYAjmrcBgxIBgW+670JXafV3jrGAuEb0PCixq1OBkEgfPIX6utYs3vANBYVm3J 0ttimcC8psUe9Ez4keH0eCyMRxJazOohwGGqqoZohZ0PCn89Uwgdv+SNaKaoF259CvXS rPFQ== 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=J2qG7ZKq2LLWcE9zTz7YvTPglUi3xbVY2wEf6KvxxJ8=; b=K0xbQYfDN87Vja7la/UNmE8lMda2jfcYvtTo38b9DrGRe/VSQ5hSlruL+Wa6MZtyvi efBj50KbqWkdYU1XRGgYdVuqRhDT1hSJg5oMjrVUGJa0sFunFV67ejXszweVtLKV9GF6 qt/bNC7hujPoTinw4/wEqH/0tdVgkhwGS5WOQ10plSWh0ahEiie8Sx/vp4AivaYavAuQ yoB4cW/d+EkQeGRU4QM3WI9q0zEo2G9Kq2B1cgueU9CPzqtUPwkQwy9ncriwzhKj5SHL w+OsJH14qputpIzLk591X3Yeejl5KY1D6q+QESu1zBiZXY+UfzQBwZSgcqH4VCs7MiNY mfSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WA4MOhJm; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s21si1205529edr.333.2022.02.24.00.56.02; Thu, 24 Feb 2022 00:56:25 -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=@chromium.org header.s=google header.b=WA4MOhJm; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231377AbiBXGnr (ORCPT + 99 others); Thu, 24 Feb 2022 01:43:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231245AbiBXGnp (ORCPT ); Thu, 24 Feb 2022 01:43:45 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD65C192F25 for ; Wed, 23 Feb 2022 22:43:16 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id 27so954513pgk.10 for ; Wed, 23 Feb 2022 22:43:16 -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=J2qG7ZKq2LLWcE9zTz7YvTPglUi3xbVY2wEf6KvxxJ8=; b=WA4MOhJmYzzPc7ehM4B4Ly35+5OunOQ5WwzYoeDhWwfBxgwAJKi97bI3GpMydQ4Y71 fvutOpNi0dXCT6E0dzUy2Ll8YyAfhG5l5r+85MBF93pbS8JG9iajJ2AzFnQzLhKpef4w ZjhwET9dBfwja8qz9sCjFkTLnCwWJt8G56WM8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=J2qG7ZKq2LLWcE9zTz7YvTPglUi3xbVY2wEf6KvxxJ8=; b=ebTloubGZvjcs1s0QY1wthnNXsfDw/yfI1L9x5TPaPLhQTZKbxDhyxw5PH94Dgbifv Nd8R9kzFIn7S/rg6YBiRgSNerqrfErzOoWMSMCjSbOrevD/OKXw/MAZ3gE9Cs39JmpxQ 4PfaMrV1tr/uupn8KekF+BPwRpxoO48bQHndqn6lH61LRlgOoUoFyd/tRiD9IEahnFkH 4cdbV6rrNT4Wnjh4Wex65rStuAuBR80s4H8S7U1ZmEPJ2miq6p49B3PxxPSDPivmsoLz DihMzi7Ys+p40sq2JoI9rzR5PWHBUYmKZIiGhGh1YfaMrYqWBV7L9CaJ5yhk6amUsX2r 7BqA== X-Gm-Message-State: AOAM531D4bTsxcHOVfQjqbcvXo5xidAi1LcYYqzXQynYjdKkwZ9UrJ9y 4HmyYwvvbjo7FxRgPSnUzc2/u8Q8bANVHw== X-Received: by 2002:a63:9d44:0:b0:374:a18a:17fa with SMTP id i65-20020a639d44000000b00374a18a17famr1198415pgd.293.1645684996377; Wed, 23 Feb 2022 22:43:16 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q13sm1873667pfj.44.2022.02.23.22.43.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 22:43:16 -0800 (PST) Date: Wed, 23 Feb 2022 22:43:15 -0800 From: Kees Cook To: Max Filippov Cc: Chris Zankel , Marc Zyngier , "open list:TENSILICA XTENSA PORT (xtensa)" , LKML , linux-hardening@vger.kernel.org Subject: Re: [PATCH] xtensa: Implement "current_stack_pointer" Message-ID: <202202232239.FF2343D42@keescook> References: <20220224060503.1856302-1-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 Wed, Feb 23, 2022 at 10:22:59PM -0800, Max Filippov wrote: > On Wed, Feb 23, 2022 at 10:05 PM Kees Cook wrote: > > > > To follow the existing per-arch conventions replace open-coded uses > > of asm "sp" as "current_stack_pointer". This will let it be used in > > non-arch places (like HARDENED_USERCOPY). > > > > Cc: Chris Zankel > > Cc: Max Filippov > > Cc: Marc Zyngier > > Cc: linux-xtensa@linux-xtensa.org > > Signed-off-by: Kees Cook > > --- > > arch/xtensa/Kconfig | 1 + > > arch/xtensa/include/asm/current.h | 2 ++ > > arch/xtensa/include/asm/stacktrace.h | 2 +- > > arch/xtensa/kernel/irq.c | 3 +-- > > 4 files changed, 5 insertions(+), 3 deletions(-) > > Acked-by: Max Filippov Thanks! And apologies, my cross-compiler tricked me into thinking this patch compiled without problems. It did, however. I've change the patch slightly to deal with the needed casts: diff --git a/arch/xtensa/include/asm/stacktrace.h b/arch/xtensa/include/asm/stacktrace.h index fe06e8ed162b..a85e785a6288 100644 --- a/arch/xtensa/include/asm/stacktrace.h +++ b/arch/xtensa/include/asm/stacktrace.h @@ -19,14 +19,14 @@ struct stackframe { static __always_inline unsigned long *stack_pointer(struct task_struct *task) { - unsigned long *sp; + unsigned long sp; if (!task || task == current) - __asm__ __volatile__ ("mov %0, a1\n" : "=a"(sp)); + sp = current_stack_pointer; else - sp = (unsigned long *)task->thread.sp; + sp = task->thread.sp; - return sp; + return (unsigned long *)sp; } void walk_stackframe(unsigned long *sp, Shall I send a v2, or just carry this fix in my tree? Sorry for the glitch! -Kees -- Kees Cook