mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] kobject: kzfree object in _release function
@ 2009-04-11 16:16 tom.leiming
  2009-04-13 16:31 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: tom.leiming @ 2009-04-11 16:16 UTC (permalink / raw)
  To: greg; +Cc: linux-kernel, Ming Lei

From: Ming Lei <tom.leiming@gmail.com>

It helps to troubleshoot the __buggy__ case, in which
unreferenced objects are still accessed, using kzfree
to free objects safely in _release function.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
 lib/kobject.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/kobject.c b/lib/kobject.c
index a6dec32..cb5a562 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -597,7 +597,7 @@ void kobject_put(struct kobject *kobj)
 static void dynamic_kobj_release(struct kobject *kobj)
 {
 	pr_debug("kobject: (%p): %s\n", kobj, __func__);
-	kfree(kobj);
+	kzfree(kobj);
 }
 
 static struct kobj_type dynamic_kobj_ktype = {
@@ -762,7 +762,7 @@ static void kset_release(struct kobject *kobj)
 	struct kset *kset = container_of(kobj, struct kset, kobj);
 	pr_debug("kobject: '%s' (%p): %s\n",
 		 kobject_name(kobj), kobj, __func__);
-	kfree(kset);
+	kzfree(kset);
 }
 
 static struct kobj_type kset_ktype = {
-- 
1.6.0.GIT


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kobject: kzfree object in _release function
  2009-04-11 16:16 [PATCH] kobject: kzfree object in _release function tom.leiming
@ 2009-04-13 16:31 ` Greg KH
  2009-04-13 16:37   ` Pekka Enberg
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2009-04-13 16:31 UTC (permalink / raw)
  To: tom.leiming; +Cc: linux-kernel

On Sun, Apr 12, 2009 at 12:16:26AM +0800, tom.leiming@gmail.com wrote:
> From: Ming Lei <tom.leiming@gmail.com>
> 
> It helps to troubleshoot the __buggy__ case, in which
> unreferenced objects are still accessed, using kzfree
> to free objects safely in _release function.
> 
> Signed-off-by: Ming Lei <tom.leiming@gmail.com>
> ---
>  lib/kobject.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/kobject.c b/lib/kobject.c
> index a6dec32..cb5a562 100644
> --- a/lib/kobject.c
> +++ b/lib/kobject.c
> @@ -597,7 +597,7 @@ void kobject_put(struct kobject *kobj)
>  static void dynamic_kobj_release(struct kobject *kobj)
>  {
>  	pr_debug("kobject: (%p): %s\n", kobj, __func__);
> -	kfree(kobj);
> +	kzfree(kobj);
>  }
>  
>  static struct kobj_type dynamic_kobj_ktype = {
> @@ -762,7 +762,7 @@ static void kset_release(struct kobject *kobj)
>  	struct kset *kset = container_of(kobj, struct kset, kobj);
>  	pr_debug("kobject: '%s' (%p): %s\n",
>  		 kobject_name(kobj), kobj, __func__);
> -	kfree(kset);
> +	kzfree(kset);


What about slab-poisoning?  Shouldn't we just rely on that instead?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kobject: kzfree object in _release function
  2009-04-13 16:31 ` Greg KH
@ 2009-04-13 16:37   ` Pekka Enberg
  2009-04-13 19:47     ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Pekka Enberg @ 2009-04-13 16:37 UTC (permalink / raw)
  To: Greg KH; +Cc: tom.leiming, linux-kernel

Hi Greg,

On Mon, Apr 13, 2009 at 7:31 PM, Greg KH <greg@kroah.com> wrote:
> On Sun, Apr 12, 2009 at 12:16:26AM +0800, tom.leiming@gmail.com wrote:
>> From: Ming Lei <tom.leiming@gmail.com>
>>
>> It helps to troubleshoot the __buggy__ case, in which
>> unreferenced objects are still accessed, using kzfree
>> to free objects safely in _release function.
>>
>> Signed-off-by: Ming Lei <tom.leiming@gmail.com>
>> ---
>>  lib/kobject.c |    4 ++--
>>  1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/lib/kobject.c b/lib/kobject.c
>> index a6dec32..cb5a562 100644
>> --- a/lib/kobject.c
>> +++ b/lib/kobject.c
>> @@ -597,7 +597,7 @@ void kobject_put(struct kobject *kobj)
>>  static void dynamic_kobj_release(struct kobject *kobj)
>>  {
>>       pr_debug("kobject: (%p): %s\n", kobj, __func__);
>> -     kfree(kobj);
>> +     kzfree(kobj);
>>  }
>>
>>  static struct kobj_type dynamic_kobj_ktype = {
>> @@ -762,7 +762,7 @@ static void kset_release(struct kobject *kobj)
>>       struct kset *kset = container_of(kobj, struct kset, kobj);
>>       pr_debug("kobject: '%s' (%p): %s\n",
>>                kobject_name(kobj), kobj, __func__);
>> -     kfree(kset);
>> +     kzfree(kset);
>
>
> What about slab-poisoning?  Shouldn't we just rely on that instead?

Yes, you should. kzfree() strictly for cases where _correctness_ of
the program requires it (i.e. security concerns).

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kobject: kzfree object in _release function
  2009-04-13 16:37   ` Pekka Enberg
@ 2009-04-13 19:47     ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2009-04-13 19:47 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: tom.leiming, linux-kernel

On Mon, Apr 13, 2009 at 07:37:47PM +0300, Pekka Enberg wrote:
> Hi Greg,
> 
> On Mon, Apr 13, 2009 at 7:31 PM, Greg KH <greg@kroah.com> wrote:
> > On Sun, Apr 12, 2009 at 12:16:26AM +0800, tom.leiming@gmail.com wrote:
> >> From: Ming Lei <tom.leiming@gmail.com>
> >>
> >> It helps to troubleshoot the __buggy__ case, in which
> >> unreferenced objects are still accessed, using kzfree
> >> to free objects safely in _release function.
> >>
> >> Signed-off-by: Ming Lei <tom.leiming@gmail.com>
> >> ---
> >>  lib/kobject.c |    4 ++--
> >>  1 files changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/lib/kobject.c b/lib/kobject.c
> >> index a6dec32..cb5a562 100644
> >> --- a/lib/kobject.c
> >> +++ b/lib/kobject.c
> >> @@ -597,7 +597,7 @@ void kobject_put(struct kobject *kobj)
> >>  static void dynamic_kobj_release(struct kobject *kobj)
> >>  {
> >>       pr_debug("kobject: (%p): %s\n", kobj, __func__);
> >> -     kfree(kobj);
> >> +     kzfree(kobj);
> >>  }
> >>
> >>  static struct kobj_type dynamic_kobj_ktype = {
> >> @@ -762,7 +762,7 @@ static void kset_release(struct kobject *kobj)
> >>       struct kset *kset = container_of(kobj, struct kset, kobj);
> >>       pr_debug("kobject: '%s' (%p): %s\n",
> >>                kobject_name(kobj), kobj, __func__);
> >> -     kfree(kset);
> >> +     kzfree(kset);
> >
> >
> > What about slab-poisoning?  Shouldn't we just rely on that instead?
> 
> Yes, you should. kzfree() strictly for cases where _correctness_ of
> the program requires it (i.e. security concerns).

Thanks for letting us know.  As such, I'll not be applying this patch.

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-04-13 20:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-11 16:16 [PATCH] kobject: kzfree object in _release function tom.leiming
2009-04-13 16:31 ` Greg KH
2009-04-13 16:37   ` Pekka Enberg
2009-04-13 19:47     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome