Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp675137rwl; Wed, 12 Apr 2023 02:24:03 -0700 (PDT) X-Google-Smtp-Source: AKy350ZuqDwFNEjwO/FpJn4oiMzRLK1q34zQgMdQqT73NrXfRZyVy9Xqa6ftj/APChcGBx8KoIqT X-Received: by 2002:a05:6a20:2a1f:b0:eb:69a:bdfc with SMTP id e31-20020a056a202a1f00b000eb069abdfcmr4797225pzh.50.1681291443018; Wed, 12 Apr 2023 02:24:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681291443; cv=none; d=google.com; s=arc-20160816; b=Dbujjnp9rZsbTSSNIwmcOHZaS5kFjgKPmHbIICnklr3JcvghoG8H3TpopE87zdUM3g Znj/xSJsi+hEg/mwgDYWOoYwTJSxIERnrHu4L4zH9K13h+EgRwDK54HHnyY7MAcq9Dff Wd8C7CgqseD/Mpi813Xyon5qV3Fnj692aScDkIxRbwTHQDeKQAqsC0BMk3nl6mgn7dPL 8yYYBZU0+yXffhjc/3QKTKaJq8GWd0MuEVO1fOvtCHU3x/6GFKrb8I0tVZxJATlbDqR0 BO6T/KKeBHwKqw2RZPSDDGABe4qXJCmUH19Xdz+TpXL331OlOnQhpPcdccYulTfhNFUo Ksfw== 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; bh=cIK/TR2iuAT3TDcpGfvHweIj+v9uljHJhbOxX8ZsMUg=; b=rYrL49dgg6GDjkAP5SJdl9T0vEB93EcYOk8yDHhCxaJZCpvGgeC8b3Y8qmParqxzEB 3zcac1M0hoHCu1sF8SI9tnqzfOUTVRplBeMHrXXkQrXRhZ+Yzws+RH1bBeSDjmaQ2AR7 pU9gpUiV8ZrQVGsR0J70itPVfXd3yH9Zc2lGSvhfmWzJYoMsRwjjnaT/ncLhgcCw3SQf zyA5BGJy5g6otfjs+vzgpBJgMENkN05At0vnZ+NqNxTUccZYKaLHoU7/rQtN3kyujeMh VqPxunwyaKZxibJlbxl27WuTgzxWATgGkRXmzHwY0zesWcm8Bj/B8Cqx9EJ36dcK9h+V 4zwQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o7-20020aa79787000000b0062880abbf43si15778027pfp.260.2023.04.12.02.23.51; Wed, 12 Apr 2023 02:24:02 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229712AbjDLJDz (ORCPT + 99 others); Wed, 12 Apr 2023 05:03:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbjDLJDx (ORCPT ); Wed, 12 Apr 2023 05:03:53 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 19CB35FE5 for ; Wed, 12 Apr 2023 02:03:50 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 16A12C14; Wed, 12 Apr 2023 02:04:34 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.21.3]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ACF793F587; Wed, 12 Apr 2023 02:03:48 -0700 (PDT) Date: Wed, 12 Apr 2023 10:03:46 +0100 From: Mark Rutland To: Heiko Carstens Cc: Kees Cook , Alexander Popov , Vasily Gorbik , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] stackleak: allow to specify arch specific stackleak poison function Message-ID: References: <20230405130841.1350565-1-hca@linux.ibm.com> <20230405130841.1350565-2-hca@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230405130841.1350565-2-hca@linux.ibm.com> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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, Apr 05, 2023 at 03:08:40PM +0200, Heiko Carstens wrote: > Factor out the code that fills the stack with the stackleak poison value > in order to allow architectures to provide a faster implementation. > > Acked-by: Vasily Gorbik > Signed-off-by: Heiko Carstens As on patch 2, it might be nicer to have a noinstr-safe memset64() and use that directly, but I don't have strong feelings either way, and I'll defer to Kees's judgement: Acked-by: Mark Rutland Thanks, Mark. > --- > kernel/stackleak.c | 17 +++++++++++++---- > 1 file changed, 13 insertions(+), 4 deletions(-) > > diff --git a/kernel/stackleak.c b/kernel/stackleak.c > index c2c33d2202e9..34c9d81eea94 100644 > --- a/kernel/stackleak.c > +++ b/kernel/stackleak.c > @@ -70,6 +70,18 @@ late_initcall(stackleak_sysctls_init); > #define skip_erasing() false > #endif /* CONFIG_STACKLEAK_RUNTIME_DISABLE */ > > +#ifndef __stackleak_poison > +static __always_inline void __stackleak_poison(unsigned long erase_low, > + unsigned long erase_high, > + unsigned long poison) > +{ > + while (erase_low < erase_high) { > + *(unsigned long *)erase_low = poison; > + erase_low += sizeof(unsigned long); > + } > +} > +#endif > + > static __always_inline void __stackleak_erase(bool on_task_stack) > { > const unsigned long task_stack_low = stackleak_task_low_bound(current); > @@ -101,10 +113,7 @@ static __always_inline void __stackleak_erase(bool on_task_stack) > else > erase_high = task_stack_high; > > - while (erase_low < erase_high) { > - *(unsigned long *)erase_low = STACKLEAK_POISON; > - erase_low += sizeof(unsigned long); > - } > + __stackleak_poison(erase_low, erase_high, STACKLEAK_POISON); > > /* Reset the 'lowest_stack' value for the next syscall */ > current->lowest_stack = task_stack_high; > -- > 2.37.2 >