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

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