Re: [PATCH v2] crypto: AF_ALG - race-free access of encryption flag

2017-11-29 Thread Herbert Xu
On Wed, Nov 29, 2017 at 12:05:13PM +0100, Stephan Müller wrote: > > Shouldn't we then create a patch for the pre-4.14 algif_skcipher code that > moves the wait out of the while loop to the beginning of the function in > recvmsg? When I said dead-lock I just meant that the recvmsg will block inde

Re: [PATCH v2] crypto: AF_ALG - race-free access of encryption flag

2017-11-29 Thread Stephan Müller
Am Mittwoch, 29. November 2017, 08:10:49 CET schrieb Herbert Xu: Hi Herbert, > > It sort of worked for skcipher because it didn't care if ctx->enc > or even ctx->iv changed midstream. But even there I don't think > we need to wait a second time. In fact waiting a second time could > result in

Re: [PATCH v2] crypto: AF_ALG - race-free access of encryption flag

2017-11-28 Thread Stephan Mueller
Am Mittwoch, 29. November 2017, 08:10:49 CET schrieb Herbert Xu: Hi Herbert, > > But anyway this isn't suitable for stable where we should just fix > it by making it not crash. I will send a patch right away moving the wait out. Later on I will elaborate on your suggestion to move the context-

Re: [PATCH v2] crypto: AF_ALG - race-free access of encryption flag

2017-11-28 Thread Herbert Xu
On Wed, Nov 29, 2017 at 07:48:53AM +0100, Stephan Mueller wrote: > Am Mittwoch, 29. November 2017, 00:02:40 CET schrieb Herbert Xu: > > > This is wrong. You can't fetch ctx->enc before you wait. It has > > to be done after the wait as otherwise ctx->enc may not even have > > been initialised. >

Re: [PATCH v2] crypto: AF_ALG - race-free access of encryption flag

2017-11-28 Thread Stephan Mueller
Am Mittwoch, 29. November 2017, 00:02:40 CET schrieb Herbert Xu: Hi Herbert, > > --- a/crypto/algif_aead.c > > +++ b/crypto/algif_aead.c > > @@ -110,6 +110,7 @@ static int _aead_recvmsg(struct socket *sock, struct > > msghdr *msg,> > > size_t outlen = 0; /* [out] RX bufs produce

Re: [PATCH v2] crypto: AF_ALG - race-free access of encryption flag

2017-11-28 Thread Herbert Xu
On Tue, Nov 28, 2017 at 10:33:09PM +0100, Stephan Müller wrote: > Hi Herbert, > > I verified the correctnes of the patch with Eric's test program. > Without the patch, the issue is present. With the patch, the kernel > happily lives ever after. > > Changes v2: change the submission into a proper

Re: [PATCH v2] crypto: AF_ALG - race-free access of encryption flag

2017-11-28 Thread Eric Biggers
On Tue, Nov 28, 2017 at 10:33:09PM +0100, Stephan Müller wrote: > Hi Herbert, > > I verified the correctnes of the patch with Eric's test program. > Without the patch, the issue is present. With the patch, the kernel > happily lives ever after. > > Changes v2: change the submission into a proper

[PATCH v2] crypto: AF_ALG - race-free access of encryption flag

2017-11-28 Thread Stephan Müller
Hi Herbert, I verified the correctnes of the patch with Eric's test program. Without the patch, the issue is present. With the patch, the kernel happily lives ever after. Changes v2: change the submission into a proper patch Ciao Stephan ---8<--- The function af_alg_get_rsgl may sleep to wait