From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B66DC65BAF for ; Thu, 6 Dec 2018 15:13:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CEBD420989 for ; Thu, 6 Dec 2018 15:13:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MRXMyknO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CEBD420989 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=cba1mphr+a66RuSFsnM+H5jKKdrpRK3mDYDwyl+l6p0=; b=MRXMyknOCEeky8 QPmKzNUY8SMdjw4zoEPpJQnKpX/QuLWhCC+s3AAwI9Q6e5zdFz5ZNfpgcG4PTSpeWSAQWoQPQ3pN7 +hK0Bo6p2EqCJS35xMz5HL6py7HtT9qhHUsqrsF4Yv4oMNWWMpPOYY5x1PjFE4wGmx2X3Kift2/bq LGeHmKLCtCql8D8uGnOtqrFd0AjsOjO1AQpaDsUp++G3AMvAzSXDkjAC4Njxbb8jlCFvZ3954bK66 yO6NWR5qSX8rsTXAfmGB3Bgvn0qsiz9amtZnRXYFSTVhcdatlmFoOUOHRhpP+QYRkCdFlHBOjQrq2 EgXxU0Tk41EM+Vk1QxgA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUvLN-0005Cq-Fg; Thu, 06 Dec 2018 15:13:37 +0000 Received: from mail-lf1-f67.google.com ([209.85.167.67]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUvLH-0005Bz-Pu for linux-arm-kernel@lists.infradead.org; Thu, 06 Dec 2018 15:13:35 +0000 Received: by mail-lf1-f67.google.com with SMTP id f23so583544lfc.13 for ; Thu, 06 Dec 2018 07:13:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=Fe3/yqBpf9nSMtaMboYSUItlGt6aYnnhkmOZpRL34kY=; b=J/b3sILuKujwtHPq54PFd0N5jrjPMkpG2wjkAJo0MQKX7vXqFnCe31Jwyvb1ExeK10 6kPN0IrqXJL/7ps18hiwUjQi7hOYzUq/57ortwxPENvhyem0J4A+sv2w1kQ67c/bGt4M GOy2hrq7YM4lzD+5jKkX1Xtl9q69hdFZg1h3h2XObYd8PmCy6RiRJCCDF5/V0uUBy+5B AUtpTRNtbnSv7/z14MSX6uZ2uUSo7K50823gwr0YBw2bfYWMLbDA9AOXLkLmJNbsRR+u sRiIf++erbltRiMpS6QPj3qTPuGiC5GoveDLPfOX9j+yWBkInFFHJB9Aki5OfdE+ujUj 8Q8g== X-Gm-Message-State: AA+aEWYPM3BwTeg3FvN1H7miumMyXLvQpHYPdmmtml7QRPnmYPqybKOT Lxzj0sOPrrVxDLxYRVrUgMk= X-Google-Smtp-Source: AFSGD/UKqwvqngJ4zSOCF6af7JvT8zoH8dIIShluX5oZq/1xPpdDhagFHSIvHngV7rawyO9gEl2mTQ== X-Received: by 2002:a19:945b:: with SMTP id w88mr16333003lfd.15.1544109200176; Thu, 06 Dec 2018 07:13:20 -0800 (PST) Received: from localhost.localdomain ([213.87.131.37]) by smtp.gmail.com with ESMTPSA id h3sm115222lfb.49.2018.12.06.07.13.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Dec 2018 07:13:19 -0800 (PST) From: Alexander Popov To: kernel-hardening@lists.openwall.com, Kees Cook , Jann Horn , Andy Lutomirski , Borislav Petkov , Thomas Gleixner , Dave Hansen , Steven Rostedt , Peter Zijlstra , Masami Hiramatsu , Florian Weimer , Richard Sandiford , Segher Boessenkool , Alexander Monakov , 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@lists.infradead.org, gcc@gcc.gnu.org, alex.popov@linux.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/1] stackleak: Register the 'stackleak_cleanup' pass before the '*free_cfg' pass Date: Thu, 6 Dec 2018 18:13:07 +0300 Message-Id: <1544109187-13805-1-git-send-email-alex.popov@linux.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181206_071331_847799_5521BE0F X-CRM114-Status: GOOD ( 14.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 '*free_cfg' pass. It's the moment when the stack frame size is already final, function prologues and epilogues are generated, and the machine-dependent code transformations are not done. [1] https://www.openwall.com/lists/kernel-hardening/2018/11/23/2 Reported-by: kbuild test robot Signed-off-by: Alexander Popov --- 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..dbd3746 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 "*free_cfg" + * pass. It's the moment when the stack frame size is already final, + * function prologues and epilogues are generated, and the + * machine-dependent code transformations are not done. */ - PASS_INFO(stackleak_cleanup, "reload", 1, PASS_POS_INSERT_AFTER); + PASS_INFO(stackleak_cleanup, "*free_cfg", 1, PASS_POS_INSERT_BEFORE); if (!plugin_default_version_check(version, &gcc_version)) { error(G_("incompatible gcc/plugin versions")); -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel