Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3783864ybi; Mon, 29 Jul 2019 12:33:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5VDuugwC83Pfeu9na4fY9LpT1IwsOrrwcrlYCiwM7JPf9SkYBxndtDEt8D6pUHKZxczHR X-Received: by 2002:a63:5945:: with SMTP id j5mr105126605pgm.452.1564428790378; Mon, 29 Jul 2019 12:33:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564428790; cv=none; d=google.com; s=arc-20160816; b=BoVq34txsRHrcB7C3n3OAYogW2dH83vH1v9c9vGDPJVRsAmpKrDfqndZxOF9hennb2 bWo67DUx8U/suHTP4p9B3L53XBTbV1nDIcR85z7nwgedNvCoOaJrlxhorHg8o150oZvN 8srxphZStvYx29LOUmc2o2aJVZmWiG7UBYfRj+8nx3eq6lSVLW1dT4IzkSUrA73x2yBI nSvMpnLnFrQUakSdF/vOiiV+JPjQU0Vgjtqfl23lTHWSze2Ny5FPea21c4rtcYvrAe+F IwdfRmlr1BZFc/abxoPgPvrf82yLHlhujcpwFugUdVMDjw0od/6aAlC9V6vnnp9qvthb DQ0A== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MvfZp1sL2VuwOQaNKIC+al39ibbbZ9otm2qY0yr7rF4=; b=XtZsg2WYp677TfCVWJqgmjEPYa1zw3gIiy9VwcF7CV/6lbvoIPhr1sgLqPQXC4aOtI UV4ETQ0KtRZqMfK/soqzQeK+z52vWSF6nP+/xwoQvCyokeRXcEqK3cVsUfgZgs0XisR7 jMtK0jDDFEZeSe+A+7ZcaLFKMpVTvs+NRkzoi4AgEs9Nhr6ApDID5ocCD47hvVILB1n5 hFLammj+yGmE5C5EcskmQ2e0Rp7111Gcf1G4r2+ryg/2PD6AByMRNIZqBHo45b9eqAQn sh5sioCmlfbXGdeYK61KRsHZKZmz6nV/SCQjT5Y3w5r2jB3zv2Yn6WMFWLRCLJPSnuHZ PNbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eScyJa+R; 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 z62si28563401pgz.143.2019.07.29.12.32.55; Mon, 29 Jul 2019 12:33:10 -0700 (PDT) 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=@kernel.org header.s=default header.b=eScyJa+R; 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 S1728979AbfG2T1t (ORCPT + 99 others); Mon, 29 Jul 2019 15:27:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:40418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728887AbfG2T1r (ORCPT ); Mon, 29 Jul 2019 15:27:47 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 07871217D4; Mon, 29 Jul 2019 19:27:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428466; bh=6vHvRQBtyfYp/zt+ZKBcm/GfCCmNfiJ/IJqu3vk8oD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eScyJa+R2Ig64enViY6HqT5Y1CNNfsxwHUKM6gBkJYxwn2JDBKU9Ct2Mad3X6qDHD /Mf5og79BhpUrWk7CyRvBZeaS1zBx+rKwg4N99f+LIIMx4kR0kXng8o+s3odgNp4+a 3SuZNAuwHxL8eVGh0EMG5yFms2mUeY44hdjrhovQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Eric Biggers , Herbert Xu , Sasha Levin Subject: [PATCH 4.14 085/293] crypto: serpent - mark __serpent_setkey_sbox noinline Date: Mon, 29 Jul 2019 21:19:36 +0200 Message-Id: <20190729190831.114721209@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 473971187d6727609951858c63bf12b0307ef015 ] The same bug that gcc hit in the past is apparently now showing up with clang, which decides to inline __serpent_setkey_sbox: crypto/serpent_generic.c:268:5: error: stack frame size of 2112 bytes in function '__serpent_setkey' [-Werror,-Wframe-larger-than=] Marking it 'noinline' reduces the stack usage from 2112 bytes to 192 and 96 bytes, respectively, and seems to generate more useful object code. Fixes: c871c10e4ea7 ("crypto: serpent - improve __serpent_setkey with UBSAN") Signed-off-by: Arnd Bergmann Reviewed-by: Eric Biggers Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- crypto/serpent_generic.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crypto/serpent_generic.c b/crypto/serpent_generic.c index 7c3382facc82..600bd288881d 100644 --- a/crypto/serpent_generic.c +++ b/crypto/serpent_generic.c @@ -229,7 +229,13 @@ x4 ^= x2; \ }) -static void __serpent_setkey_sbox(u32 r0, u32 r1, u32 r2, u32 r3, u32 r4, u32 *k) +/* + * both gcc and clang have misoptimized this function in the past, + * producing horrible object code from spilling temporary variables + * on the stack. Forcing this part out of line avoids that. + */ +static noinline void __serpent_setkey_sbox(u32 r0, u32 r1, u32 r2, + u32 r3, u32 r4, u32 *k) { k += 100; S3(r3, r4, r0, r1, r2); store_and_load_keys(r1, r2, r4, r3, 28, 24); -- 2.20.1