+ mm-kasan-initial-memory-quarantine-implementation-v8.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: mm: kasan: Initial memory quarantine implementation
has been added to the -mm tree.  Its filename is
     mm-kasan-initial-memory-quarantine-implementation-v8.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/mm-kasan-initial-memory-quarantine-implementation-v8.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/mm-kasan-initial-memory-quarantine-implementation-v8.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Alexander Potapenko <glider@xxxxxxxxxx>
Subject: mm: kasan: Initial memory quarantine implementation

v2: - added copyright comments
    - per request from Joonsoo Kim made __cache_free() more straightforward
    - added comments for smp_load_acquire()/smp_store_release()

v3: - incorporate changes introduced by the "mm, kasan: SLAB support" patch

v4: - fix kbuild compile-time error (missing ___cache_free() declaration)
      and a warning (wrong format specifier)

v6: - extended the patch description
    - dropped the unused qlist_remove() function

Signed-off-by: Alexander Potapenko <glider@xxxxxxxxxx>
Cc: Christoph Lameter <cl@xxxxxxxxx>
Cc: Pekka Enberg <penberg@xxxxxxxxxx>
Cc: David Rientjes <rientjes@xxxxxxxxxx>
Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
Cc: Andrey Konovalov <adech.fo@xxxxxxxxx>
Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx>
Cc: Andrey Ryabinin <ryabinin.a.a@xxxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Konstantin Serebryany <kcc@xxxxxxxxxx>
Cc: Dmitry Chernenkov <dmitryc@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 mm/kasan/quarantine.c |   59 ++++++++++++++--------------------------
 1 file changed, 21 insertions(+), 38 deletions(-)

diff -puN mm/kasan/quarantine.c~mm-kasan-initial-memory-quarantine-implementation-v8 mm/kasan/quarantine.c
--- a/mm/kasan/quarantine.c~mm-kasan-initial-memory-quarantine-implementation-v8
+++ a/mm/kasan/quarantine.c
@@ -33,7 +33,7 @@
 
 /* Data structure and operations for quarantine queues. */
 
