Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9931653ybi; Wed, 24 Jul 2019 12:33:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqbrN6wWzr45eOcst6GdKk9GYbOqX/EK/jYEeJReEu0qvdddiiRA3c7Uhq5JYonK9WThO9 X-Received: by 2002:a17:90a:db08:: with SMTP id g8mr86138422pjv.39.1563996792905; Wed, 24 Jul 2019 12:33:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563996792; cv=none; d=google.com; s=arc-20160816; b=Juq5S1ZqHeAL2XBgJa7MGfVvdHe4dMhkAdvXS/YuP7JH92J1jg1B/TrQH6SIwhan/D PxKwN27XUUo0e+ybJm9R40RerC9EDVclfz+CbFdtWKlqvUqfAhKc4JusMidfGvDFZGyk Ozj/jFfojYopof+VEU6Y80evMCOktzK07+/rEKB9PbIioY5+boqyCpIi3Lfj14Pakv9g dbuQLI4URa6hawPNUp7RBjyPEgp2Zv3hkhxYsMXfZ8q+TZiwfrZPjlX4JU8cBzHk53rq fv4OVgNSHjye2qMWsSZ8UDaV/8fcRJf+kCKF0YYARLX/sWISSZFyeVmhjUCes+PbeSOI HCZA== 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=+GFoj9DjRV3rU84pZjF6tDLkePn6OBq71iJ2IADzx40=; b=uY2GYwO9YMpxKtYoOpC78Cd9U1KrkU9hUuI6ozpypX+XOY3lKzq9/tRauO7z4H66O/ cc/yHvew8bdL3HpAUoZnTR1HZFE0618sohQtzxaBG0Av8sUiTfMyEVP59KcMeLv3H8ET ANsq7m1Fsx7+QmAioYqHrPhqBUrIZy59CUNpGHeDiSkAO0jgSj3uIuMoO+fMZdY3oy0k 4Mx5JujC+Uxob7jzM+qE2o3MeVc9kuU9sOejTLW04qw/U2RjQksSdrJeQOQc0Vgy/UV+ IXDeyK7aOd7KZFksVEqp+h7PGVM6TMyfMIQC8TTDvUNf8ZUEjbhyKj5JkGwCv1Sq8tc/ uoww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mscaT6l7; 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 q42si15048679pjc.103.2019.07.24.12.32.57; Wed, 24 Jul 2019 12:33:12 -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=mscaT6l7; 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 S2388469AbfGXTbV (ORCPT + 99 others); Wed, 24 Jul 2019 15:31:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:52114 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388459AbfGXTbS (ORCPT ); Wed, 24 Jul 2019 15:31:18 -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 4D8E5218EA; Wed, 24 Jul 2019 19:31:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996677; bh=FWreuhMM6Mt1r7S5lDbbQSWGpAelMHeB009HZa6gmmc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mscaT6l70CCYVbaaOhLk1Ja5w2WdP/D902cdIetBrjOWiNRFi9/F02yz3AhOS7eWO GJEQJMleZxbnHULg8tjawsXf6V7VP7ZFgHDeg+DBn9trmtZX5HZ32xIDG4YXRZMfcW 2VBTwuOw1iIwM6vaMsLTCHWEc9pNXL5jEHhOUGiw= 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 5.2 180/413] crypto: serpent - mark __serpent_setkey_sbox noinline Date: Wed, 24 Jul 2019 21:17:51 +0200 Message-Id: <20190724191747.711245129@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 16f612b6dbca..a9cc0b2aa0d6 100644 --- a/crypto/serpent_generic.c +++ b/crypto/serpent_generic.c @@ -225,7 +225,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