Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10422193ybi; Wed, 24 Jul 2019 22:56:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXv1cUUagPH72juwcT0WWjfpsBS6x38muyJncb/drUOXNSQ3vqMZ4DCJ2lbv9p3oD8G/tC X-Received: by 2002:a62:7990:: with SMTP id u138mr14352639pfc.191.1564034218413; Wed, 24 Jul 2019 22:56:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564034218; cv=none; d=google.com; s=arc-20160816; b=i8AFnWhYdfU6dDL9b+2gKiZiboO0rB3LbJ3mK/rUkHTaQwOUYGa1ZzaZPoxYO8QJOV z4TGRLxP4ljV/HWGFPSOvHm0NSwJm4mJGbF8rF+f6Sc0r7Lel6JnOXlYpKEDAVFpUvg7 8LoqO3X67TsnrmTTfGzs3kNzMU+/XAkAFt74lqwpEXA4MB2nPnNTdxkpSJ8p5dxFmC6Q yA4dccrnG0duWgue2Yh3S3V9ZDMj1fIWrNJwE6Pbk+xywBNwAOdq3un0j/6r2AXIKO7e VUOlgPw9S2igWWNTF3fn+sAH7feQ5pttHF1jmEE6ybG3oY3kHiopswZhF4QgVHnOK+fK cYlQ== 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=TXKysCVoOkG04Gc6xeECa5YEErKdB/QQlWIcTBbx1OYOlfctWdCKQG1ftDC5JBkql9 78hQwxcw7dBWnZ7Sr/IlsoFpTnBfHk3qRtqLGuM0XDi3wUCetMR3juA2OX74NKuc9Nyo oYqbNA5E2WgjWFjISdeemkMBrGxGnHnqREToGvYzCnH3EAEZpX4LWYA8IIB1dUrFpx+N Hby/p8fcoSBpM481+U3k4kAr6luS5Cgp1WVEsTYqhqqqOliL/dpPCjJp+yE9wnXh2irf km/2f2dgy3ZtE1iQhZUBDu/HoCwW/oKpqh5QKe8c/dNo9GsDw0rQzuK7Glq712RVLG/z yfdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DO+H+CKO; 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 c13si15413055pfr.36.2019.07.24.22.56.43; Wed, 24 Jul 2019 22:56:58 -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=DO+H+CKO; 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 S2404191AbfGYFjw (ORCPT + 99 others); Thu, 25 Jul 2019 01:39:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:54118 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404156AbfGYFjt (ORCPT ); Thu, 25 Jul 2019 01:39:49 -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 9670922BF3; Thu, 25 Jul 2019 05:39:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033188; bh=6vHvRQBtyfYp/zt+ZKBcm/GfCCmNfiJ/IJqu3vk8oD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DO+H+CKOWqhTjWeemV1w3loGNfRVKhU24xcq6k834tkDr+jln96FMf7gm1c3P+Zyg SCZKshGo1JzfsZoniGij1S/Zof7KKnKSOrVZwLP+94t2K/w/WgxobhWEDE/XnGvKKp 80/3UtgYuOzDoShve8RKih+JPs9/sTwzS+cqG7QA= 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.19 120/271] crypto: serpent - mark __serpent_setkey_sbox noinline Date: Wed, 24 Jul 2019 21:19:49 +0200 Message-Id: <20190724191705.563020760@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@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