kernel-hardening.lists.openwall.com archive mirror
 help / color / mirror / Atom feed
* Re: Regarding have kfree() (and related) set the pointer to NULL too
@ 2019-06-27 10:19 Gote, Nitin R
  2019-06-27 11:45 ` Vegard Nossum
  0 siblings, 1 reply; 6+ messages in thread
From: Gote, Nitin R @ 2019-06-27 10:19 UTC (permalink / raw)
  To: Kees Cook; +Cc: kernel-hardening

[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]

Hi,

I'm looking  into "have kfree() (and related) set the pointer to NULL too" task.

As per my understanding, I did below changes :
Could you please provide some points on below ways ?

diff --git a/mm/slab.c b/mm/slab.c
index f7117ad..a6e3d1b 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -3754,6 +3754,7 @@ void kfree(const void *objp)
        debug_check_no_obj_freed(objp, c->object_size);
        __cache_free(c, (void *)objp, _RET_IP_);
        local_irq_restore(flags);
+       objp = NULL;
}
EXPORT_SYMBOL(kfree);

diff --git a/mm/slob.c b/mm/slob.c
index 84aefd9..dcdb815 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -523,6 +523,8 @@ void kfree(const void *block)
                slob_free(m, *m + align);
        } else
                __free_pages(sp, compound_order(sp));
+
+       block = NULL;
}
EXPORT_SYMBOL(kfree);

diff --git a/mm/slub.c b/mm/slub.c
index cd04dbd..7cc400a 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3947,6 +3947,8 @@ void kfree(const void *x)
                return;
        }
        slab_free(page->slab_cache, page, object, NULL, 1, _RET_IP_);
+
+       x = NULL;
}
EXPORT_SYMBOL(kfree);

[-- Attachment #2: Type: text/html, Size: 5093 bytes --]

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

end of thread, other threads:[~2019-07-22 17:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-27 10:19 Regarding have kfree() (and related) set the pointer to NULL too Gote, Nitin R
2019-06-27 11:45 ` Vegard Nossum
2019-06-27 16:21   ` Kees Cook
2019-07-06 20:52     ` Gote, Nitin R
2019-07-17 10:01       ` Gote, Nitin R
2019-07-22 17:10         ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).