Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp14500imm; Thu, 20 Sep 2018 17:12:20 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYmCAHOoAqglJKMGXBzZjlrXdYFhGCVGUquXo81xjKA2zMHJdqwyyhYFr/Nf2pZ5DjTLlq9 X-Received: by 2002:a17:902:bd04:: with SMTP id p4-v6mr41991347pls.105.1537488740603; Thu, 20 Sep 2018 17:12:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537488740; cv=none; d=google.com; s=arc-20160816; b=BnJPFqRIzDDfr9kt++AzfYM/fKGwi1fnAeQ17ASJucMoW6lLASXCE29MYgqXZQ3woA k5fO/3FHlAbR9c/wd8+OTHqmkP/FVhDHcrqHAUC4YT6/ORTfM7X5vSTbnRhZNNxJCeK4 NKh3hRVemGP2MuKXsZHB9VjfvWAku1U1tFNITaEkbZdPS0KiUnRQPTYQUZpAX40IbQqR /+GS/1LszCrvh0q8DNimVGbAd00hLnuHL/2+gBxpNcAb2PeLFdsCMbVOqRJ6UzJKsiES 4eYrDRInYSLDiMXBGzjB9lz41nkKC4odrZmP+1qLIn8av02QQxqWCNcGsv9ORgAR5x3T 7C5A== 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=7q+mfWos2fm/mqT+TMeYxtCCzFu1H3P5iHlXk/lRbDs=; b=DEN4MCP1HAM9AKbxQ2Rm+yrLYlcZJr6m+Zl0bqRtjhMAdbJP4+Rdly32ezA1D5jVrL CwFKexhxOOr688JsZS6104KNr5fPGOvmGtNlgz5j0KG7YWi6pOoEFVcSEcF9asHND6vY MuWLJ96Z7zM98Qb/FFeqYD5py+TCxcIKPbxrmX9rt9y5iQKjaX/Xtsv0ZQudCQMwjU7r kqTJK8h1AwO1P2xmwFF8Mlvdccq6qoGTRko08YoPdcrGJoyZIEKVqiRpdCUu5zxdFfjU zr/HKcaOGTfZNZ9hTEYsb80UHgvJh4JwrW0bXPb/yTUJz2jGvVIKSXuhum84gPSrAufn 3L7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b="ldyGK/3y"; 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=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k5-v6si28011900pfk.2.2018.09.20.17.12.05; Thu, 20 Sep 2018 17:12:20 -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; dkim=pass header.i=@zx2c4.com header.s=mail header.b="ldyGK/3y"; 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=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388764AbeIUF6E (ORCPT + 99 others); Fri, 21 Sep 2018 01:58:04 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:57769 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725794AbeIUF6E (ORCPT ); Fri, 21 Sep 2018 01:58:04 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id d94cd457; Thu, 20 Sep 2018 23:54:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :references:in-reply-to:from:date:message-id:subject:to:cc :content-type; s=mail; bh=68QzLuBMy3Wmpn8zaTvNKarwaok=; b=ldyGK/ 3y2o5/1+tFiI573cT958zqOf4fI49Z/KHjwyuCf/3V1mI/pKs7cHtg4hSZdlK+KM SGzWPnb+OX/u4QTIHN3fiTQr8n6mjmKKdASmrhkX2g3DYH0E9LYylQmYTDevrKTR g3f8Suh3g3C1BlWiBaOdhL/98mem93Foww6qjIq50FS9Q68QZztuWst/zHgAEgcs l9vdiYvdghzMvybKaizt3zy9gv6VCtUlIWdG8PqxXasvoaMw4NHqJ2DBzS7dqfO5 E2/EFwGnAueLeNxAVCANnbyPxYDtKyZMJFe5uyWr8P60vuvACTm+OF02jcq4gAea sx/bEex/RSnI43Lg== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 2e0b2dbc (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128:NO); Thu, 20 Sep 2018 23:54:04 +0000 (UTC) Received: by mail-ot1-f52.google.com with SMTP id 36-v6so11280492oth.11; Thu, 20 Sep 2018 17:11:55 -0700 (PDT) X-Gm-Message-State: APzg51Df7+ctAifO2mXfz7r0rvmlGUSTzIBNPqFZBS/TlEyopTxowlrh NDGx/qPR1++N+cbVyi9GaXro9dLw3Qk3fv0DS0o= X-Received: by 2002:a9d:56b6:: with SMTP id o51-v6mr22536761oth.393.1537488714434; Thu, 20 Sep 2018 17:11:54 -0700 (PDT) MIME-Version: 1.0 References: <20180918161646.19105-1-Jason@zx2c4.com> <20180918161646.19105-3-Jason@zx2c4.com> In-Reply-To: From: "Jason A. Donenfeld" Date: Fri, 21 Sep 2018 02:11:43 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH net-next v5 02/20] zinc: introduce minimal cryptography library To: Arnd Bergmann Cc: Ard Biesheuvel , Eric Biggers , LKML , Netdev , Linux Crypto Mailing List , David Miller , Greg Kroah-Hartman , Samuel Neves , Andrew Lutomirski , Jean-Philippe Aumasson 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 Hey Arnd, On Thu, Sep 20, 2018 at 6:02 PM Arnd Bergmann wrote: > Right, if you hit a stack requirement like this, it's usually the compiler > doing something bad, not just using too much stack but also generating > rather slow object code in the process. It's better to fix the bug by > optimizing the code to not spill registers to the stack. > > In the long run, I'd like to reduce the stack frame size further, so > best assume that anything over 1024 bytes (on 32-bit) or 1280 bytes > (on 64-bit) is a bug in the code, and stay below that. > > For prototyping, you can just mark the broken functions individually > by setting the warning limit for a specific function that is known to > be misoptimized by the compiler (with a comment about which compiler > and architectures are affected), but not override the limit for the > entire file. Thanks for the explanation. Fortunately in my case, the issues were trivially fixable to get it under 1024/1280. (By the way, why does 64-bit have a slightly larger stack frame? To account for 32 pointers taking double the space or something?) That will be rectified in v6. There is one exception though: sometimes KASAN bloats the frame on 64-bit compiles. How would you feel about me adding 'ccflags-$(CONFIG_KASAN) += -Wframe-larger-than=16384' in my makefile? I'm not remotely close to reaching that limit (it's just a tiny bit over 1280), but it does seem like telling gcc to quiet down about stack frames when KASAN is being used might make sense. Alternatively, I see the defaults for FRAME_WARN are: config FRAME_WARN int "Warn for stack frames larger than (needs gcc 4.4)" range 0 8192 default 3072 if KASAN_EXTRA default 2048 if GCC_PLUGIN_LATENT_ENTROPY default 1280 if (!64BIT && PARISC) default 1024 if (!64BIT && !PARISC) default 2048 if 64BIT What about changing that KASAN_EXTRA into just KASAN? This seems cleanest; I'll send a patch for it. On the other hand, this KASAN behavior is only observable on 64-bit systems when I force it to be 1280, whereas the default is still 2048, so probably this isn't a problem *now* for this patchset. But it is something to think about for down the road when you lower the default frame. Regards, Jason