Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp459863ybt; Mon, 6 Jul 2020 13:41:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsBKq3gkn3jFm2ix6I3GWQmWWxQCU2mx3TE6DRD6Yz87yhckVgzqpNZcv9SBV/n/BmI/v4 X-Received: by 2002:a17:906:d286:: with SMTP id ay6mr36030303ejb.400.1594068108823; Mon, 06 Jul 2020 13:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594068108; cv=none; d=google.com; s=arc-20160816; b=lqS10EOPpw/Exxowc4ZlO2CP1jOjZfreiVfPrAOwYu0dHo6zUwTn1tWBI9kFvY8dnM 9Zogo06vVMJSoJyED/rOF+ypHKdIPu3aQn7cBgkh3SIvy9zMpopLh+8rtcxa5q0mRZib uNJ6NUQt3QlysTKU/QhcsA1HqadGoBgCkqqp3eYYLcen/LpAxYVNQF58vaTov5LWdhd1 +tUv/3I7CzDk8bnGFFuUch9N84Ww0XeSrAZxUMWs1gCz5L8hInox6nTflGpz3EDNIIbv 9gbCzhWkp8ZO14/gepJzU3v/UYTFVANHTrr8pRFopFdml+9GytBiR3G+/D3b1XTPzZ1p pplg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Y41M1YxlKMi8fy++W0D9aY498rV6BUbWxLDmFQDP1Ww=; b=wcC/d2F65blrHJps29Mzmho7MinNPzLH2RflKqNJlfIzNqLbvS3MPIjF24cj9Ht3j9 mKpt9Fk6vmfMaahgCFdOp253fO3DylGP8kFYd76vb4qXgWl/gOLS+4RXe/Bjp8RZcOgT x455gen0Zw1NH9AXM10/rfnUBBKHpKYN3c5ND7hYkhqCFEIDZYAVgMmpH2Ic3M3cOepc ymelnGH8PpsetSHggserIHAAj8yoZPpXt7q9TYrd84KuMoud57AKB5ZuEB8RP489Khus XjREDB192kZVqVqu2Wrp1kY3Sg0n2eg6prUG+6/iYqI7ziDj54GuFiKHdqtbjw/aX39Z QQGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rDSwn1IK; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m8si13546578ejq.294.2020.07.06.13.41.17; Mon, 06 Jul 2020 13:41:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=@gmail.com header.s=20161025 header.b=rDSwn1IK; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726684AbgGFUkx (ORCPT + 99 others); Mon, 6 Jul 2020 16:40:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726434AbgGFUkx (ORCPT ); Mon, 6 Jul 2020 16:40:53 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C6D2C061755 for ; Mon, 6 Jul 2020 13:40:53 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id z15so31390129wrl.8 for ; Mon, 06 Jul 2020 13:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Y41M1YxlKMi8fy++W0D9aY498rV6BUbWxLDmFQDP1Ww=; b=rDSwn1IKnuGBhIb4T2tURULMieFysyKw1GeOwIVN2lR3nysIuciw+sQTU7z9idf0TL KuyzPdkIokA1cWCXIwL7KpgFX2qSedqEogrr2ry35B1CTmC2CcQDHNiZwrood+SnVJzO Ob/XM2ZhHi5XaIs2mrfyaUbYlGmR47NFnMBiXFYOFtD+k0qbugQdrLvqEkfnL5OjaiN0 KHJlVR/sUNIqAJ8Zh8F7YIRjNKpDlq7npCkgHAgz9c75wb2XRSat6fL4Xg8YKB262k6J kx3M3QXRe55NlnBagRs3h+ROnc9oiBdWUlkbQZka+VZJaDSNU7gl3v8QmmOtL/+Oub6A oeWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Y41M1YxlKMi8fy++W0D9aY498rV6BUbWxLDmFQDP1Ww=; b=iNDck/VwB1NDdSooNOhA+23ZZ01pU1NZK5Ui8/m97vjhHZCx3bMa54X0P+kao+ZWdC Zy552p/rVhTxGjTi09Zp/NPvBuUgWpXXr4A9JuVA6ajVzTV783x+OyppGWSQu2Pp4q06 t7JQ07cdi51l1+zv5Dt0xg3ZIkXh2z6wLAytW+eOtt8HbgN247bBjq66RzDKGLf4wdvz 8EnHNvrBFwk9mP8414aea7iIqBM7/9nwDs14/5PEpDNHfdc8tWNKz4zcQCZGvv6A9NDH r9IXlDj3UeZsUSOTmjI6upbK5tI0UAwgvDpearmx0ksrBYrvXykYczu2lHUqK5i+Yoxm tD4A== X-Gm-Message-State: AOAM531f4g2UJqXXk0YawEFtauLGPgrSmIMmlTNCDLLrzoyHX6t9pCEV SJ+u0wliHGi/cX53Mv0k5CY= X-Received: by 2002:adf:82f5:: with SMTP id 108mr49930198wrc.218.1594068051967; Mon, 06 Jul 2020 13:40:51 -0700 (PDT) Received: from Red ([2a01:cb1d:3d5:a100:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id f17sm829053wme.14.2020.07.06.13.40.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 13:40:51 -0700 (PDT) Date: Mon, 6 Jul 2020 22:40:49 +0200 From: Corentin Labbe To: Ard Biesheuvel Cc: linux-crypto@vger.kernel.org, Herbert Xu , "David S. Miller" , Maxime Ripard , Chen-Yu Tsai , Tom Lendacky , Ayush Sawal , Vinay Kumar Yadav , Rohit Maheshwari , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Jamie Iles , Eric Biggers , Tero Kristo , Matthias Brugger Subject: Re: [PATCH v3 06/13] crypto: sun8i-ss - permit asynchronous skcipher as fallback Message-ID: <20200706204049.GA25432@Red> References: <20200630121907.24274-1-ardb@kernel.org> <20200630121907.24274-7-ardb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200630121907.24274-7-ardb@kernel.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Tue, Jun 30, 2020 at 02:19:00PM +0200, Ard Biesheuvel wrote: > Even though the sun8i-ss driver implements asynchronous versions of > ecb(aes) and cbc(aes), the fallbacks it allocates are required to be > synchronous. Given that SIMD based software implementations are usually > asynchronous as well, even though they rarely complete asynchronously > (this typically only happens in cases where the request was made from > softirq context, while SIMD was already in use in the task context that > it interrupted), these implementations are disregarded, and either the > generic C version or another table based version implemented in assembler > is selected instead. > > Since falling back to synchronous AES is not only a performance issue, but > potentially a security issue as well (due to the fact that table based AES > is not time invariant), let's fix this, by allocating an ordinary skcipher > as the fallback, and invoke it with the completion routine that was given > to the outer request. > > Signed-off-by: Ard Biesheuvel > --- > drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c | 39 ++++++++++---------- > drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h | 3 +- > 2 files changed, 22 insertions(+), 20 deletions(-) > > diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h > index 29c44f279112..42658b134228 100644 > --- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h > +++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h > @@ -159,6 +159,7 @@ struct sun8i_cipher_req_ctx { > unsigned int ivlen; > unsigned int keylen; > void *biv; > + struct skcipher_request fallback_req; // keep at the end Hello You forgot to add it to the kerneldoc of the struct sun8i_cipher_req_ctx otherwise: Acked-by: Corentin Labbe Tested-by: Corentin Labbe Tested-on: sun8i-a83t-bananapi-m3 thanks