Skip to contentSkip to conversation

eCryptfs: use after free in ecryptfs_release_messaging()

PATCH In review Dan Carpenter 2 participants 2 messages Aug 22, 2017 – Oct 14, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eCryptfs: use after free in ecryptfs_release_messaging()

We're freeing the list iterator so we should be using the _safe() version of hlist_for_each_entry().

Fixes 88b4a07e6610 ("[PATCH] eCryptfs: Public key transport mechanism")

---
It's also possible that I misunderstood this code. Please review with caution.

fs/ecryptfs/messaging.c +4 -3
index 286f10b0363b..4f457d5c4933 100644
@@ -442,15 +442,16 @@ void ecryptfs_release_messaging(void)
 	}
 	if (ecryptfs_daemon_hash) {
 		struct ecryptfs_daemon *daemon;
+		struct hlist_node *n;
 		int i;
 
 		mutex_lock(&ecryptfs_daemon_hash_mux);
 		for (i = 0; i < (1 << ecryptfs_hash_bits); i++) {
 			int rc;
 
-			hlist_for_each_entry(daemon,
-					     &ecryptfs_daemon_hash[i],
-					     euid_chain) {
+			hlist_for_each_entry_safe(daemon, n,
+						  &ecryptfs_daemon_hash[i],
+						  euid_chain) {
 				rc = ecryptfs_exorcise_daemon(daemon);
 				if (rc)
 					printk(KERN_ERR "%s: Error whilst "
#1 lore raw

Hi Dan - Thanks for the patch. I'm sorry for not getting back to you until now.

Quoted 5 lines · Dan Carpenter

We're freeing the list iterator so we should be using the _safe() version of hlist_for_each_entry().

Fixes 88b4a07e6610 ("[PATCH] eCryptfs: Public key transport mechanism")

I think this patch is correct. I'll perform some testing and, if all goes well, get it in before 4.14 is released.

Tyler

Quoted 33 lines

---
It's also possible that I misunderstood this code. Please review with caution.

fs/ecryptfs/messaging.c +4 -4
index 286f10b0363b..4f457d5c4933 100644
@@ -442,15 +442,16 @@ void ecryptfs_release_messaging(void)
 	}
 	if (ecryptfs_daemon_hash) {
 		struct ecryptfs_daemon *daemon;
+		struct hlist_node *n;
 		int i;
 
 		mutex_lock(&ecryptfs_daemon_hash_mux);
 		for (i = 0; i < (1 << ecryptfs_hash_bits); i++) {
 			int rc;
 
-			hlist_for_each_entry(daemon,
-					     &ecryptfs_daemon_hash[i],
-					     euid_chain) {
+			hlist_for_each_entry_safe(daemon, n,
+						  &ecryptfs_daemon_hash[i],
+						  euid_chain) {
 				rc = ecryptfs_exorcise_daemon(daemon);
 				if (rc)
 					printk(KERN_ERR "%s: Error whilst "
--

To unsubscribe from this list: send the line "unsubscribe ecryptfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html