All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harald Freudenberger <freude@linux.ibm.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org, ebiggers@kernel.org,
	heiko.carstens@de.ibm.com, gor@linux.ibm.com
Subject: Re: [PATCH 2/3] s390/crypto: Rework on paes implementation
Date: Fri, 22 Nov 2019 15:45:11 +0100	[thread overview]
Message-ID: <dbd99075-22d3-b41a-57c6-ba85168eab87@linux.ibm.com> (raw)
In-Reply-To: <20191122140757.mbpnasimvnhke3k2@gondor.apana.org.au>

On 22.11.19 15:07, Herbert Xu wrote:
> On Fri, Nov 22, 2019 at 02:38:30PM +0100, Harald Freudenberger wrote:
>> The pkey is in fact a encrypted key + a verification pattern for the
>> encrypted key used. It gets invalid when this encryption key changes.
>> The encryption key changes when the LPAR is re-activated so for
>> example on suspend/resume or an Linux running as kvm guest
>> gets relocated. So this happens very rarely.
> I see.  Is there any way of you finding out that the key has been
> invalidated apart from trying out the crypto and having it fail?
No. By using the pkey for a crypto operation the hardware
checks the verification pattern and if there is a mismatch
it simple rejects the operation. Theoretically such an operation
can only partly complete and then a pkey could get invalid.
I have no way to check if the pkey is still valid before the
cpacf instruction call.
>
> Ideally you'd have a global counter that gets incremented everytime
> an invalidation occurs.  You can then regenerate your key if its
> generation counter differs from the current global counter.
>
> Also when the crypto fails due to an invalid key you're currently
> calling skcipher_walk_done with zero.  This is wrong as the done
> function must be called with a positive value or an error.  In
> some cases this can cause a crash in scatterwalk.
>
> IOW you should just repeat the crypto operation after regenerating
> the key rather than looping around again.
That's right. I'll try to rework the functions this way to
avoid calling skciper_walk_done with 0.

Thanks
>
> Cheers,


  reply	other threads:[~2019-11-22 14:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-13 10:55 [PATCH 0/3] provide paes selftests Harald Freudenberger
2019-11-13 10:55 ` [PATCH 1/3] s390/pkey: Add support for key blob with clear key value Harald Freudenberger
2019-11-13 10:55 ` [PATCH 2/3] s390/crypto: Rework on paes implementation Harald Freudenberger
2019-11-22  8:13   ` Herbert Xu
2019-11-22  9:54     ` Harald Freudenberger
2019-11-22 10:42       ` Herbert Xu
2019-11-22 13:38         ` Harald Freudenberger
2019-11-22 14:07           ` Herbert Xu
2019-11-22 14:45             ` Harald Freudenberger [this message]
2019-11-13 10:55 ` [PATCH 3/3] crypto/testmgr: add selftests for paes-s390 Harald Freudenberger
2019-11-22  8:16   ` Herbert Xu
2019-11-22  9:11     ` Harald Freudenberger
2019-11-26  8:59       ` Herbert Xu
2020-01-31 11:06     ` Harald Freudenberger
2020-02-10  7:19       ` Harald Freudenberger
2020-02-11  2:38         ` Herbert Xu
2020-02-13  7:40   ` [PATCH] " Harald Freudenberger
2020-02-13  8:39     ` 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=dbd99075-22d3-b41a-57c6-ba85168eab87@linux.ibm.com \
    --to=freude@linux.ibm.com \
    --cc=ebiggers@kernel.org \
    --cc=gor@linux.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    /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.