Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4000003imu; Fri, 30 Nov 2018 09:16:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ug0TjaX5gi+34bPNbF5iauzK3TNkhPV52mur3qgWbf3pLr4QUt0vJGz8LwvscQL4GZu6Fb X-Received: by 2002:a17:902:6681:: with SMTP id e1-v6mr6346841plk.173.1543598185326; Fri, 30 Nov 2018 09:16:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543598185; cv=none; d=google.com; s=arc-20160816; b=tlVjmy6CkRFk9GTNM2417iNG7mFYWYmBR/fiq5oETsd1iYyWktbuaSGoHaeN469Lox f9FV4Dt4SH2rZZoX8q1zpCBZh3oDhxJJD2WVPQ3OJlSRzpWX3cBjzt7/Ckm1hCkPLn9b eOOun2qWib7CDl/dwNZImaaGbmmR9LnGJvqt4XUBeW+URfbILZ7Vdp+rrjzr3eXXJQbz 7o4f3omLoYW1WvLbQXElGFAq2lclDOcOAqAdAqj9WOmrmeA6cIbLwOwfXaiyWlQNVdgL vQ/erb39FxxFuZQjbOFKXQ9gtvw6QdQgLPY7OfW7OOhJh4EuKnaEY+9Y6CRbwiQZj/B8 niZA== 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=eA8RA4BMCo4J6Tj7FedpLFV8GAZ8Ue1y/wfOuYx7IRw=; b=LrHKI2ezqxW3ca0lWILrThLsjpBJdhM3wTGmZph9am1Pszmoffq+kTSS7pn/hVSk4h OEp0Ew3Q6WSEldTX2cwIKSXJuW6NOlCB7N0VWAsux/pU7T1kq1c0Xujv0isYQls7ZxN9 oqqbjjlWLhvIVbNeXJK5L2m4jaWntghzDf1bR/qivb6KYdamal9JoAjqtbz9w+vzxbqb AR+WWSRydNC1s5ddzjLqt93TsKK2/4juZCgog7ylx8NbVKjg++0WfH5i2kBLybfdqEQV rqD5BhURM5zvv8L+nbADokN/Afe2bchYlpV2t1qPwJfDtXs9PSo1626j/Zr+7fuAqsik dC4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nV05wTbR; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n33si4610717pgl.336.2018.11.30.09.15.59; Fri, 30 Nov 2018 09:16:25 -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=@chromium.org header.s=google header.b=nV05wTbR; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726991AbeLAEZC (ORCPT + 99 others); Fri, 30 Nov 2018 23:25:02 -0500 Received: from mail-yb1-f194.google.com ([209.85.219.194]:42981 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726659AbeLAEZB (ORCPT ); Fri, 30 Nov 2018 23:25:01 -0500 Received: by mail-yb1-f194.google.com with SMTP id s8so334769ybe.9 for ; Fri, 30 Nov 2018 09:15:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eA8RA4BMCo4J6Tj7FedpLFV8GAZ8Ue1y/wfOuYx7IRw=; b=nV05wTbR9GdI2h4En2tMC6ecY9fatk6N+XQPboTAptZvLo8XtMgte+MdmEMglze9Dt /y2dVXn4NidmLvTt6UE6aHbl2ZbMqht0r2NVBicchD71ylSLz4rzd1+Ldt0HqCr611C7 2TarH69sIG6gt1L5N0uVfc3y4G5guz1BelI3I= 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=eA8RA4BMCo4J6Tj7FedpLFV8GAZ8Ue1y/wfOuYx7IRw=; b=qR5CMqsFzDjYtqYgo2WIZuhMXsQyxwubJqjhlfkjNqdLh0/9jgxj6C9CU3o4uCA0i5 x19cLH3E1e8GD1XK1ITk8mzWbHZt8kBmplg5kRG2PWDW11uxlVXOCYeaMCEE69io+SPA PkJgbvqAzMDHGcOjq+t19eSDMH+lEWOK6+RJB+qRd3xkw0NPPaSQ2k+OIHbAnfn23F5a DkIdPT2ZOvHjnEfPY/Vj4ArmNFbTdAqWe7flqQ0gcyuowrombxHaxMd3ccQ0ToWHzFfz 5LR6+Gnb49THUDM9WVnAh6D3DKvTC6kCAnROC+oqZky8EGemzCDgbPWAywgeqpW2v5wx lEMA== X-Gm-Message-State: AA+aEWYBevOD06j+ezPxYe+HgK7NwzqbaR3Khc31Sar6BBCRDKUT6stm q71D9IUbV4KPgzs9eMd98VcpQH7P7yU= X-Received: by 2002:a25:3005:: with SMTP id w5-v6mr6241277ybw.365.1543598102314; Fri, 30 Nov 2018 09:15:02 -0800 (PST) Received: from mail-yw1-f54.google.com (mail-yw1-f54.google.com. [209.85.161.54]) by smtp.gmail.com with ESMTPSA id p201sm2050170ywe.45.2018.11.30.09.15.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 09:15:02 -0800 (PST) Received: by mail-yw1-f54.google.com with SMTP id h193so2561796ywc.4 for ; Fri, 30 Nov 2018 09:15:01 -0800 (PST) X-Received: by 2002:a81:2890:: with SMTP id o138mr6717118ywo.168.1543597754077; Fri, 30 Nov 2018 09:09:14 -0800 (PST) MIME-Version: 1.0 References: <1543583987-27948-1-git-send-email-alex.popov@linux.com> In-Reply-To: <1543583987-27948-1-git-send-email-alex.popov@linux.com> From: Kees Cook Date: Fri, 30 Nov 2018 09:09:02 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/1] stackleak: Register the 'stackleak_cleanup' pass before the 'mach' pass To: Alexander Popov Cc: Kernel Hardening , Jann Horn , Andy Lutomirski , Borislav Petkov , Thomas Gleixner , Dave Hansen , Steven Rostedt , Peter Zijlstra , Masami Hiramatsu , Florian Weimer , Richard Sandiford , Segher Boessenkool , amonakov@ispras.ru, Tycho Andersen , Laura Abbott , Mark Rutland , Emese Revfy , Thomas Garnier , Ingo Molnar , Will Deacon , Alexei Starovoitov , Ard Biesheuvel , "H. Peter Anvin" , "David S. Miller" , linux-arm-kernel , gcc@gcc.gnu.org, LKML 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 Fri, Nov 30, 2018 at 5:20 AM Alexander Popov wrote: > > Currently the 'stackleak_cleanup' pass deleting a CALL insn is executed > after the 'reload' pass. That allows gcc to do some weird optimization in > function prologues and epilogues, which are generated later [1]. > > Let's avoid that by registering the 'stackleak_cleanup' pass before > the 'mach' pass, which performs the machine dependent code transformations. > It's the moment when the stack frame size is final and function prologues > and epilogues are already generated. > > [1] https://www.openwall.com/lists/kernel-hardening/2018/11/23/2 > > Reported-by: kbuild test robot > Signed-off-by: Alexander Popov Thanks, applied! -Kees > --- > scripts/gcc-plugins/stackleak_plugin.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/scripts/gcc-plugins/stackleak_plugin.c b/scripts/gcc-plugins/stackleak_plugin.c > index 2f48da9..6f41b32 100644 > --- a/scripts/gcc-plugins/stackleak_plugin.c > +++ b/scripts/gcc-plugins/stackleak_plugin.c > @@ -363,10 +363,12 @@ __visible int plugin_init(struct plugin_name_args *plugin_info, > PASS_POS_INSERT_BEFORE); > > /* > - * The stackleak_cleanup pass should be executed after the > - * "reload" pass, when the stack frame size is final. > + * The stackleak_cleanup pass should be executed before the "mach" > + * pass, which performs the machine dependent code transformations. > + * It's the moment when the stack frame size is already final and > + * function prologues and epilogues are generated. > */ > - PASS_INFO(stackleak_cleanup, "reload", 1, PASS_POS_INSERT_AFTER); > + PASS_INFO(stackleak_cleanup, "mach", 1, PASS_POS_INSERT_BEFORE); > > if (!plugin_default_version_check(version, &gcc_version)) { > error(G_("incompatible gcc/plugin versions")); > -- > 2.7.4 > -- Kees Cook