Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1316475pxm; Thu, 24 Feb 2022 00:14:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwAY5Pbb842bX+WN+RTcK1id7KrzIzMK8f65D/WQ5LyA+LsvlBPrnVbcuNDSiY5SmHcG1oj X-Received: by 2002:a05:6402:1112:b0:413:3d99:f2d7 with SMTP id u18-20020a056402111200b004133d99f2d7mr1161398edv.23.1645690450064; Thu, 24 Feb 2022 00:14:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645690450; cv=none; d=google.com; s=arc-20160816; b=fy8rkZIKQf2rXicGRCMVtXcVy1sjf5YSbU79BwajqWc6HhruSaZjrZvH4lq2fUfbTP AVHdbBp+BO5YOWT5xDp5hQRhnowElmcYOw8gJHJXxZZJ/Oc/eV12+38k18quMt6xrA7k AjmFW3rFpwJH+yMjPAnJH2kkIOQrYoC1pn2y/wf9XIfT5hnEpKXR0YJmBciOtn4wrycC YjDkVF8J2bn1eX88MRNFOfHz5A1SP8p9SH2bFlgP9K/SPF1w1xLzRWOEuKKUMCGOVqEG jgYxYWHGLVOK2dxwNdADZlt5w9OCjLnMoKB72TpaQZdSFQOu6fafhKp6Tf0jbgDLx5lm fGDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Hypa21N0zanMgGLH9mohM/n3Ow6quteAnbWgQTT26/U=; b=AY9otar5uF7uAAW4r6uNxm24MQWVgFNwTbFQtGBzKLM7dBvdjT+QoM5eqLoTJMDb32 kEf2yQibuNcQePl93MWZXLubZFMSymcj8UoSfzJgLjGvAgOm/M6GC3B5rKg3+hX2aOuL 6kOEe++TWmge2MRCpgx4/3SuCbk2lc72+ySJMhFSxm57Oatj32s8Y22dBvC9bZL1sWe5 0KeiAImzHHdO2VqdSOERqwt/RrErDFLj3PXfXwPiZfDriO1C8cGwEmkFtafha/ikB9/f 8/jkmmHalQjJNYCCOU9g+1oCHqHrMRC4X4ZU/E1EhCuxymUF2Wbx2MhH+QGw4fXycwGd hOsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=H6U3HtHg; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a16si1063926edy.356.2022.02.24.00.13.47; Thu, 24 Feb 2022 00:14:10 -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=@gmail.com header.s=20210112 header.b=H6U3HtHg; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231398AbiBXG6p (ORCPT + 99 others); Thu, 24 Feb 2022 01:58:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229933AbiBXG6n (ORCPT ); Thu, 24 Feb 2022 01:58:43 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A80461BB71A; Wed, 23 Feb 2022 22:58:13 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id p15so2297284ejc.7; Wed, 23 Feb 2022 22:58:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Hypa21N0zanMgGLH9mohM/n3Ow6quteAnbWgQTT26/U=; b=H6U3HtHgGRz2L//QixHDUgzuArG/Q7+kUivaHj7KiwedSetjfLBSkg+h2yODOxyElI 2nhkXulqaF52wrQQiOntznuzVSzTy0oKqyqJPSGL6pX92K1EAeFnkhAWdPa+P98iSosV qFS/kzGWBiz/EAdAfNVuq9zH6rmIPb2mPpQy6w8InjS6mNBSkOzR3IflLdSup03kHmQn TaB+anImJVW97zxTA8LF+dtqNLs4BYb/9JN4d3Ac11A6qDEec6hsegEhM9sELv4IqwDO MRVXSigXngdZ/9Lt21XjcKCjs/rPQHSKWnRiWn2kIL+Fxm2AmvDExxgP/59rIFYc9Val 40AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Hypa21N0zanMgGLH9mohM/n3Ow6quteAnbWgQTT26/U=; b=nHSCPHXKrV4cAuddDkJZCdL1PNe/rslD2qj7RY3JsB8tydHiGcFJ03iKQuGSoZQg5k xUhR44xzuo57Z66UNPm8kGaBFWDND45iNSXNhC8TljchOCp9OFr+3j86fTAcdWCONu4d uNgQKo4XjL4B+H1Q61ypr3WIKkfODDH4n08muqIMNL59sI3mhKtiEJ6yGyQO7zvrS6CP gsMlIUMBXbIwvAaHPLRp7bH02hafBz9O16DZA1dyqAg7DxRaLk5jfSv2Y9OzmWhvppG5 EWIngIBa9PWjh3Or1AxSAMuvs8ATImawL7jU8gHaU1eC/kVVR0zBoVNkeYyzVJYQ+1x4 eb8Q== X-Gm-Message-State: AOAM532XoTOkmKm9rzLdvpFerRPIxe9nI4Z2a6JEI9JdBEOjQxygEaRV EcHobtGagImN5YZT/6sqRtHnMorXTIfnl5ge5wtVHR36 X-Received: by 2002:a17:907:3c12:b0:6cf:37d0:a551 with SMTP id gh18-20020a1709073c1200b006cf37d0a551mr1141531ejc.38.1645685892323; Wed, 23 Feb 2022 22:58:12 -0800 (PST) MIME-Version: 1.0 References: <20220224060503.1856302-1-keescook@chromium.org> <202202232239.FF2343D42@keescook> In-Reply-To: <202202232239.FF2343D42@keescook> From: Max Filippov Date: Wed, 23 Feb 2022 22:58:00 -0800 Message-ID: Subject: Re: [PATCH] xtensa: Implement "current_stack_pointer" To: Kees Cook Cc: Chris Zankel , Marc Zyngier , "open list:TENSILICA XTENSA PORT (xtensa)" , LKML , linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, FROM_LOCAL_NOVOWEL,HK_RANDOM_ENVFROM,HK_RANDOM_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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:43 PM Kees Cook wrote: > > 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? This additional change looks good to me, if you could fold it into the original patch that'd be perfect. But separate patch would also work. -- Thanks. -- Max