-/* Each queue is a signled-linked list, which also stores the total size of
+/* Each queue is a signle-linked list, which also stores the total size of
  * objects inside of it.
  */
 struct qlist {
@@ -44,20 +44,20 @@ struct qlist {
 
 #define QLIST_INIT { NULL, NULL, 0 }
 
-static inline bool empty_qlist(struct qlist *q)
+static bool qlist_empty(struct qlist *q)
 {
 	return !q->head;
 }
 
-static inline void init_qlist(struct qlist *q)
+static void qlist_init(struct qlist *q)
 {
 	q->head = q->tail = NULL;
 	q->bytes = 0;
 }
 
-static inline void qlist_put(struct qlist *q, void **qlink, size_t size)
+static void qlist_put(struct qlist *q, void **qlink, size_t size)
 {
-	if (unlikely(empty_qlist(q)))
+	if (unlikely(qlist_empty(q)))
 		q->head = qlink;
 	else
 		*q->tail = qlink;
@@ -66,31 +66,14 @@ static inline void qlist_put(struct qlis
 	q->bytes += size;
 }
 
-static inline void **qlist_remove(struct qlist *q, void ***prev,
-				 size_t size)
+static void qlist_move_all(struct qlist *from, struct qlist *to)
 {
-	void **qlink = *prev;
-
-	*prev = *qlink;
-	if (q->tail == qlink) {
-		if (q->head == qlink)
-			q->tail = NULL;
-		else
-			q->tail = (void **)prev;
-	}
-	q->bytes -= size;
-
-	return qlink;
-}
-
-static inline void qlist_move_all(struct qlist *from, struct qlist *to)
-{
-	if (unlikely(empty_qlist(from)))
+	if (unlikely(qlist_empty(from)))
 		return;
 
-	if (empty_qlist(to)) {
+	if (qlist_empty(to)) {
 		*to = *from;
-		init_qlist(from);
+		qlist_init(from);
 		return;
 	}
 
@@ -98,17 +81,17 @@ static inline void qlist_move_all(struct
 	to->tail = from->tail;
 	to->bytes += from->bytes;
 
-	init_qlist(from);
+	qlist_init(from);
 }
 
-static inline void qlist_move(struct qlist *from, void **last, struct qlist *to,
+static void qlist_move(struct qlist *from, void **last, struct qlist *to,
 			  size_t size)
 {
 	if (unlikely(last == from->tail)) {
 		qlist_move_all(from, to);
 		return;
 	}
-	if (empty_qlist(to))
+	if (qlist_empty(to))
 		to->head = from->head;
 	else
 		*to->tail = from->head;
@@ -143,12 +126,12 @@ static unsigned long quarantine_size;
 #define QUARANTINE_LOW_SIZE (smp_load_acquire(&quarantine_size) * 3 / 4)
 #define QUARANTINE_PERCPU_SIZE (1 << 20)
 
-static inline struct kmem_cache *qlink_to_cache(void **qlink)
+static struct kmem_cache *qlink_to_cache(void **qlink)
 {
 	return virt_to_head_page(qlink)->slab_cache;
 }
 
-static inline void *qlink_to_object(void **qlink, struct kmem_cache *cache)
+static void *qlink_to_object(void **qlink, struct kmem_cache *cache)
 {
 	struct kasan_free_meta *free_info =
 		container_of((void ***)qlink, struct kasan_free_meta,
@@ -157,7 +140,7 @@ static inline void *qlink_to_object(void
 	return ((void *)free_info) - cache->kasan_info.free_meta_offset;
 }
 
-static inline void qlink_free(void **qlink, struct kmem_cache *cache)
+static void qlink_free(void **qlink, struct kmem_cache *cache)
 {
 	void *object = qlink_to_object(qlink, cache);
 	struct kasan_alloc_meta *alloc_info = get_alloc_info(cache, object);
@@ -169,11 +152,11 @@ static inline void qlink_free(void **qli
 	local_irq_restore(flags);
 }
 
-static inline void qlist_free_all(struct qlist *q, struct kmem_cache *cache)
+static void qlist_free_all(struct qlist *q, struct kmem_cache *cache)
 {
 	void **qlink;
 
-	if (unlikely(empty_qlist(q)))
+	if (unlikely(qlist_empty(q)))
 		return;
 
 	qlink = q->head;
@@ -185,7 +168,7 @@ static inline void qlist_free_all(struct
 		qlink_free(qlink, obj_cache);
 		qlink = next;
 	}
-	init_qlist(q);
+	qlist_init(q);
 }
 
 void quarantine_put(struct kasan_free_meta *info, struct kmem_cache *cache)
@@ -203,7 +186,7 @@ void quarantine_put(struct kasan_free_me
 
 	local_irq_restore(flags);
 
-	if (unlikely(!empty_qlist(&temp))) {
+	if (unlikely(!qlist_empty(&temp))) {
 		spin_lock_irqsave(&quarantine_lock, flags);
 		qlist_move_all(&temp, &global_quarantine);
 		spin_unlock_irqrestore(&quarantine_lock, flags);
@@ -251,13 +234,13 @@ void quarantine_reduce(void)
 	qlist_free_all(&to_free, NULL);
 }
 
-static inline void qlist_move_cache(struct qlist *from,
+static void qlist_move_cache(struct qlist *from,
 				   struct qlist *to,
 				   struct kmem_cache *cache)
 {
 	void ***prev;
 
-	if (unlikely(empty_qlist(from)))
+	if (unlikely(qlist_empty(from)))
 		return;
 
 	prev = &from->head;
_

Patches currently in -mm which might be from glider@xxxxxxxxxx are

kasan-modify-kmalloc_large_oob_right-add-kmalloc_pagealloc_oob_right.patch
mm-kasan-slab-support.patch
mm-kasan-added-gfp-flags-to-kasan-api.patch
arch-ftrace-for-kasan-put-hard-soft-irq-entries-into-separate-sections.patch
mm-kasan-stackdepot-implementation-enable-stackdepot-for-slab.patch
mm-kasan-stackdepot-implementation-enable-stackdepot-for-slab-v8.patch
kasan-test-fix-warn-if-the-uaf-could-not-be-detected-in-kmalloc_uaf2.patch
mm-kasan-initial-memory-quarantine-implementation.patch
mm-kasan-initial-memory-quarantine-implementation-v8.patch

--
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux