Received: by 10.223.185.116 with SMTP id b49csp2299726wrg; Thu, 22 Feb 2018 11:23:12 -0800 (PST) X-Google-Smtp-Source: AH8x225vie7KvShXc6nTkES2S9wG71F7gL0qQW9suZvAznowACh4yzZA9g7lnmZCOdkSoiO2IVNJ X-Received: by 10.99.97.211 with SMTP id v202mr6458626pgb.193.1519327392225; Thu, 22 Feb 2018 11:23:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519327392; cv=none; d=google.com; s=arc-20160816; b=rrtskWeivX3nJh9LspdwzryTecCaaULAWVBb3+bYiTECHbxuS7FN2VP8051MAXN5s+ Z3o+nL0xQyIJ7tLMm5RF8lHlonxmystaQlXTrN2ufu+pkme9Ua1TeAyF7gM1OnVwtqPc sdQXV6zDwNJCDoVyN5yNHbEr2p4WhxV2R4YFsns7tFVy/qBejOMydSiL8KVJO9Qvbho0 c0Ke4lgpVEhJV0mnfxzuza5spPqnIVa5scclaCjb69G4EeWa6+vv7oBou5LrHSCwHHyR QQZOzYa/karSNIVf8zzemGLTFuyKxfSA3p+Z6tEK1U63pxo4KZkjw7mLZNK0F/50m7hY /NQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:reply-to :arc-authentication-results; bh=E1hqoSpvGH4ANSrwoSllXeCHrLXV3Fz097xijgTcsEg=; b=CUMXVssYIV96eIj0Knl7LrVw3P+g1sQfRQwSxo0kPipm5CDQWBqV3xDbLoeItE7NKe VCsFJP2fiGSOIJCJHFvcpRWBECv0530kXx6DZnUzJe5Wo0Olip6IV6BGwVAsjzgkUKfx 0AGs0pnuj+hD+0saJWJla8YMXHzjlmuvhhUTaoQ0+/5HJhrJLmy2ZSUTiNcXCSsfLl/X HfhdZ6YYs/FxfG3aHxnzW9jZ5WIRWbrLkSAndnm2oFh+JY4RsJNHdDMatgJ6j93IVOS/ 8R81RsFM33t3iBxw/on7VVjmAj2ObYBfVva/r9LYztzazEW9yj7hafIM66opQJK58e9J sN0A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t85si480712pfj.296.2018.02.22.11.22.57; Thu, 22 Feb 2018 11:23:12 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751296AbeBVTWS (ORCPT + 99 others); Thu, 22 Feb 2018 14:22:18 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:35457 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750805AbeBVTWR (ORCPT ); Thu, 22 Feb 2018 14:22:17 -0500 Received: by mail-lf0-f66.google.com with SMTP id 70so8984140lfw.2 for ; Thu, 22 Feb 2018 11:22:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=E1hqoSpvGH4ANSrwoSllXeCHrLXV3Fz097xijgTcsEg=; b=NuHUiKHqxmQvaoO/KBTyQvN/bg6lQNBeE5Ff0axCDb2x2wv+FcDNPCnV2EGvd2CMWc bRCW+PzFcAwpjpD7pp9Hi0blg26DBRMf7k1XTy6zQtTDRCRkJNVOOBb7WTNNEpKozo+U iFpw1uBjRJjiESXkkHC6WlXw5/RDjtp3aZy/X83r433SmSzWYiUIq+ftsVGB8/9/CkSa iLQwtOxDa8q+RKi08njv3oNK5AU56yIstF2inzEAW9dYMmnmkJpVBkzYiMSmZNA32zfg 9tF4nJ8BAmDIgBg7BgP3weKdqoxmwaK3GZBJTpqVVfPepVPZYRawnA2fpUegW7t7LQoL wpNw== X-Gm-Message-State: APf1xPA3JFdIMPF4x+lIwqFWSfAp/LYSwiyI3EHlgNjcWy2o8YmSMjmu PH4Y6Outr1CQXUkhKX0gl9g= X-Received: by 10.46.99.11 with SMTP id x11mr5970917ljb.136.1519327336285; Thu, 22 Feb 2018 11:22:16 -0800 (PST) Received: from [192.168.1.147] (128-68-176-249.broadband.corbina.ru. [128.68.176.249]) by smtp.gmail.com with ESMTPSA id f77sm141342lfe.68.2018.02.22.11.22.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Feb 2018 11:22:15 -0800 (PST) Reply-To: alex.popov@linux.com Subject: Re: [PATCH 1/2] stackleak: Update for arm64 To: Will Deacon , Laura Abbott Cc: Kees Cook , Mark Rutland , Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-hardening@lists.openwall.com, richard.sandiford@arm.com References: <20180221011303.20392-1-labbott@redhat.com> <20180221011303.20392-2-labbott@redhat.com> <20180222165834.GC18421@arm.com> From: Alexander Popov Message-ID: <97090ca6-efad-7c03-6084-a97674ae61c7@linux.com> Date: Thu, 22 Feb 2018 22:22:14 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180222165834.GC18421@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Will, Richard and GCC folks! On 22.02.2018 19:58, Will Deacon wrote: > On Tue, Feb 20, 2018 at 05:13:02PM -0800, Laura Abbott wrote: >> >> arm64 has another layer of indirection in the RTL. >> Account for this in the plugin. >> >> Signed-off-by: Laura Abbott >> --- >> scripts/gcc-plugins/stackleak_plugin.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/scripts/gcc-plugins/stackleak_plugin.c b/scripts/gcc-plugins/stackleak_plugin.c >> index 6fc991c98d8b..7dfaa027423f 100644 >> --- a/scripts/gcc-plugins/stackleak_plugin.c >> +++ b/scripts/gcc-plugins/stackleak_plugin.c >> @@ -244,6 +244,11 @@ static unsigned int stackleak_final_execute(void) >> * that insn. >> */ >> body = PATTERN(insn); >> + /* arm64 is different */ >> + if (GET_CODE(body) == PARALLEL) { >> + body = XEXP(body, 0); >> + body = XEXP(body, 0); >> + } > > Like most kernel developers, I don't know the first thing about GCC internals > so I asked our GCC team and Richard (CC'd) reckons this should be: > > if (GET_CODE(body) == PARALLEL) > body = XVECEXP(body, 0, 0); > > instead of the hunk above. Can you give that a go instead, please? Thanks a lot! Would you be so kind to take a look at the whole STACKLEAK plugin? http://www.openwall.com/lists/kernel-hardening/2018/02/16/4 https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?h=kspp/gcc-plugin/stackleak&id=57a0a6763b12e82dd462593d0f42be610e93cdc9 It's not very big. I documented it in detail. I would be really grateful for the review! Best regards, Alexander