Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1300113

Re: [PATCH v2] crypto: algif_skcipher - Require setkey before accept(2)

From Stephan Mueller <smueller@chronox.de>
Newsgroups linux.kernel
Subject Re: [PATCH v2] crypto: algif_skcipher - Require setkey before accept(2)
Date 2016-01-02 21:10 +0100
Message-ID <qMAEW-4bL-17@gated-at.bofh.it> (permalink)
References <qJbWq-5Z3-15@gated-at.bofh.it> <qMt0L-7Eq-19@gated-at.bofh.it> <qMvFg-RW-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Am Samstag, 2. Januar 2016, 15:41:34 schrieb Milan Broz:

Hi Milan,

> On 01/02/2016 12:52 PM, Milan Broz wrote:
> > On 12/25/2015 08:40 AM, Herbert Xu wrote:
> >> Dmitry Vyukov <dvyukov@google.com> wrote:
> >>> I am testing with your two patches:
> >>> crypto: algif_skcipher - Use new skcipher interface
> >>> crypto: algif_skcipher - Require setkey before accept(2)
> >>> on top of a88164345b81292b55a8d4829fdd35c8d611cd7d (Dec 23).
> >> 
> >> You sent the email to everyone on the original CC list except me.
> >> Please don't do that.
> >> 
> >>> Now the following program causes a bunch of use-after-frees and them
> >> 
> >>> kills kernel:
> >> Yes there is an obvious bug in the patch that Julia Lawall has
> >> responded to in another thread.  Here is a fixed version.
> >> 
> >> ---8<--
> >> Some cipher implementations will crash if you try to use them
> >> without calling setkey first.  This patch adds a check so that
> >> the accept(2) call will fail with -ENOKEY if setkey hasn't been
> >> done on the socket yet.
> > 
> > Hi Herbert,
> > 
> > this patch breaks userspace in cryptsetup...
> > 
> > We use algif_skcipher in cryptsetup (for years, even before
> > there was Stephan's library) and with this patch applied
> > I see fail in ALG_SET_IV call (patch from your git).
> 
> (Obviously this was because of failing accept() call here, not set_iv.)
> 
> > I can fix it upstream, but for thousands of installations it will
> > be broken (for LUKS there is a fallback, cor TrueCrypt compatible devices
> > it will be unusable. Also people who configured kernel crypto API as
> > default backend will have non-working cryptsetup).
> > 
> > Is it really thing for stable branch?
> 
> Also how it is supposed to work for cipher_null, where there is no key?
> Why it should call set_key if it is noop? (and set key length 0 is not
> possible).
> 
> (We are using cipher_null for testing and for offline re-encryption tool
> to create temporary "fake" header for not-yet encrypted device...)

The change implies that any setkey or set IV operations (i.e. any operations 
on the tfmfd) are done before the opfd(s) are created with one or more accept 
calls.

Thus, after a bind that returns the tfmfd, the setkey and setiv operations 
shall be called. This is followed by accept. If you change the order of 
invocations in your code, it should work.
> 
> Milan


-- 
Ciao
Stephan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

GPF in lrw_crypt Dmitry Vyukov <dvyukov@google.com> - 2015-12-17 14:00 +0100
  Re: GPF in lrw_crypt Stephan Mueller <smueller@chronox.de> - 2015-12-22 00:00 +0100
  Re: GPF in lrw_crypt Herbert Xu <herbert@gondor.apana.org.au> - 2015-12-24 10:40 +0100
    Re: GPF in lrw_crypt Dmitry Vyukov <dvyukov@google.com> - 2015-12-24 12:10 +0100
      [PATCH v2] crypto: algif_skcipher - Require setkey before accept(2) Herbert Xu <herbert@gondor.apana.org.au> - 2015-12-25 08:50 +0100
        Re: [PATCH v2] crypto: algif_skcipher - Require setkey before accept(2) Dmitry Vyukov <dvyukov@google.com> - 2015-12-28 14:50 +0100
          Re: [PATCH v2] crypto: algif_skcipher - Require setkey before  accept(2) Herbert Xu <herbert@gondor.apana.org.au> - 2015-12-29 14:30 +0100
        Re: [PATCH v2] crypto: algif_skcipher - Require setkey before  accept(2) Milan Broz <gmazyland@gmail.com> - 2016-01-02 13:00 +0100
          Re: [PATCH v2] crypto: algif_skcipher - Require setkey before  accept(2) Milan Broz <gmazyland@gmail.com> - 2016-01-02 15:50 +0100
            Re: [PATCH v2] crypto: algif_skcipher - Require setkey before accept(2) Stephan Mueller <smueller@chronox.de> - 2016-01-02 21:10 +0100
              Re: [PATCH v2] crypto: algif_skcipher - Require setkey before  accept(2) Milan Broz <gmazyland@gmail.com> - 2016-01-02 21:20 +0100
                Re: [PATCH v2] crypto: algif_skcipher - Require setkey before  accept(2) Herbert Xu <herbert@gondor.apana.org.au> - 2016-01-03 02:40 +0100
                Re: [PATCH v2] crypto: algif_skcipher - Require setkey before  accept(2) Milan Broz <gmazyland@gmail.com> - 2016-01-03 10:50 +0100
                [PATCH 1/2] crypto: af_alg - Add nokey compatibility path Herbert Xu <herbert@gondor.apana.org.au> - 2016-01-04 05:40 +0100
                [PATCH 2/2] crypto: algif_skcipher - Add nokey compatibility path Herbert Xu <herbert@gondor.apana.org.au> - 2016-01-04 05:40 +0100
                Re: [PATCH 1/2] crypto: af_alg - Add nokey compatibility path Milan Broz <gmazyland@gmail.com> - 2016-01-04 13:40 +0100
                Re: [PATCH 1/2] crypto: af_alg - Add nokey compatibility path Herbert Xu <herbert@gondor.apana.org.au> - 2016-01-08 13:50 +0100
                Re: [PATCH 1/2] crypto: af_alg - Add nokey compatibility path Milan Broz <gmazyland@gmail.com> - 2016-01-08 19:30 +0100
                Re: [PATCH 1/2] crypto: af_alg - Add nokey compatibility path Herbert Xu <herbert@gondor.apana.org.au> - 2016-01-09 06:50 +0100
                Re: [PATCH 1/2] crypto: af_alg - Add nokey compatibility path Milan Broz <gmazyland@gmail.com> - 2016-01-09 11:20 +0100
                [PATCH 1/2] crypto: skcipher - Add crypto_skcipher_has_setkey Herbert Xu <herbert@gondor.apana.org.au> - 2016-01-11 14:30 +0100
                [PATCH 2/2] crypto: algif_skcipher - Add key check exception for  cipher_null Herbert Xu <herbert@gondor.apana.org.au> - 2016-01-11 14:40 +0100
                Re: [PATCH 2/2] crypto: algif_skcipher - Add key check exception for  cipher_null Milan Broz <gmazyland@gmail.com> - 2016-01-11 16:00 +0100
                [PATCH 1/2] crypto: hash - Add crypto_ahash_has_setkey Herbert Xu <herbert@gondor.apana.org.au> - 2016-01-08 14:30 +0100
                [PATCH 2/2] crypto: algif_hash - Require setkey before accept(2) Herbert Xu <herbert@gondor.apana.org.au> - 2016-01-08 14:40 +0100
                Re: [PATCH 2/2] crypto: algif_hash - Require setkey before accept(2) kbuild test robot <lkp@intel.com> - 2016-01-08 15:00 +0100
                Re: [PATCH 2/2] crypto: algif_hash - Require setkey before accept(2) Milan Broz <gmazyland@gmail.com> - 2016-01-09 11:20 +0100

csiph-web