Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp1047768imb; Sat, 2 Mar 2019 01:05:53 -0800 (PST) X-Google-Smtp-Source: APXvYqxOXeDq4QxV2XPHFp2qjsoLselpAY4pSmgZ7VkdeTfKuQ77pX6Z+HyYJ2HB13W4x/QBVjx/ X-Received: by 2002:a63:2d43:: with SMTP id t64mr8962125pgt.155.1551517553755; Sat, 02 Mar 2019 01:05:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551517553; cv=none; d=google.com; s=arc-20160816; b=W8yNzqZwQ8Itep+p9vThc/TmeY+W71aOUQZc/1/8jYmNAR4KMqgG4nZNiGMcwmHbrH ZaZ1+tHd8GGT7egmsM0GGMUsS7L6ryGwJxvCeJa+Sy7x48C1sC634GV1bkPN7Sxed+Y+ WjrIfbKCTAWVLxJeIG1YY6WE8Jsl37SzayJ3DEkCdQ/KCwJaenutMP8X4+w9vu5Sp+35 IIdmw6wUKgKBtA8LkMfdRZutLev7VvraRmCmxLeQuumGpgPxYbTbxh2t+mSpJykNoVPf hsulCnNngt1OrbIRWc8bdwCLXSjhd8luof4Yhpz33q3t6BRKQilIcEAairAoHmQ2Fb06 JHlA== 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=NAvkCRQePpvlokHlpGhy/8CGCcGTFNt7ygGtzz6KllQ=; b=D1F1Xz5fMnY1SDNHDGUVNq+JSnsE7ircEV6Vib1bf6H03tMPa+1ib9YG1m/ZALBo0N 9l+yjbs5BGPwtN9Ryl0DegbchbDWmtqbv6TkI8I2z9O8Ko9ooLCZM14HVKDBV5FNIqEI nqKN1IsJJYyiGR56yA5q6lttKvBRbIp975iFMWCxALvzfy9yqD0/SjyzPbWPtnAhVsYk rMJrHgzNdbGwQl0IgbDnxjvJ2Zd4ODMHXUNCisv3tTnEelx+Bn+klKdxMp0pbDMxUYtY 1QnO2i9E78gI4jQAhmklfQQMuWmjU6dpFcdftLThf/TzXc0meQZIPgVw4O8TbhGUvWQ1 Z9uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mVAvkNwz; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2si295718pgp.60.2019.03.02.01.05.37; Sat, 02 Mar 2019 01:05:53 -0800 (PST) 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=@linaro.org header.s=google header.b=mVAvkNwz; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726114AbfCBJFK (ORCPT + 99 others); Sat, 2 Mar 2019 04:05:10 -0500 Received: from mail-io1-f65.google.com ([209.85.166.65]:36889 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725986AbfCBJFK (ORCPT ); Sat, 2 Mar 2019 04:05:10 -0500 Received: by mail-io1-f65.google.com with SMTP id v10so240201iop.4 for ; Sat, 02 Mar 2019 01:05:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NAvkCRQePpvlokHlpGhy/8CGCcGTFNt7ygGtzz6KllQ=; b=mVAvkNwzDoT26/8N3Z0DJy8UP7RV5I1yKvOrAJWxGXSwyr+VA4o6iEXuhSS6adc+59 WFR7/hIzvR9TOQrOYDVc1/Q84pQP4jZyvBvLkeZBMsVCgKwvJwU7Q4eo2/R37PQ8Lw13 Zt5rb/CXUvPmhfPmQB3dgk2rOfHmPcMP1iEXqD/ROcq9oJVXqhJOjnX8I0HS1QiImgcu kQ5/w8ZnKHATNnicAuRqYVF3fl3a8So6C8jnnWN9n3w0ROZzHHOFduHWQSjMID7TrmiC Ha/7XVx0amMP+nsIpS2AJq48cWBv7Udn+k5NGmmKW0ztKJIPqHWziqEeqsT9sKFlwjSL b9gw== 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=NAvkCRQePpvlokHlpGhy/8CGCcGTFNt7ygGtzz6KllQ=; b=ZqBL+4RvS5azMyUS+LLHk961bLE7tnxrEYugXdYBp2ewhTGAolgBHo36NwdVpSJLV0 zZGDEINqQKVWEQLooGWBY6sXtzFTRRvdUYILKCFFHMZO1kCNF8C4cf1zmLphz27g+cBx yZOA+uOjvWTLoN3HLquA3dy3PiYO2yx2yG4jM5ybrUJYOUR4GL+KqG8+8t3+DxTZa0Zk ujcZrqYFvLjhfkgjEuEtlyHWyDJdowZ04c34MscSV5gMuE+PSPSeBfB6up7K3fRwwKjl lsqhMmsnW7+76WxSq0Kfw1OpML+JXbuNkco+fTmarI0Qr2GyLo0s1zRAfRUuTDT+LkyB DTsA== X-Gm-Message-State: APjAAAW10VkRPpO0bOd0iW/wrbttipkXZO162xSC6WOs1ry13Blt7LFW swcn6/99otYlcssqc2GAO0Z5e3rv+7nJhMwemjiVUw== X-Received: by 2002:a6b:6511:: with SMTP id z17mr1776944iob.173.1551517508781; Sat, 02 Mar 2019 01:05:08 -0800 (PST) MIME-Version: 1.0 References: <20190212180441.15340-1-keescook@chromium.org> <20190212180441.15340-2-keescook@chromium.org> In-Reply-To: From: Ard Biesheuvel Date: Sat, 2 Mar 2019 10:04:56 +0100 Message-ID: Subject: Re: [PATCH 1/2] gcc-plugins: structleak: Generalize to all variable types To: Arnd Bergmann Cc: Kees Cook , Linux Kernel Mailing List , Emese Revfy , Alexander Popov , Laura Abbott , Jann Horn , Alexander Potapenko , Kernel Hardening 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 On Thu, 28 Feb 2019 at 21:27, Arnd Bergmann wrote: > > On Tue, Feb 12, 2019 at 7:08 PM Kees Cook wrote: > > > > This adjusts structleak to also work with non-struct types when they > > are passed by reference, since those variables may leak just like > > anything else. This is exposed via an improved set of Kconfig options. > > (This does mean structleak is slightly misnamed now.) > > > > Building with CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL should give the > > kernel complete initialization coverage of all stack variables passed > > by reference, including padding (see lib/test_stackinit.c). > > > > Using CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE to count added initializations > > under defconfig: > > > > ..._BYREF: 5945 added initializations > > ..._BYREF_ALL: 16606 added initializations > > > > There is virtually no change to text+data size (both have less than 0.05% > > growth): > > I just resumed my randconfig build testing after a longer break, and found > a regression for stack usage that I bisected to your change. It shows up in a > variety of files depending on the configuration, so far the worst one is the > configuration at https://pastebin.com/UK54qbKa that leads to > > ../drivers/media/dvb-frontends/stv090x.c: In function 'stv090x_start_search': > ../drivers/media/dvb-frontends/stv090x.c:1595:1: error: the frame size > of 5320 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] > ../drivers/media/dvb-frontends/stv090x.c: In function 'stv090x_optimize_track': > ../drivers/media/dvb-frontends/stv090x.c:3090:1: error: the frame size > of 5872 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] > ../drivers/media/dvb-frontends/stv090x.c: In function 'stv090x_algo': > ../drivers/media/dvb-frontends/stv090x.c:3431:1: error: the frame size > of 5144 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] > } > > At least for this specific file, I also see a significant (though not alarming) > increase in code size: > > text data bss dec hex filename > 179196 4632 256 184084 2cf14 > obj-x86/drivers/media/dvb-frontends/stv090x-before.o > 216740 4632 256 221628 361bc > obj-x86/drivers/media/dvb-frontends/stv090x-after.o > > Part of the problem here is definitely interaction with the asan-stack > sanitizer. Changing asan-stack=1 to asan-stack=0, it looks a lot > better: > > ../drivers/media/dvb-frontends/stv090x.c: In function 'stv090x_start_search': > ../drivers/media/dvb-frontends/stv090x.c:1595:1: warning: the frame > size of 120 bytes is larger than 20 bytes [-Wframe-larger-than=] > ../drivers/media/dvb-frontends/stv090x.c: In function 'stv090x_optimize_track': > ../drivers/media/dvb-frontends/stv090x.c:3090:1: warning: the frame > size of 168 bytes is larger than 20 bytes [-Wframe-larger-than=] > ../drivers/media/dvb-frontends/stv090x.c: In function 'stv090x_algo': > ../drivers/media/dvb-frontends/stv090x.c:3431:1: warning: the frame > size of 192 bytes is larger than 20 bytes [-Wframe-larger-than=] > > text data bss dec hex filename > 184061 4632 256 188949 2e215 > obj-x86/drivers/media/dvb-frontends/stv090x.o > > I get similar results with asan-stack=1 but without your plugin, only > the combination of the two has the explosive stack size growth. > > I can help analyze this further, but maybe you can have a look first, > there might be something obvious when you read the input to the > plugin. > Is this before or after use-after-scope was disabled entirely?