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

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