Skip to contentSkip to conversation

Patch "mm/list_lru.c: avoid error-path NULL pointer deref" has been added to the 4.8-stable tree

PATCH [email protected] 1 participant 1 message Nov 7, 2016

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

mm/list_lru.c: avoid error-path NULL pointer deref

to the 4.8-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
mm-list_lru.c-avoid-error-path-null-pointer-deref.patch
and it can be found in the queue-4.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 1bc11d70b5db7c6bb1414b283d7f09b1fe1ac0d0 Mon Sep 17 00:00:00 2001

From: Alexander Polakov <[email protected]>
Date: Thu, 27 Oct 2016 17:46:27 -0700
Subject: mm/list_lru.c: avoid error-path NULL pointer deref

From: Alexander Polakov <[email protected]>

commit 1bc11d70b5db7c6bb1414b283d7f09b1fe1ac0d0 upstream.

As described in https://bugzilla.kernel.org/show_bug.cgi?id=177821:

After some analysis it seems to be that the problem is in alloc_super(). In case list_lru_init_memcg() fails it goes into destroy_super(), which calls list_lru_destroy().

And in list_lru_init() we see that in case memcg_init_list_lru() fails, lru->node is freed, but not set NULL, which then leads list_lru_destroy() to believe it is initialized and call memcg_destroy_list_lru(). memcg_destroy_list_lru() in turn can access lru->node[i].memcg_lrus, which is NULL.

---
 mm/list_lru.c |    2 ++
 1 file changed, 2 insertions(+)
mm/list_lru.c +2 -0
@@ -554,6 +554,8 @@ int __list_lru_init(struct list_lru *lru
 	err = memcg_init_list_lru(lru, memcg_aware);
 	if (err) {
 		kfree(lru->node);
+		/* Do this so a list_lru_destroy() doesn't crash: */
+		lru->node = NULL;
 		goto out;
 	}
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.8/mm-list_lru.c-avoid-error-path-null-pointer-deref.patch