diff options
| author | wuchi <[email protected]> | 2022-06-20 10:02:44 +0000 |
|---|---|---|
| committer | akpm <[email protected]> | 2022-07-18 00:31:38 +0000 |
| commit | 86e5908ec293bf6505a59d02542da006226bcaa7 (patch) | |
| tree | 0fdf7d7de783319fb1f1517c2381f5e27cd8cad1 /lib/error-inject.c | |
| parent | lib/stackdepot: replace CONFIG_STACK_HASH_ORDER with automatic sizing (diff) | |
| download | kernel-86e5908ec293bf6505a59d02542da006226bcaa7.tar.gz kernel-86e5908ec293bf6505a59d02542da006226bcaa7.zip | |
lib/error-inject: traverse list with mutex
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.
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: wuchi <[email protected]>
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]>
Signed-off-by: Andrew Morton <[email protected]>
Diffstat (limited to 'lib/error-inject.c')
| -rw-r--r-- | lib/error-inject.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/error-inject.c b/lib/error-inject.c index 4a4f1278c419..1afca1b1cdea 100644 --- a/lib/error-inject.c +++ b/lib/error-inject.c @@ -40,12 +40,18 @@ bool within_error_injection_list(unsigned long addr) 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; } /* |
