Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1087200rwb; Fri, 18 Nov 2022 12:33:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf5qq5LrrE9k/8v9pcqWrTdBnk8SDjVD78NjjrVFp8Gu1h1xksycEfbLdkp8c2qaHTfvVxkW X-Received: by 2002:a17:902:e84d:b0:183:8006:3338 with SMTP id t13-20020a170902e84d00b0018380063338mr1085718plg.125.1668803581964; Fri, 18 Nov 2022 12:33:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668803581; cv=none; d=google.com; s=arc-20160816; b=UgYpS0B4+Boowa2JqXhfUs3ABpJTPrxx0Jk2HDi+adYC1qPmaJm2//jTRMzzQNcRUo 2b/lhpL0l30dLnno33swe8ZClvKdPZzaC+uAU+tSwRrU0VTo/TxSwYs+Iq02ffrlo/b/ JtqLQ4Z5C+x9T4859BoNCE2/c7C58bZjB1TYv/j/SgF4tHKCeHIgmQSkC20/wqI+aWWq a6l3JHKul9FB+bPuLGJ0ceZswJdRwehbmN5nXr9FzvVrQPzk2nIgCKtdGD3LcUQF68b9 zSVXzRbMSb7bF8GeOzzMaUnTiKKEp1lHed2XZk7dgDkVT+VYZ8pimsRvB91hndg7sQ2G X5ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=vZwGHNcQb0fQL0dIXVfO9Z/ROsXVh+NZri45yvzXL3A=; b=QhZl4DoD26nk1GoJ3rqc+sGNYRex8iPzmfexUXdiL39Q8d9KU/zU11kI/nNajRo7rd Jkthy5YQeCSVhhK6z5KDhg8M0p43aWmAIwbBaSDvggABirR3roUfi3hSBp/queoUcPme iRRthA1XmnMgbVcRuNdqXr0FzUrlJVXnfUVA8mxr89G9s4u19sSQKkzxyjIWdoRT9NS2 qEjxSX7mDsLbRW/9l6dWERv7ycY8a6mXO1Mha2b7iS3SsxaJ5VC2T+teIa/iMjNbSaNS f9x7ZAh/RorL+caGYWl3UVpTVSCgSwJxcr2CKtUCs+eDIJ94xQ6fBKGWix0mNShl2QJ/ ykcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=OVoFdFdQ; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u18-20020a627912000000b00547a857b7b3si4212466pfc.375.2022.11.18.12.32.43; Fri, 18 Nov 2022 12:33:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=OVoFdFdQ; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229933AbiKRU22 (ORCPT + 99 others); Fri, 18 Nov 2022 15:28:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbiKRU21 (ORCPT ); Fri, 18 Nov 2022 15:28:27 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C45E5250 for ; Fri, 18 Nov 2022 12:28:24 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id x2so8729062edd.2 for ; Fri, 18 Nov 2022 12:28:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=vZwGHNcQb0fQL0dIXVfO9Z/ROsXVh+NZri45yvzXL3A=; b=OVoFdFdQbkLGMmf+NMi3IyzgUaB2vBMEp5b5g6wg+bl/c5Dd9mSrKnyUTUMaBDt/OR vVOElPooUgIwzZeaiEciN6TNDy8PKBh6AXh+dDeWBPJI9hq/s+UkaiI/y59+HOdczAb9 r6RDTmwv8Gnxn6+Tef9wzmZJEZauIRCoPQBIW7dHzZFFloK5DzmwU2EfkTxXkWllikMq Kn93WBT2Iv52Z/G/FnzQmHhANwgOu5Vw47M90fGrHrJpQKxB9achWFUYc0CFtXV3BABU 21+2tvvQgas1dGyu6+FIFL/jXnm07b/jwf+6V6nG4zBvuCsLsIn7JrsmQjarjOIWJ2Bj k6HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vZwGHNcQb0fQL0dIXVfO9Z/ROsXVh+NZri45yvzXL3A=; b=5rZ0YYcCpdwubExHVDwTAbHAmwN3h5DbuHePz/ti/q2NcDwxAPd+oqfKn81Yhd5zCh a3aFjFNZSe2NVjEjIjU393y5XpC0YldrkR+gIXDooab53cq0XdAnA/fTxrWiv8rPohCR OzAj9Q9OgJlefh+lrDS41PTv7mw0PzndZ4+qaUMiZjXgGd7YqrdjyGylU0HSuEaV+vSY a88AcbQYyn/GxNAYGsvavEHz2MaJnY3PydkDjtz5KkZGq/Agbg0SyX8H5BiWccrYkcjD Y19KYAltH/OKhi2n/rQbdUg6XjWa76+or6xa7L1dbsWiEnzfzDMC0a5R+oYMKpx8mi1P 0AfA== X-Gm-Message-State: ANoB5pmLir2H0YJJj+2hL6/D3J3hKqMUFh+1kI0Tm4TP60vYlJlSeOb9 ysLEvyNCpOF8Dy4lV+pxJNtFgSmqNg+k1fvWsPIkttNJ3eg= X-Received: by 2002:a05:6402:3893:b0:461:b033:90ac with SMTP id fd19-20020a056402389300b00461b03390acmr5824070edb.257.1668803303099; Fri, 18 Nov 2022 12:28:23 -0800 (PST) MIME-Version: 1.0 References: <20221118194421.160414-1-ebiggers@kernel.org> <20221118194421.160414-9-ebiggers@kernel.org> In-Reply-To: From: Sami Tolvanen Date: Fri, 18 Nov 2022 12:27:46 -0800 Message-ID: Subject: Re: [PATCH v2 08/12] crypto: x86/sm4 - fix crash with CFI enabled To: Eric Biggers Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Fri, Nov 18, 2022 at 12:10 PM Eric Biggers wrote: > > On Fri, Nov 18, 2022 at 11:44:17AM -0800, Eric Biggers wrote: > > From: Eric Biggers > > > > sm4_aesni_avx_ctr_enc_blk8(), sm4_aesni_avx_cbc_dec_blk8(), > > sm4_aesni_avx_cfb_dec_blk8(), sm4_aesni_avx2_ctr_enc_blk16(), > > sm4_aesni_avx2_cbc_dec_blk16(), and sm4_aesni_avx2_cfb_dec_blk16() are > > called via indirect function calls. Therefore they need to use > > SYM_TYPED_FUNC_START instead of SYM_FUNC_START to cause their type > > hashes to be emitted when the kernel is built with CONFIG_CFI_CLANG=y. > > Otherwise, the code crashes with a CFI failure. > > > > (Or at least that should be the case. For some reason the CFI checks in > > sm4_avx_cbc_decrypt(), sm4_avx_cfb_decrypt(), and sm4_avx_ctr_crypt() > > are not always being generated, using current tip-of-tree clang. > > Anyway, this patch is a good idea anyway.) > > Sami, is it expected that a CFI check isn't being generated for the indirect > call to 'func' in sm4_avx_cbc_decrypt()? I'm using LLVM commit 4a7be42d922af0. If the compiler emits an indirect call, it should also emit a CFI check. What's the assembly code it generates here? Sami