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

304803
autofs-5.1.4 - fix use after free in do_master_list_reset()
304803
304803
From: Ian Kent <raven@themaw.net>
304803
304803
Umm ... list_for_each() can't be used in do_master_list_reset() because
304803
the subject entry of the loop is removed for the list within the loop
304803
body. Therefore it can't be used to calculate the next pointer within a
304803
for (...) loop.
304803
304803
There is no list_for_each_safe() macro in the list.h of autofs so it
304803
needs to be done manually.
304803
304803
Signed-off-by: Ian Kent <raven@themaw.net>
304803
---
304803
 CHANGELOG          |    1 +
304803
 daemon/automount.c |    8 ++++++--
304803
 2 files changed, 7 insertions(+), 2 deletions(-)
304803
304803
diff --git a/CHANGELOG b/CHANGELOG
304803
index 4cb23f2..6cd3029 100644
304803
--- a/CHANGELOG
304803
+++ b/CHANGELOG
304803
@@ -289,6 +289,7 @@
304803
 - fix open calls not using open_xxxx() calls.
304803
 - move open_xxxx() functions to spawn.c.
304803
 - serialize calls to open_xxxx() functions.
304803
+- fix use after free in do_master_list_reset().
304803
 
304803
 25/07/2012 autofs-5.0.7
304803
 =======================
304803
diff --git a/daemon/automount.c b/daemon/automount.c
304803
index d96cd35..1a61b90 100644
304803
--- a/daemon/automount.c
304803
+++ b/daemon/automount.c
304803
@@ -2075,14 +2075,18 @@ static void remove_empty_args(char **argv, int *argc)
304803
 
304803
 static void do_master_list_reset(struct master *master)
304803
 {
304803
-	struct list_head *head, *p;
304803
+	struct list_head *head, *p, *n;
304803
 
304803
 	master_mutex_lock();
304803
 
304803
 	head = &master->mounts;
304803
-	list_for_each(p, head) {
304803
+	n = head->next;
304803
+	while (n != head) {
304803
 		struct master_mapent *entry;
304803
 
304803
+		p = n;
304803
+		n = p->next;
304803
+
304803
 		entry = list_entry(p, struct master_mapent, list);
304803
 
304803
 		if (!list_empty(&entry->list))