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=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham 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 710EBC169C4 for ; Mon, 11 Feb 2019 17:28:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 426AD2229E for ; Mon, 11 Feb 2019 17:28:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="DS8fHmlh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726655AbfBKR2t (ORCPT ); Mon, 11 Feb 2019 12:28:49 -0500 Received: from mail-it1-f195.google.com ([209.85.166.195]:39439 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726140AbfBKR2t (ORCPT ); Mon, 11 Feb 2019 12:28:49 -0500 Received: by mail-it1-f195.google.com with SMTP id a6so84224itl.4 for ; Mon, 11 Feb 2019 09:28:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hEOQzzk4xnw1lE439NKJnWZB7JJxP/JEAS97OWrd7Bc=; b=DS8fHmlhSXAAvqpjlp0ayzobhAQKtGtmYEreN8xQxhSHHmmk9urSf2hsOWDykFwcpN q0c7Hu3hjtO59OmhUi1FQZrAfGCJ8mZITMFDNAUjT7vmDqiPEA+dmBa9IUs7+qoq7pWZ tGqePf2chzEuDb/wUAcOWg//Oemo5+qs4gOqIpFlBj1PL4mKFAmOulnijWkf1U/nR5h1 Qq/Kg9tJNaklkaEwvkv6pWhYJtBWWSUW641ebmdSjh+cw47pZGXuvVVCUEBysiqY9Ovy 3bALWl1F67LMmP3g8QQoEsI5tr4+XSeSzXDTH7c3ZbSBCrGylkF/sc//riXuZyECPQwl tj/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hEOQzzk4xnw1lE439NKJnWZB7JJxP/JEAS97OWrd7Bc=; b=MLzKHakLBSokWIT+sAOReY9imIJpMFjpVjAydNrTbaAPQgRKMGWIRCRIFTQwImjcSL Ig2fBoflcRBdoqlxvMrsVrtt+IvyNhkX01LmGU70+g+/cGNiUSuMuKZrQIEuLaApzU3H ulAN+BX581ZMUEXmNrHkjuoaP4d0C4qzDXN3w4mWr+sSJuLIJX8CTouu7VQDIYP3CEUd HCd+AuTi8mkpk2C6pN7Qi+yVu21jwIZJf716+RUoViZTSXrVq3rAb2wq302Fa8m8QFMZ LdSLTjb4U//ByhboJEi2nmH/TdLEJuy4OYT1yBn6DjDPSQiQe62op59gOme8GAnC1y2N L+Yw== X-Gm-Message-State: AHQUAuY6xB5UjHHQ1uImREDyaoOH+hW1CdlQfF1ROFE8Ic/YM5T2FyvR +F+pkfldBOF5TAcaFHkWNvy5yZXkrU550Md7Z9miqQ== X-Google-Smtp-Source: AHgI3Ia9g/7W11Utn2LXM5hualOGABBWud2tI2d7ZSqzsfo2IrZA34h0QB5bvV8JYLCsNh/N77ifNS29Brp9Qntb73c= X-Received: by 2002:a24:4582:: with SMTP id c2mr388915itd.158.1549906128564; Mon, 11 Feb 2019 09:28:48 -0800 (PST) MIME-Version: 1.0 References: <20190131061225.15541-1-s.hauer@pengutronix.de> <20190208071635.5dkhabduambzzsu3@gondor.apana.org.au> <20190208114532.5yznhgeq6m6gh5fo@gondor.apana.org.au> In-Reply-To: From: Ard Biesheuvel Date: Mon, 11 Feb 2019 18:28:36 +0100 Message-ID: Subject: Re: [PATCH] crypto: caam - Do not overwrite IV To: Horia Geanta Cc: Herbert Xu , Sascha Hauer , "linux-crypto@vger.kernel.org" , "kernel@pengutronix.de" , "stable@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Mon, 11 Feb 2019 at 16:13, Horia Geanta wrote: > > On 2/8/2019 1:45 PM, Herbert Xu wrote: > > On Fri, Feb 08, 2019 at 08:41:37AM +0000, Horia Geanta wrote: > >> > >> So if there is a real intention to support offloading skcipher, as this old > >> commit suggests: > >> > >> 84c911523020 ("[CRYPTO] gcm: Add support for async ciphers") > >> This patch adds the necessary changes for GCM to be used with async > >> ciphers. This would allow it to be used with hardware devices that > >> support CTR. > >> > >> then we must take special care when building skcipher req->src and avoid having > >> it's first entry (auth_tag[16] in crypto_gcm_req_priv_ctx structure) sharing a > >> cache line with req->iv. > > > > Could you prepare a patch for this? > > > Yes, will do. > > Note that I am seeing the same issue on CCM. > > Also for GCM, besides auth_tag there is iauth_tag[16] buffer that is added in a > 1-entry S/G in gcm_hash_len(): > sg_init_one(&pctx->sg, pctx->iauth_tag, 16); > Yes, but I suppose the issue only occurs when writing data from the device, no? AFAICT, iauth_tag[] is passed into the device but never updated by it. > It looks like there other places where this happens, for e.g. "tail" member of > poly_req (crypto/cacha20poly1305.c) in poly_tail(): > sg_set_buf(preq->src, &preq->tail, sizeof(preq->tail)); > Same here. If it never occurs in the destination of the scatterlist, it should be safe for non-cache coherent DMA (since DMA to the device does not involve cache invalidation) However, it would be nice if we could test this in some way ...