2010-11-26 07:49:21

by Steffen Klassert

[permalink] [raw]
Subject: [PATCH] crypto: pcrypt - Fix use after free on padata_free

kobject_put is called from padata_free for the padata kobject.
The kobject's release function frees the padata instance,
so don't call kobject_put for the padata kobject from pcrypt.

Reported-by: Randy Dunlap <[email protected]>
Signed-off-by: Steffen Klassert <[email protected]>
Tested-by: Randy Dunlap <[email protected]>
---
crypto/pcrypt.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
index de30782..75586f1 100644
--- a/crypto/pcrypt.c
+++ b/crypto/pcrypt.c
@@ -504,7 +504,6 @@ err:

static void pcrypt_fini_padata(struct padata_pcrypt *pcrypt)
{
- kobject_put(&pcrypt->pinst->kobj);
free_cpumask_var(pcrypt->cb_cpumask->mask);
kfree(pcrypt->cb_cpumask);

--
1.7.0.4


2010-11-26 08:49:23

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: pcrypt - Fix use after free on padata_free

On Fri, Nov 26, 2010 at 08:49:17AM +0100, Steffen Klassert wrote:
> kobject_put is called from padata_free for the padata kobject.
> The kobject's release function frees the padata instance,
> so don't call kobject_put for the padata kobject from pcrypt.
>
> Reported-by: Randy Dunlap <[email protected]>
> Signed-off-by: Steffen Klassert <[email protected]>
> Tested-by: Randy Dunlap <[email protected]>

Linus has already taken this patch.

Thanks,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2010-11-26 08:54:14

by Steffen Klassert

[permalink] [raw]
Subject: Re: [PATCH] crypto: pcrypt - Fix use after free on padata_free

On Fri, Nov 26, 2010 at 04:49:15PM +0800, Herbert Xu wrote:
> On Fri, Nov 26, 2010 at 08:49:17AM +0100, Steffen Klassert wrote:
> > kobject_put is called from padata_free for the padata kobject.
> > The kobject's release function frees the padata instance,
> > so don't call kobject_put for the padata kobject from pcrypt.
> >
> > Reported-by: Randy Dunlap <[email protected]>
> > Signed-off-by: Steffen Klassert <[email protected]>
> > Tested-by: Randy Dunlap <[email protected]>
>
> Linus has already taken this patch.
>

Ok, I applied it on top of crypto-2.6. So I did not notice that it
is already in Linus tree.

Steffen