Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1155582pxb; Fri, 21 Jan 2022 11:02:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwhXMlpPxV/m5HhbB8emKXo11/m9V3Db6tpB1FgdV4jQ16GNa1ex2a2H15kxjSz8yVlv2HK X-Received: by 2002:a17:90a:ae15:: with SMTP id t21mr2053234pjq.147.1642791764766; Fri, 21 Jan 2022 11:02:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642791764; cv=none; d=google.com; s=arc-20160816; b=qqp6dI8LvWv8ojd4eXoEHxSlsX39h/pf1QbpjLFicrG2rtkCIMpZm92ZiBSfH64n5l QG1BR5W49LJMXMtueTKCHJ5nqAaDe8GGabqgtG38l2BBN2RInquAIuAgZknx/eTtSjso ZET9G4lb8zN6lG6EY3kpmRh7Xe57AI4sxJuXNCUV/MJWLbVOL4r1qkW4HR0vyoNppquI w7bgLvIw3TWX/N2yyN94SdXAPYSmd2G+FvexbAqWbJMSbMQZZGPvwGtdFDFqQFtpGI5Y kHfgVMNLn5WHq49aSOOLkFJYN+mqxSbkU3sEztHq7GUd4flMRxI47vKCotqKZmFPa65P Cv3g== 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=tuTL/kxFOhaGgngpykki6krTkzeUwuGFFqpWpfMnJHU=; b=UhbNVov2JwY9qjXvjRjwr6XTy9VlayG7xDblPUHF3k1bsCQosk3ZkzAoBynus4iyfh vU1pWv5gLI4UWneGxpYtMc+2AIv00s2zv6DIJ2TOl6PTBM60CfQkQqD4E83Ep11a7DpD cb3LJLyD94P4hQVMF5lghK6dk9tL59vK0N2Rr6Tb+bg7vdT8bcR+A5AxAoNZs5BQENjL UMYnW3BMXebBKFOPQh3e116mWFRPhSg2ikbaMPhh5S1DWzQiT7T6hAGRqQHM97tAPZIT uCfkUAZZmJsExAReX6qDwnjvICNK017TNhW+l3bH4scjPkxzZxUMP3u89wat2KUEP6ZP gtZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ak4X7XB7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r10si6214519plo.33.2022.01.21.11.02.32; Fri, 21 Jan 2022 11:02:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ak4X7XB7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352563AbiASJKT (ORCPT + 99 others); Wed, 19 Jan 2022 04:10:19 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:40662 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352746AbiASJKP (ORCPT ); Wed, 19 Jan 2022 04:10:15 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A7BA9614F1; Wed, 19 Jan 2022 09:10:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CC70C340E6; Wed, 19 Jan 2022 09:10:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642583414; bh=WDNHgCq1Sifyl65SzNP7dhJXzUA+KcGSqB1STBpal/o=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ak4X7XB7uZSGxPLHzqT/QXn42qKgsLVbs8uG+kewTlvVrlDl92zFFe4y58KwWDLHT f44qHyq5PPPHZeeUaP9l6bFhkZ0KYdEgrfaItVstIwMLINaFygpYqzP2EhtEHEOEwu il87cFjjgMG738RjYKKmF8wFOk0h/rYUErjNFc6R71BKzZrrEJ0Ez6VusIKV+gGzA1 h0ePyVKLFxET5XWPSQDkiyK36hYZ6nktY37PR3iBWeRUkwIkN5n9CzsaLCNPCesZ7q hHvpNi3va5mgodYDODW60+y0to9IqOGRGZaXgMNkTfAeJ/9pqwBJLXJf316Gd7U8Ss 1uEUJ/JwmByBQ== Received: by mail-wm1-f45.google.com with SMTP id l12-20020a7bc34c000000b003467c58cbdfso12791200wmj.2; Wed, 19 Jan 2022 01:10:14 -0800 (PST) X-Gm-Message-State: AOAM530qmRy5d8UXCpFyn1Jc6XVWwz5wWS/bTTZtDOgZowGA8vhIwqBN 9dIN+wbJzBurx1Tj9CxZilnak0DaKsaRxvY2LfI= X-Received: by 2002:a5d:4087:: with SMTP id o7mr27561730wrp.189.1642583412437; Wed, 19 Jan 2022 01:10:12 -0800 (PST) MIME-Version: 1.0 References: <20220119082447.1675-1-miles.chen@mediatek.com> In-Reply-To: From: Ard Biesheuvel Date: Wed, 19 Jan 2022 10:09:59 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] lib/crypto: blake2s: fix a CFI failure To: "Jason A. Donenfeld" Cc: =?UTF-8?B?TWlsZXMgQ2hlbiAo6Zmz5rCR5qi6KQ==?= , Herbert Xu , "David S. Miller" , Matthias Brugger , Greg Kroah-Hartman , Linux Crypto Mailing List , Linux Kernel Mailing List , Linux ARM , linux-mediatek@lists.infradead.org, Eric Biggers , Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (+ Sami, Eric) On Wed, 19 Jan 2022 at 10:00, Jason A. Donenfeld wrote: > > Hi Miles, > > Thanks for the patch. Could you let me know which architecture and > compiler this was broken on? If I had to guess, I'd wager arm32, and > you hit this by enabling optimized blake2s? > > If so, I'm not sure the problem is with weak symbols. Why should CFI > break weak symbols? Rather, perhaps the issue is that the function is > defined in blake2s-core.S? Are there some CFI macros we need for that > definition? > We should try to understand why CFI thinks the prototypes of the two symbols are different. There are still a number of issues with CFI, so papering over them by reverting stuff that we want for good reasons is not the way to go imo. In the short term, you can work around it by avoiding the indirect call to blake2s_compress, e.g., diff --git a/lib/crypto/blake2s.c b/lib/crypto/blake2s.c index 93f2ae051370..fef2ff678431 100644 --- a/lib/crypto/blake2s.c +++ b/lib/crypto/blake2s.c @@ -16,9 +16,15 @@ #include #include +static void __blake2s_compress(struct blake2s_state *state, const u8 *block, + size_t nblocks, const u32 inc) +{ + return blake2s_compress(state, block, nblocks, inc); +} + void blake2s_update(struct blake2s_state *state, const u8 *in, size_t inlen) { - __blake2s_update(state, in, inlen, blake2s_compress); + __blake2s_update(state, in, inlen, __blake2s_compress); } EXPORT_SYMBOL(blake2s_update);