Re: [PATCH] crypto: do not free algorithm before using

2018-11-29 Thread Herbert Xu
On Thu, Nov 29, 2018 at 03:47:56PM +0800, PanBian wrote: > On Thu, Nov 29, 2018 at 02:57:11PM +0800, Herbert Xu wrote: > > On Thu, Nov 22, 2018 at 06:00:16PM +0800, Pan Bian wrote: > > > In multiple functions, the algorithm fields are read after its reference > > > is dropped through crypto_mod_put

Re: [PATCH] crypto: do not free algorithm before using

2018-11-28 Thread PanBian
On Thu, Nov 29, 2018 at 02:57:11PM +0800, Herbert Xu wrote: > On Thu, Nov 22, 2018 at 06:00:16PM +0800, Pan Bian wrote: > > In multiple functions, the algorithm fields are read after its reference > > is dropped through crypto_mod_put. In this case, the algorithm memory > > may be freed, resulting

Re: [PATCH] crypto: do not free algorithm before using

2018-11-28 Thread Herbert Xu
On Thu, Nov 22, 2018 at 06:00:16PM +0800, Pan Bian wrote: > In multiple functions, the algorithm fields are read after its reference > is dropped through crypto_mod_put. In this case, the algorithm memory > may be freed, resulting in use-after-free bugs. This patch delays the > put operation until

Re: [PATCH] crypto: do not free algorithm before using

2018-11-22 Thread Herbert Xu
On Fri, Nov 23, 2018 at 09:05:55AM +0800, PanBian wrote: > > Thanks for your explanation! But I find that the function > crypto_init_spawn just lets spawn->alg point to the algorithm without > increasing the reference count, i.e., alg->cra_refcnt. So I am confused > about how this can protect the

Re: [PATCH] crypto: do not free algorithm before using

2018-11-22 Thread PanBian
On Thu, Nov 22, 2018 at 10:44:41PM +0800, Herbert Xu wrote: > On Thu, Nov 22, 2018 at 06:00:16PM +0800, Pan Bian wrote: > > In multiple functions, the algorithm fields are read after its reference > > is dropped through crypto_mod_put. In this case, the algorithm memory > > may be freed, resulting

Re: [PATCH] crypto: do not free algorithm before using

2018-11-22 Thread Herbert Xu
On Thu, Nov 22, 2018 at 06:00:16PM +0800, Pan Bian wrote: > In multiple functions, the algorithm fields are read after its reference > is dropped through crypto_mod_put. In this case, the algorithm memory > may be freed, resulting in use-after-free bugs. This patch delays the > put operation until

[PATCH] crypto: do not free algorithm before using

2018-11-22 Thread Pan Bian
In multiple functions, the algorithm fields are read after its reference is dropped through crypto_mod_put. In this case, the algorithm memory may be freed, resulting in use-after-free bugs. This patch delays the put operation until the algorithm is never used. Signed-off-by: Pan Bian --- crypto