Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2109351pxb; Fri, 29 Jan 2021 13:31:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJycXsRiUwyRPZ+KGr9DCeaUdAFAB44fEJiuTQlVYgYtyF1Gg89UmWY19CArPssGYvpx3W8c X-Received: by 2002:a17:906:dfd3:: with SMTP id jt19mr6452779ejc.64.1611955881751; Fri, 29 Jan 2021 13:31:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611955881; cv=none; d=google.com; s=arc-20160816; b=oXXOFbnMsZcP7OLTFiT94gfSn0VhDSS3ldvdnQJqdlJxAkOJ94x5GrIAOcR7pD1P9y wdLpFHYQEVBD9gAi/IhnU8afv6MUKYI7qV9WhuXpzlMGrsgI3Aqq8sNAlb4ArxAPa8IQ qnjVXxb3mLPNYz2MRjEAa82UN099Q0o8t9akc0UJ5pdBtuPjOGceR5qh2+Gy0StSO353 WFxZSSJZAYkPHEnM1inPmWp4isVA+3qU5JO/nNwFt4cqoN5kDwzBIKLb+sa6otXw58X9 HAnQO9T++3G+HbCiu0unWhKfWwKfjIl9oSNd4GQhA7kQvuUdsevPBlOoEI3x6/0AyMwi aBaQ== 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=tzQsONGruEyjt5Iym23vI9HLnucrCfyMF2lrfS7LSKo=; b=w0CseXw5I2NmlWS9FtCYHcY2UJ94KDL9HqU2QzSrz337bALTrbSsKfolUNJPszD7tD n0qSWIIOpfmjuzrlC6DHErBd5pYQDosdsgdpeYICuymXWSlevFk6/Ty4ceI8ghtjPuI4 Bnnv2oCnTBd2WV9xEx8MyYk++OcoPzzikaBdmTAtJIcrNGrH1WBKcEV8lIL2GZ1oSs9b +IBuyhfGoIGBsQFqEBpfo9n2qKViS8hhrMtCyO4ECM+iQbuSeTragOiZMPpKlbi4CxF3 uDvUMuyNQlOy3nUxTO8REmo6lUZ5/YjIrrXif+VfqhFZq61FZ2lFbdACsl7l7fEo98lL YTOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="dfFvPhN/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs12si5236073ejb.127.2021.01.29.13.30.57; Fri, 29 Jan 2021 13:31:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="dfFvPhN/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233484AbhA2VaY (ORCPT + 99 others); Fri, 29 Jan 2021 16:30:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233455AbhA2VaN (ORCPT ); Fri, 29 Jan 2021 16:30:13 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 843B1C0613D6 for ; Fri, 29 Jan 2021 13:29:32 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id e9so6033146plh.3 for ; Fri, 29 Jan 2021 13:29:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tzQsONGruEyjt5Iym23vI9HLnucrCfyMF2lrfS7LSKo=; b=dfFvPhN/zaDEnQjnsdzGUnt46hQnAerCAHB5gFqm0IBnwmpGrwbTmzVqeI0kzv2Mxz 1qh3wayCvSJiVuZRgBzDSiigh+I9pDuxZre2fAbeLPehMrb9TvMpL+/u4vl57JfVLG02 l7EVSXApCIktH25rMivtF8lrf9drTCAIgiIRh7HDa+mqat5fMR+CeaAsfz9qs6ekv2Zu cxe9XdLxOEUysnYGvahF1Z/K3Nn8eIh/h4ys2yKIQ4r+SnSVnGayvrYMUc3ku0bJnPmv q1sIDbRJCCmsi/j5O0mtio+Pl165XJIFtZQJuYFP38VRqVSh+ulyUt7KuxNyi5t23sJ+ hcSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tzQsONGruEyjt5Iym23vI9HLnucrCfyMF2lrfS7LSKo=; b=HygO0VnkllCxOcRKcr08Bv5+n+pm5ybPK7RXa0G0rylPoztcATTpiwrSoj3TzvyIbw Q/fK14fuMNM/IOj6/9PC30kB/gzj/dvO0puAT9adnST8umsea6cChuMdE7kde6W/WUEg 2WEjNG/E7VavFBNx6jlU3Xo2BXofxX4Apd8lXcZi5IPnhQT3GtpkZ0mfNWE2TqjnZyc/ dLLLMOcY/rFGSA24q9MRMyIwME5sA7H8uzcf7fZP6mdGErCtlkmRkCxoZHyVkjLtJDh8 DfN9Wou4ny+jGn+WfF6Hy7K6eJ4Dr4t/xXDLiFeCX68F6VpUvcUMKR4Ydg/nuEXXqpCf YQ4Q== X-Gm-Message-State: AOAM531lNY3EjUClgdxzVV2T/ybALiNSOWlr+QDPs0V1CUiRkrIq/p8J A92lg09t3FIPOhj6BYMxaxd9wE6QNJqRsgLtnSqxuQ== X-Received: by 2002:a17:902:760f:b029:df:e6bf:7e53 with SMTP id k15-20020a170902760fb02900dfe6bf7e53mr5997159pll.80.1611955771785; Fri, 29 Jan 2021 13:29:31 -0800 (PST) MIME-Version: 1.0 References: <20210125124533.101339-1-arnd@kernel.org> <202101271213.4F331332E@keescook> In-Reply-To: <202101271213.4F331332E@keescook> From: Brendan Higgins Date: Fri, 29 Jan 2021 13:29:20 -0800 Message-ID: Subject: Re: [RFC 0/3] kunit vs structleak To: Kees Cook Cc: Arnd Bergmann , Linux Kernel Mailing List , Arnd Bergmann , Shuah Khan , Geert Uytterhoeven , Alan Maguire , Dmitry Torokhov , Mika Westerberg , Vitor Massaru Iha , linux-hardening@vger.kernel.org, "open list:KERNEL SELFTEST FRAMEWORK" , KUnit Development Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 27, 2021 at 12:15 PM Kees Cook wrote: > > On Mon, Jan 25, 2021 at 01:45:25PM +0100, Arnd Bergmann wrote: > > From: Arnd Bergmann > > > > I ran into a couple of problems with kunit tests taking too much stack > > space, sometimes dangerously so. These the the three instances that > > cause an increase over the warning limit of some architectures: > > > > lib/bitfield_kunit.c:93:1: error: the frame size of 7440 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] > > drivers/base/test/property-entry-test.c:481:1: error: the frame size of 2640 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] > > drivers/thunderbolt/test.c:1529:1: error: the frame size of 1176 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] > > > > Ideally there should be a way to rewrite the kunit infrastructure > > that avoids the explosion of stack data when the structleak plugin > > is used. > > > > A rather drastic measure would be to use Kconfig logic to make > > the two options mutually exclusive. This would clearly work, but > > is probably not needed. > > > > As a simpler workaround, this disables the plugin for the three > > files in which the excessive stack usage was observed. > > > > Arnd > > > > Arnd Bergmann (3): > > bitfield: build kunit tests without structleak plugin > > drivers/base: build kunit tests without structleak plugin > > thunderbolt: build kunit tests without structleak plugin > > > > drivers/base/test/Makefile | 1 + > > drivers/thunderbolt/Makefile | 1 + > > lib/Makefile | 1 + > > 3 files changed, 3 insertions(+) > > I think I'd prefer centralizing the disabling, as done with the other > plugins, instead of sprinkling "open coded" command-line options around > the kernel's Makefiles. :) > > For example: > > > diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins > index 952e46876329..2d5009e3b593 100644 > --- a/scripts/Makefile.gcc-plugins > +++ b/scripts/Makefile.gcc-plugins > @@ -21,6 +21,10 @@ gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL) \ > += -fplugin-arg-structleak_plugin-byref-all > gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) \ > += -DSTRUCTLEAK_PLUGIN > +ifdef CONFIG_GCC_PLUGIN_STRUCTLEAK > + DISABLE_STRUCTLEAK_PLUGIN += -fplugin-arg-structleak_plugin-disable > +endif > +export DISABLE_STRUCTLEAK_PLUGIN > > gcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += randomize_layout_plugin.so > gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) \ > > > And then use DISABLE_STRUCTLEAK_PLUGIN. This looks fine to me. Does somebody want me to send this out as a patch? Don't want to steal anyone's thunder :-)