Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <12356C813DFF6F479B608F81178A561586BDFE@BGSMSX101.gar.corp.intel.com>
Date: Thu, 27 Jun 2019 10:19:40 +0000
From: "Gote, Nitin R" <nitin.r.gote@...el.com>
To: Kees Cook <keescook@...omium.org>
CC: "kernel-hardening@...ts.openwall.com"
	<kernel-hardening@...ts.openwall.com>
Subject: Re: Regarding have kfree() (and related) set the pointer to NULL too

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);

Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.