All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Pascal Van Leeuwen <pvanleeuwen@insidesecure.com>
Cc: "linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
	Herbert Xu <herbert@gondor.apana.org.au>
Subject: Re: Question regarding crypto scatterlists / testmgr
Date: Wed, 17 Apr 2019 13:24:08 -0700	[thread overview]
Message-ID: <20190417202407.GA96242@gmail.com> (raw)
In-Reply-To: <AM6PR09MB352386B26E3F632D6FE2FDDDD2250@AM6PR09MB3523.eurprd09.prod.outlook.com>

Hi Pascal,

On Wed, Apr 17, 2019 at 07:51:08PM +0000, Pascal Van Leeuwen wrote:
> Hi,
> 
> I'm trying to fix the inside-secure driver to pass all testmgr
> tests and I have one final issue remaining with the AEAD ciphers.
> As it was not clear at all what the exact problem was, I spent
> some time reverse engineering testmgr and I got the distinct
> impression that it is using scatter particles that cross page
> boundaries. On purpose, even.
> 
> While the inside-secure driver is built on the premise that
> scatter particles are continuous in device space. As I can't
> think of any reason why you would want to scatter/gather other
> than to handle virtual-to-physical address translation ...
> In any case, this should affect all other other operations as
> well, but maybe those just got "lucky" by getting particles
> that were still contiguous in device space, despite the page
> crossing (to *really* verify this, you would have to fully
> randomize your page allocation!)
> 
> Anyway, assuming that I *should* be able to handle particles
> that are *not* contiguous in device space, then there should
> probably already exist some function in the kernel API that
> converts a scatterlist with non-contiguous particles into a
> scatterlist with contiguous particles, taking into account the
> presence of an IOMMU? Considering pretty much every device
> driver would need to do that?
> Does anyone know which function(s) to use for that?
> 
> Regards,
> Pascal van Leeuwen
> Silicon IP Architect, Multi-Protocol Engines @ Inside Secure
> 

Indeed, since v5.1, testmgr tests scatterlist elements that cross a page.
However, the pages are guaranteed to be *physically* contiguous.  Does
dma_map_sg() not handle this?

BTW, this isn't just a theoretical case.  Many crypto API users do crypto on
kmalloced buffers, and those can cross a page boundary, especially if they are
large.  All software crypto algorithms handle this case.

The fact that these types of issues are just being considered now certainly
isn't raising my confidence in the hardware crypto drivers in the kernel...

- Eric

  parent reply	other threads:[~2019-04-17 20:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-17 19:51 Question regarding crypto scatterlists / testmgr Pascal Van Leeuwen
2019-04-17 20:15 ` Ard Biesheuvel
2019-04-17 20:49   ` Pascal Van Leeuwen
2019-04-17 20:51     ` Ard Biesheuvel
2019-04-17 20:24 ` Eric Biggers [this message]
2019-04-17 21:16   ` Pascal Van Leeuwen
2019-04-17 21:22     ` Pascal Van Leeuwen
2019-04-17 21:42     ` Eric Biggers
2019-04-18  3:10       ` Pascal Van Leeuwen
2019-04-17 21:43     ` Ard Biesheuvel
2019-04-18  3:16       ` Pascal Van Leeuwen
2019-04-18  3:29         ` Ard Biesheuvel
2019-04-18  3:36           ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190417202407.GA96242@gmail.com \
    --to=ebiggers@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=pvanleeuwen@insidesecure.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.