lkml.org 
[lkml]   [2017]   [Jul]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1] mm/slub.c: add a naive detection of double free or corruption
Date
Add an assertion similar to "fasttop" check in GNU C Library allocator:
an object added to a singly linked freelist should not point to itself.
That helps to detect some double free errors (e.g. CVE-2017-2636) without
slub_debug and KASAN. Testing with hackbench doesn't show any noticeable
performance penalty.

Signed-off-by: Alexander Popov <alex.popov@linux.com>
---
mm/slub.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/mm/slub.c b/mm/slub.c
index 1d3f983..a106939b 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -261,6 +261,7 @@ static inline void *get_freepointer_safe(struct kmem_cache *s, void *object)

static inline void set_freepointer(struct kmem_cache *s, void *object, void *fp)
{
+ BUG_ON(object == fp); /* naive detection of double free or corruption */
*(void **)(object + s->offset) = fp;
}

--
2.7.4
\
 
 \ /
  Last update: 2017-07-17 18:46    [W:0.215 / U:0.120 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site