From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_PASS,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4C8DC43381 for ; Fri, 15 Mar 2019 03:31:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 91C752186A for ; Fri, 15 Mar 2019 03:31:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mIu1sRg4"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="c+st7HBb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 91C752186A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Fgo4vWRrO+sL+pi54ThxNXxh3ozdNqUQ/a+wNU28iU8=; b=mIu1sRg49k9FAv H4BW5zzbjhK2pmwHaTSEeFzLno5eiacId5kwEvRbsafJVUl+6DPoDipyHSDmvscqGztMezff0cYs1 BPNiLOoMtI0FJ/l5gLFmYFQl7+SyqA2/YTe6vel6p1ZxQuULTSvLLevewBZ40TH3XiufcnRnlLkRv qi+XGmqVnWuCobucHgy8SnOSbZ81BzkPgjP9oNUqG2dqdZwzk98FsJqJ2OcLKjI/p/YSBEBGnZ001 tJ+6QJ/ieGqc6Ewlv0VhsNwfpf3br30h2/6veAiHevogdebCK3/PWmn/jDJtpg5Gf1kOAr4iZaQXm djOIbkGktPlYR3vct6QA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4dZS-0004EM-Tj; Fri, 15 Mar 2019 03:31:46 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4dZP-0004Dw-Hi; Fri, 15 Mar 2019 03:31:45 +0000 Received: from sol.localdomain (c-107-3-167-184.hsd1.ca.comcast.net [107.3.167.184]) (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 6B1E32186A; Fri, 15 Mar 2019 03:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552620702; bh=uF01UR9y60givakqqMOf4UJOv7kIJvNN7F5TewuZEMk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=c+st7HBbDCpBwqiKnKS3ZmUNYbT1nwvXWGrMzu6Mcd92r+dVytExP1iWl2VISWMTU ZgLpJgieD6dPXNL9VGVY6sYwi82g7raAsz7gvbUD+pyGdmgVOLvNYt2jlGyftd2TTU Cvae1d0XtpT1UIxFp31kc1rN8vQWyIdYn3OGEBvY= Date: Thu, 14 Mar 2019 20:31:40 -0700 From: Eric Biggers To: Zhang Zhijie Subject: Re: [Bug] Rockchip crypto driver sometimes produces wrong ciphertext Message-ID: <20190315033140.GB1671@sol.localdomain> References: <20190126210530.GB709@sol.localdomain> <1894799.pWIprST79S@phil> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190314_203143_621671_AEFC293B X-CRM114-Status: GOOD ( 15.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tao Huang , Zain Wang , Heiko Stuebner , Arnd Bergmann , Ard Biesheuvel , linux-rockchip@lists.infradead.org, "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , Olof Johansson , ezequiel@collabora.com, linux-arm-kernel Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Zhang, On Mon, Jan 28, 2019 at 11:14:32AM +0800, Tao Huang wrote: > Hi Eric and Heiko: > > >> On Sat, 26 Jan 2019 at 22:05, Eric Biggers wrote: > >>> > >>> Hello, > >>> > >>> I don't know whether anyone is actually maintaining the Rockchip crypto driver > >>> in drivers/crypto/rockchip/, but it's failing the improved crypto tests > >>> that I currently have out for review: https://patchwork.kernel.org/cover/10778089/ > > Zhang Zhijie, engineer from Rockchip, will try to fix this software bug. > > >>> > >>> See the boot logs for RK3288 from the KernelCI job here: > >>> > >>> https://storage.kernelci.org/ardb/for-kernelci/v5.0-rc1-86-geaffe22db9d1/arm/multi_v7_defconfig/lab-collabora/boot-rk3288-rock2-square.txt > >>> https://storage.kernelci.org/ardb/for-kernelci/v5.0-rc1-86-geaffe22db9d1/arm/multi_v7_defconfig/lab-collabora/boot-rk3288-veyron-jaq.txt > >>> > >>> alg: skcipher: ecb-aes-rk encryption test failed (wrong result) on test vector 0, cfg=\"random: use_digest src_divs=[15.64%@+3258, 84.36%@+4059] dst_divs=[69.11%@+1796, 8.49%@+4027, 6.34%@+1, 16.6%@+4058] iv_offset=21\" > >>> alg: skcipher: cbc-aes-rk encryption test failed (wrong result) on test vector 0, cfg=\"random: may_sleep use_digest src_divs=[100.0%@alignmask+3993] dst_divs=[65.31%@alignmask+1435, 34.69%@+14]\" > >>> alg: skcipher: ecb-des-rk encryption test failed (wrong result) on test vector 0, cfg=\"random: may_sleep use_final src_divs=[ 66.52%@+11, 33.48%@+1519] dst_divs=[58.82%@+1, 19.43%@+4082, 21.75%@+8]\" > >>> alg: skcipher: cbc-des-rk encryption test failed (wrong result) on test vector 0, cfg=\"random: may_sleep use_finup src_divs=[100.0%@+3980] dst_divs=[60.4%@+3763, 23.9%@+4011, 16.87%@+4046]\" > >>> alg: skcipher: ecb-des3-ede-rk encryption test failed (wrong result) on test vector 0, cfg=\"random: may_sleep use_digest src_divs=[100.0%@+4] dst_divs=[47.25%@+19, 14.83%@+22, 37.92%@+31]\" > >>> alg: skcipher: cbc-des3-ede-rk encryption test failed (wrong result) on test vector 0, cfg=\"two even aligned splits\" > >>> > >>> In other words: the ecb-aes-rk, cbc-aes-rk, ecb-des-rk, cbc-des-rk, > >>> ecb-des3-ede-rk, and cbc-des3-ede-rk algorithms are failing because they produce > >>> the wrong ciphertext on some scatterlist layouts. > >>> > >>> You can reproduce by pulling from > >>> https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git > >>> branch "testmgr-improvements", unsetting CONFIG_CRYPTO_MANAGER_DISABLE_TESTS, > >>> setting CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y, rebooting and checking dmesg. > >>> > >>> Note that I don't have this hardware myself, so if it turns out that no one is > >>> interested in fixing this anytime soon I'll instead have to propose disabling > >>> these algorithms until they can be fixed. > >>> > >>> Thanks, > >>> > >>> - Eric > >> Thanks for the fixes, but I've improved the self-tests more, and there is another bug. See the KernelCI job here: https://kernelci.org/boot/all/job/ardb/branch/for-kernelci/kernel/v5.0-11071-g7d597cc3f0ef/ The self-tests are failing on the rk3288-rock2-square platform: alg: skcipher: cbc-aes-rk encryption test failed (wrong output IV) on test vector 0, cfg=\"in-place\" alg: skcipher: cbc-des-rk encryption test failed (wrong output IV) on test vector 0, cfg=\"in-place\" alg: skcipher: cbc-des3-ede-rk encryption test failed (wrong output IV) on test vector 0, cfg=\"in-place\" The issue is that the self-tests now verify that CBC implementations update the IV buffer to contain the next IV, aka the last ciphertext block. But the Rockchip crypto driver doesn't do that, so it needs to be fixed. This has always been a requirement for CBC implementations so that users can chain CBC requests. Unfortunately it was just never tested for... This should be easily reproducible using the mainline kernel. - Eric _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel