From patchwork Fri Jun 8 09:53:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Vyukov X-Patchwork-Id: 10454043 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 43898601D4 for ; Fri, 8 Jun 2018 09:53:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BBC9294CD for ; Fri, 8 Jun 2018 09:53:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DBEA294D2; Fri, 8 Jun 2018 09:53:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73842294CD for ; Fri, 8 Jun 2018 09:53:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751549AbeFHJxt (ORCPT ); Fri, 8 Jun 2018 05:53:49 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:42116 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752950AbeFHJxq (ORCPT ); Fri, 8 Jun 2018 05:53:46 -0400 Received: by mail-wr0-f196.google.com with SMTP id w10-v6so12726728wrk.9 for ; Fri, 08 Jun 2018 02:53:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=c2ZwmVEZVhxU8xppUSGIEiVwJxWumN+BKMyTpnvJr30=; b=REinIPwiMxRNKjGnEk10k0eClauJrpS8byy117kyRejgUVweEeZj/xuIENOPDztqeC Oz9G2Re7p9Nz4VkzRSqI4TNzkVRUvwWo8lGwAHRdQ/lILMD4hemfc/6YJhM+VS6VKY7C Hf935+Q8wrewp0Eoes/Y9HA3N8NiZ7/1TwoGHTmwLMvrDV3/qe+eW8bpVXf/z50I/Jfe sdZ+oq5dhzdBrh9McWm671diaKn/1v5TuK1v58J974w+CGxXuxo2oaTUHoWvt1ypga0i 8FCXDs1tJk+W/u5mTR7X/5RuOZCfFNNsuPHNfx0kCLH721S9TRxt/2EB//yHWMvVbXNB 8uYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=c2ZwmVEZVhxU8xppUSGIEiVwJxWumN+BKMyTpnvJr30=; b=LusfD5AEa9MjWRcqTQ+BlHTmOHq94feJv3Co/CuMzoG0RAKgQBCBOAVQYktS6m3Sd2 BUu4oTg6PrQVxt9mip/xLBDyY03Luv4FT0KKDlnuzVp3WeOwZ5wVu81UbCqrY1yvGXHA sDB2fsbS2GlfkKbkMS4f8yrMdPbyTGjmvqXNOMIlDN1nhBNRCUH1GK5+6zAhY8zQcznd 0YBsSMQnDdxvAkaSyadmKJ93u0ORm0Agm2HYqRQvAw2N5Wzjm3oWWam2FX3HqiecHnhd OjBkCUH19MUbnS2BcyacHlCm6F7NLuuR1E5dys2MzdCgqP3gK+ioy37GMvkPNAgTqHCz I1PA== X-Gm-Message-State: APt69E3Oo2T2hlKyfTBt+cKYfAX+R1vWvLnJy8Cog5zUE0cOCgNeIEBD OJbsS2/hld192WDQFVfqCaf0og== X-Google-Smtp-Source: ADUXVKLN4guI8JygspzTpKsj6NCOpxkWxjBNfazAsCeyhEUypMczjPuuZqkadf6Q5tI3N97NSda+3w== X-Received: by 2002:adf:8ab9:: with SMTP id y54-v6mr4257056wry.98.1528451625311; Fri, 08 Jun 2018 02:53:45 -0700 (PDT) Received: from dvyukov-z840.muc.corp.google.com ([100.105.28.230]) by smtp.gmail.com with ESMTPSA id t14-v6sm3575818wrm.79.2018.06.08.02.53.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jun 2018 02:53:44 -0700 (PDT) Received: by dvyukov-z840.muc.corp.google.com (Postfix, from userid 129372) id 25F8AE0860; Fri, 8 Jun 2018 11:53:42 +0200 (CEST) From: Dmitry Vyukov To: herbert@gondor.apana.org.au, davem@davemloft.net, ard.biesheuvel@linaro.org Cc: Dmitry Vyukov , linux-crypto@vger.kernel.org Subject: [PATCH] crypto: don't optimize keccakf() Date: Fri, 8 Jun 2018 11:53:41 +0200 Message-Id: <20180608095341.92777-1-dvyukov@google.com> X-Mailer: git-send-email 2.18.0.rc1.242.g61856ae69a-goog Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP keccakf() is the only function in kernel that uses __optimize() macro. __optimize() breaks frame pointer unwinder as optimized code uses RBP, and amusingly this always lead to degraded performance as gcc does not inline across different optimizations levels, so keccakf() wasn't inlined into its callers and keccakf_round() wasn't inlined into keccakf(). Drop __optimize() to resolve both problems. Signed-off-by: Dmitry Vyukov Fixes: 83dee2ce1ae7 ("crypto: sha3-generic - rewrite KECCAK transform to help the compiler optimize") Reported-by: syzbot+37035ccfa9a0a017ffcf@syzkaller.appspotmail.com Reported-by: syzbot+e073e4740cfbb3ae200b@syzkaller.appspotmail.com Cc: linux-crypto@vger.kernel.org Cc: "David S. Miller" Cc: Herbert Xu Cc: Ard Biesheuvel Acked-by: Ard Biesheuvel --- crypto/sha3_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/sha3_generic.c b/crypto/sha3_generic.c index 264ec12c0b9c..7f6735d9003f 100644 --- a/crypto/sha3_generic.c +++ b/crypto/sha3_generic.c @@ -152,7 +152,7 @@ static SHA3_INLINE void keccakf_round(u64 st[25]) st[24] ^= bc[ 4]; } -static void __optimize("O3") keccakf(u64 st[25]) +static void keccakf(u64 st[25]) { int round;