Blame SOURCES/autofs-5.1.4-fix-use-after-free-in-do_master_list_reset.patch

135b98
autofs-5.1.4 - fix use after free in do_master_list_reset()
135b98
135b98
From: Ian Kent <raven@themaw.net>
135b98
135b98
Umm ... list_for_each() can't be used in do_master_list_reset() because
135b98
the subject entry of the loop is removed for the list within the loop
135b98
body. Therefore it can't be used to calculate the next pointer within a
135b98
for (...) loop.
135b98
135b98
There is no list_for_each_safe() macro in the list.h of autofs so it
135b98
needs to be done manually.
135b98
135b98
Signed-off-by: Ian Kent <raven@themaw.net>
135b98
---
135b98
 CHANGELOG          |    1 +
135b98
 daemon/automount.c |    8 ++++++--
135b98
 2 files changed, 7 insertions(+), 2 deletions(-)
135b98
135b98
diff --git a/CHANGELOG b/CHANGELOG
135b98
index 4faab510..2747327b 100644
135b98
--- a/CHANGELOG
135b98
+++ b/CHANGELOG
135b98
@@ -1,6 +1,7 @@
135b98
 xx/xx/2018 autofs-5.1.5
135b98
 - fix flag file permission.
135b98
 - fix directory create permission.
135b98
+- fix use after free in do_master_list_reset().
135b98
 
135b98
 19/12/2017 autofs-5.1.4
135b98
 - fix spec file url.
135b98
diff --git a/daemon/automount.c b/daemon/automount.c
135b98
index dcdc19fb..28b3f2f5 100644
135b98
--- a/daemon/automount.c
135b98
+++ b/daemon/automount.c
135b98
@@ -2070,14 +2070,18 @@ static void remove_empty_args(char **argv, int *argc)
135b98
 
135b98
 static void do_master_list_reset(struct master *master)
135b98
 {
135b98
-	struct list_head *head, *p;
135b98
+	struct list_head *head, *p, *n;
135b98
 
135b98
 	master_mutex_lock();
135b98
 
135b98
 	head = &master->mounts;
135b98
-	list_for_each(p, head) {
135b98
+	n = head->next;
135b98
+	while (n != head) {
135b98
 		struct master_mapent *entry;
135b98
 
135b98
+		p = n;
135b98
+		n = p->next;
135b98
+
135b98
 		entry = list_entry(p, struct master_mapent, list);
135b98
 
135b98
 		if (!list_empty(&entry->list))