Skip to contentSkip to conversation

lib-error-inject-traverse-list-with-mutex.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Jul 18, 2022

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: lib/error-inject: traverse list with mutex
has been removed from the -mm tree. Its filename was
lib-error-inject-traverse-list-with-mutex.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: wuchi <[email protected]>
Subject: lib/error-inject: traverse list with mutex
Date: Mon, 20 Jun 2022 18:02:44 +0800

Traversing list without mutex in get_injectable_error_type will race with the following code:

    list_del_init(&ent->list)
    kfree(ent)

in module_unload_ei_list. So fix that.

Cc Masami Hiramatsu (Google) <[email protected]>
Cc Martin KaFai Lau <[email protected]>
Cc Song Liu <[email protected]>
Cc Yonghong Song <[email protected]>
Cc John Fastabend <[email protected]>
Cc KP Singh <[email protected]>

---

 lib/error-inject.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
lib/error-inject.c renamed from lib/error-inject.c~lib-error-inject-traverse-list-with-mutex +9 -3
@@ -40,12 +40,18 @@ bool within_error_injection_list(unsigne
 int get_injectable_error_type(unsigned long addr)
 {
 	struct ei_entry *ent;
+	int ei_type = EI_ETYPE_NONE;
 
+	mutex_lock(&ei_mutex);
 	list_for_each_entry(ent, &error_injection_list, list) {
-		if (addr >= ent->start_addr && addr < ent->end_addr)
-			return ent->etype;
+		if (addr >= ent->start_addr && addr < ent->end_addr) {
+			ei_type = ent->etype;
+			break;
+		}
 	}
-	return EI_ETYPE_NONE;
+	mutex_unlock(&ei_mutex);
+
+	return ei_type;
 }
 
 /*

_

Patches currently in -mm which might be from [email protected] are

lib-debugobjects-fix-stat-count-and-optimize-debug_objects_mem_init.patch