Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Tesarik <ptesarik@suse.cz>2019-10-04 17:41:49 +0200
committerPetr Tesarik <ptesarik@suse.cz>2019-10-04 17:41:49 +0200
commit3fc0a32d3a49f4550aa8ec439bc4e334ba3e93d0 (patch)
treee788ab54c84f752961f63bd62cacc991186c13e9
parente36113e3dd7ddda262a7ed17880460eda4ca212f (diff)
parent3ca917a379f22e3e5f794e3b8e1c240e9dcc443a (diff)
Merge branch 'users/pmladek/SLE15/for-next' into SLE15
Pull a blacklist update from Petr Mladek
-rw-r--r--blacklist.conf1
-rw-r--r--patches.suse/ftrace-x86-remove-possible-deadlock-between-register_kprobe-and-ftrace_run_update_code.patch182
-rw-r--r--patches.suse/module-fix-livepatch-ftrace-module-text-permissions-race.patch170
-rw-r--r--series.conf2
4 files changed, 1 insertions, 354 deletions
diff --git a/blacklist.conf b/blacklist.conf
index 1ec4b61426..14a1f1dc8f 100644
--- a/blacklist.conf
+++ b/blacklist.conf
@@ -623,6 +623,7 @@ d125f3f866df88da5a85df00291f88f0baa89f7c # ftrace: see above 8114865ff82e200b383
b1b35f2e218a5b57d03bbc3b0667d5064570dc60 # ftrace: see above 8114865ff82e200b383
3cec638b3d793b7cacdec5b8072364b41caeb0e1 # ftrace: memory leak when set_trigger_filter() fails; should not normally happen; not worth it
2840f84f74035e5a535959d5f17269c69fa6edc5 # ftrace: memory leak in pretty advanced scenario
+9f255b632bf12c4dd7fc31caee89aa991ef75176 # livepatch/ftrace: fixes a potential deadlock when loading livepatch and another module in parallel; rather theoretical; also opens can of worms with other possible deadlocks; more than 6 locks involved; see bsc#1152325
c4ff91dd40e2253ab6dd028011469c2c694e1e19 # drm/amd/pp: initialize result to before or'ing in data
9c60583c0b0fd6f3a5b61fda3eb604ce218b9d25 # breaks KABI
diff --git a/patches.suse/ftrace-x86-remove-possible-deadlock-between-register_kprobe-and-ftrace_run_update_code.patch b/patches.suse/ftrace-x86-remove-possible-deadlock-between-register_kprobe-and-ftrace_run_update_code.patch
deleted file mode 100644
index 7ca190f8d2..0000000000
--- a/patches.suse/ftrace-x86-remove-possible-deadlock-between-register_kprobe-and-ftrace_run_update_code.patch
+++ /dev/null
@@ -1,182 +0,0 @@
-From: Petr Mladek <pmladek@suse.com>
-Date: Thu, 27 Jun 2019 10:13:34 +0200
-Subject: ftrace/x86: Remove possible deadlock between register_kprobe() and
- ftrace_run_update_code()
-Git-commit: d5b844a2cf507fc7642c9ae80a9d585db3065c28
-Patch-mainline: v5.2
-References: bsc#1071995 fate#323487
-
-The commit 9f255b632bf12c4dd7 ("module: Fix livepatch/ftrace module text
-permissions race") causes a possible deadlock between register_kprobe()
-and ftrace_run_update_code() when ftrace is using stop_machine().
-
-The existing dependency chain (in reverse order) is:
-
--> #1 (text_mutex){+.+.}:
- validate_chain.isra.21+0xb32/0xd70
- __lock_acquire+0x4b8/0x928
- lock_acquire+0x102/0x230
- __mutex_lock+0x88/0x908
- mutex_lock_nested+0x32/0x40
- register_kprobe+0x254/0x658
- init_kprobes+0x11a/0x168
- do_one_initcall+0x70/0x318
- kernel_init_freeable+0x456/0x508
- kernel_init+0x22/0x150
- ret_from_fork+0x30/0x34
- kernel_thread_starter+0x0/0xc
-
--> #0 (cpu_hotplug_lock.rw_sem){++++}:
- check_prev_add+0x90c/0xde0
- validate_chain.isra.21+0xb32/0xd70
- __lock_acquire+0x4b8/0x928
- lock_acquire+0x102/0x230
- cpus_read_lock+0x62/0xd0
- stop_machine+0x2e/0x60
- arch_ftrace_update_code+0x2e/0x40
- ftrace_run_update_code+0x40/0xa0
- ftrace_startup+0xb2/0x168
- register_ftrace_function+0x64/0x88
- klp_patch_object+0x1a2/0x290
- klp_enable_patch+0x554/0x980
- do_one_initcall+0x70/0x318
- do_init_module+0x6e/0x250
- load_module+0x1782/0x1990
- __s390x_sys_finit_module+0xaa/0xf0
- system_call+0xd8/0x2d0
-
- Possible unsafe locking scenario:
-
- CPU0 CPU1
- ---- ----
- lock(text_mutex);
- lock(cpu_hotplug_lock.rw_sem);
- lock(text_mutex);
- lock(cpu_hotplug_lock.rw_sem);
-
-It is similar problem that has been solved by the commit 2d1e38f56622b9b
-("kprobes: Cure hotplug lock ordering issues"). Many locks are involved.
-To be on the safe side, text_mutex must become a low level lock taken
-after cpu_hotplug_lock.rw_sem.
-
-This can't be achieved easily with the current ftrace design.
-For example, arm calls set_all_modules_text_rw() already in
-ftrace_arch_code_modify_prepare(), see arch/arm/kernel/ftrace.c.
-This functions is called:
-
- + outside stop_machine() from ftrace_run_update_code()
- + without stop_machine() from ftrace_module_enable()
-
-Fortunately, the problematic fix is needed only on x86_64. It is
-the only architecture that calls set_all_modules_text_rw()
-in ftrace path and supports livepatching at the same time.
-
-Therefore it is enough to move text_mutex handling from the generic
-kernel/trace/ftrace.c into arch/x86/kernel/ftrace.c:
-
- ftrace_arch_code_modify_prepare()
- ftrace_arch_code_modify_post_process()
-
-This patch basically reverts the ftrace part of the problematic
-commit 9f255b632bf12c4dd7 ("module: Fix livepatch/ftrace module
-text permissions race"). And provides x86_64 specific-fix.
-
-Some refactoring of the ftrace code will be needed when livepatching
-is implemented for arm or nds32. These architectures call
-set_all_modules_text_rw() and use stop_machine() at the same time.
-
-Link: http://lkml.kernel.org/r/20190627081334.12793-1-pmladek@suse.com
-
-Fixes: 9f255b632bf12c4dd7 ("module: Fix livepatch/ftrace module text permissions race")
-Acked-by: Thomas Gleixner <tglx@linutronix.de>
-Reported-by: Miroslav Benes <mbenes@suse.cz>
-Reviewed-by: Miroslav Benes <mbenes@suse.cz>
-Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
-Signed-off-by: Petr Mladek <pmladek@suse.com>
-[
- As reviewed by Miroslav Benes <mbenes@suse.cz>, removed return value of
- ftrace_run_update_code() as it is a void function.
-]
-Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-Acked-by: Miroslav Benes <mbenes@suse.cz>
----
- arch/x86/kernel/ftrace.c | 3 +++
- kernel/trace/ftrace.c | 10 +---------
- 2 files changed, 4 insertions(+), 9 deletions(-)
-
---- a/arch/x86/kernel/ftrace.c
-+++ b/arch/x86/kernel/ftrace.c
-@@ -21,6 +21,7 @@
- #include <linux/init.h>
- #include <linux/list.h>
- #include <linux/module.h>
-+#include <linux/memory.h>
-
- #include <trace/syscall.h>
-
-@@ -34,6 +35,7 @@
-
- int ftrace_arch_code_modify_prepare(void)
- {
-+ mutex_lock(&text_mutex);
- set_kernel_text_rw();
- set_all_modules_text_rw();
- return 0;
-@@ -43,6 +45,7 @@ int ftrace_arch_code_modify_post_process
- {
- set_all_modules_text_ro();
- set_kernel_text_ro();
-+ mutex_unlock(&text_mutex);
- return 0;
- }
-
---- a/kernel/trace/ftrace.c
-+++ b/kernel/trace/ftrace.c
-@@ -33,7 +33,6 @@
- #include <linux/list.h>
- #include <linux/hash.h>
- #include <linux/rcupdate.h>
--#include <linux/memory.h>
-
- #include <trace/events/sched.h>
-
-@@ -2630,12 +2629,10 @@ static void ftrace_run_update_code(int c
- {
- int ret;
-
-- mutex_lock(&text_mutex);
--
- ret = ftrace_arch_code_modify_prepare();
- FTRACE_WARN_ON(ret);
- if (ret)
-- goto out_unlock;
-+ return;
-
- /*
- * By default we use stop_machine() to modify the code.
-@@ -2647,9 +2644,6 @@ static void ftrace_run_update_code(int c
-
- ret = ftrace_arch_code_modify_post_process();
- FTRACE_WARN_ON(ret);
--
--out_unlock:
-- mutex_unlock(&text_mutex);
- }
-
- static void ftrace_run_modify_code(struct ftrace_ops *ops, int command,
-@@ -5415,7 +5409,6 @@ void ftrace_module_enable(struct module
- struct ftrace_page *pg;
-
- mutex_lock(&ftrace_lock);
-- mutex_lock(&text_mutex);
-
- if (ftrace_disabled)
- goto out_unlock;
-@@ -5476,7 +5469,6 @@ void ftrace_module_enable(struct module
- ftrace_arch_code_modify_post_process();
-
- out_unlock:
-- mutex_unlock(&text_mutex);
- mutex_unlock(&ftrace_lock);
- }
-
diff --git a/patches.suse/module-fix-livepatch-ftrace-module-text-permissions-race.patch b/patches.suse/module-fix-livepatch-ftrace-module-text-permissions-race.patch
deleted file mode 100644
index 66088c57bc..0000000000
--- a/patches.suse/module-fix-livepatch-ftrace-module-text-permissions-race.patch
+++ /dev/null
@@ -1,170 +0,0 @@
-From: Josh Poimboeuf <jpoimboe@redhat.com>
-Date: Thu, 13 Jun 2019 20:07:22 -0500
-Subject: module: Fix livepatch/ftrace module text permissions race
-Git-commit: 9f255b632bf12c4dd7fc31caee89aa991ef75176
-Patch-mainline: v5.2-rc5
-References: bsc#1071995 fate#323487
-
-It's possible for livepatch and ftrace to be toggling a module's text
-permissions at the same time, resulting in the following panic:
-
- BUG: unable to handle page fault for address: ffffffffc005b1d9
- #PF: supervisor write access in kernel mode
- #PF: error_code(0x0003) - permissions violation
- PGD 3ea0c067 P4D 3ea0c067 PUD 3ea0e067 PMD 3cc13067 PTE 3b8a1061
- Oops: 0003 [#1] PREEMPT SMP PTI
- CPU: 1 PID: 453 Comm: insmod Tainted: G O K 5.2.0-rc1-a188339ca5 #1
- Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-20181126_142135-anatol 04/01/2014
- RIP: 0010:apply_relocate_add+0xbe/0x14c
- Code: fa 0b 74 21 48 83 fa 18 74 38 48 83 fa 0a 75 40 eb 08 48 83 38 00 74 33 eb 53 83 38 00 75 4e 89 08 89 c8 eb 0a 83 38 00 75 43 <89> 08 48 63 c1 48 39 c8 74 2e eb 48 83 38 00 75 32 48 29 c1 89 08
- RSP: 0018:ffffb223c00dbb10 EFLAGS: 00010246
- RAX: ffffffffc005b1d9 RBX: 0000000000000000 RCX: ffffffff8b200060
- RDX: 000000000000000b RSI: 0000004b0000000b RDI: ffff96bdfcd33000
- RBP: ffffb223c00dbb38 R08: ffffffffc005d040 R09: ffffffffc005c1f0
- R10: ffff96bdfcd33c40 R11: ffff96bdfcd33b80 R12: 0000000000000018
- R13: ffffffffc005c1f0 R14: ffffffffc005e708 R15: ffffffff8b2fbc74
- FS: 00007f5f447beba8(0000) GS:ffff96bdff900000(0000) knlGS:0000000000000000
- CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
- CR2: ffffffffc005b1d9 CR3: 000000003cedc002 CR4: 0000000000360ea0
- DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
- DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
- Call Trace:
- klp_init_object_loaded+0x10f/0x219
- ? preempt_latency_start+0x21/0x57
- klp_enable_patch+0x662/0x809
- ? virt_to_head_page+0x3a/0x3c
- ? kfree+0x8c/0x126
- patch_init+0x2ed/0x1000 [livepatch_test02]
- ? 0xffffffffc0060000
- do_one_initcall+0x9f/0x1c5
- ? kmem_cache_alloc_trace+0xc4/0xd4
- ? do_init_module+0x27/0x210
- do_init_module+0x5f/0x210
- load_module+0x1c41/0x2290
- ? fsnotify_path+0x3b/0x42
- ? strstarts+0x2b/0x2b
- ? kernel_read+0x58/0x65
- __do_sys_finit_module+0x9f/0xc3
- ? __do_sys_finit_module+0x9f/0xc3
- __x64_sys_finit_module+0x1a/0x1c
- do_syscall_64+0x52/0x61
- entry_SYSCALL_64_after_hwframe+0x44/0xa9
-
-The above panic occurs when loading two modules at the same time with
-ftrace enabled, where at least one of the modules is a livepatch module:
-
-CPU0 CPU1
-klp_enable_patch()
- klp_init_object_loaded()
- module_disable_ro()
- ftrace_module_enable()
- ftrace_arch_code_modify_post_process()
- set_all_modules_text_ro()
- klp_write_object_relocations()
- apply_relocate_add()
- *patches read-only code* - BOOM
-
-A similar race exists when toggling ftrace while loading a livepatch
-module.
-
-Fix it by ensuring that the livepatch and ftrace code patching
-operations -- and their respective permissions changes -- are protected
-by the text_mutex.
-
-Link: http://lkml.kernel.org/r/ab43d56ab909469ac5d2520c5d944ad6d4abd476.1560474114.git.jpoimboe@redhat.com
-
-Reported-by: Johannes Erdfelt <johannes@erdfelt.com>
-Fixes: 444d13ff10fb ("modules: add ro_after_init support")
-Acked-by: Jessica Yu <jeyu@kernel.org>
-Reviewed-by: Petr Mladek <pmladek@suse.com>
-Reviewed-by: Miroslav Benes <mbenes@suse.cz>
-Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
-Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-Acked-by: Miroslav Benes <mbenes@suse.cz>
----
- kernel/livepatch/core.c | 6 ++++++
- kernel/trace/ftrace.c | 10 +++++++++-
- 2 files changed, 15 insertions(+), 1 deletion(-)
-
---- a/kernel/livepatch/core.c
-+++ b/kernel/livepatch/core.c
-@@ -30,6 +30,7 @@
- #include <linux/elf.h>
- #include <linux/moduleloader.h>
- #include <linux/completion.h>
-+#include <linux/memory.h>
- #include <asm/cacheflush.h>
- #include "core.h"
- #include "patch.h"
-@@ -729,16 +730,21 @@ static int klp_init_object_loaded(struct
- struct klp_func *func;
- int ret;
-
-+ mutex_lock(&text_mutex);
-+
- module_disable_ro(patch->mod);
- ret = klp_write_object_relocations(patch->mod, obj);
- if (ret) {
- module_enable_ro(patch->mod, true);
-+ mutex_unlock(&text_mutex);
- return ret;
- }
-
- arch_klp_init_object_loaded(patch, obj);
- module_enable_ro(patch->mod, true);
-
-+ mutex_unlock(&text_mutex);
-+
- klp_for_each_func(obj, func) {
- ret = klp_find_object_symbol(obj->name, func->old_name,
- func->old_sympos,
---- a/kernel/trace/ftrace.c
-+++ b/kernel/trace/ftrace.c
-@@ -33,6 +33,7 @@
- #include <linux/list.h>
- #include <linux/hash.h>
- #include <linux/rcupdate.h>
-+#include <linux/memory.h>
-
- #include <trace/events/sched.h>
-
-@@ -2629,10 +2630,12 @@ static void ftrace_run_update_code(int c
- {
- int ret;
-
-+ mutex_lock(&text_mutex);
-+
- ret = ftrace_arch_code_modify_prepare();
- FTRACE_WARN_ON(ret);
- if (ret)
-- return;
-+ goto out_unlock;
-
- /*
- * By default we use stop_machine() to modify the code.
-@@ -2644,6 +2647,9 @@ static void ftrace_run_update_code(int c
-
- ret = ftrace_arch_code_modify_post_process();
- FTRACE_WARN_ON(ret);
-+
-+out_unlock:
-+ mutex_unlock(&text_mutex);
- }
-
- static void ftrace_run_modify_code(struct ftrace_ops *ops, int command,
-@@ -5409,6 +5415,7 @@ void ftrace_module_enable(struct module
- struct ftrace_page *pg;
-
- mutex_lock(&ftrace_lock);
-+ mutex_lock(&text_mutex);
-
- if (ftrace_disabled)
- goto out_unlock;
-@@ -5469,6 +5476,7 @@ void ftrace_module_enable(struct module
- ftrace_arch_code_modify_post_process();
-
- out_unlock:
-+ mutex_unlock(&text_mutex);
- mutex_unlock(&ftrace_lock);
- }
-
diff --git a/series.conf b/series.conf
index 1b5ac6b642..8121d891fa 100644
--- a/series.conf
+++ b/series.conf
@@ -23724,7 +23724,6 @@
patches.suse/drm-i915-sdvo-Implement-proper-HDMI-audio-support-fo.patch
patches.suse/drm-i915-perf-fix-whitelist-on-Gen10.patch
patches.suse/cgroup-use-css_tryget-instead-of-css_tryget_online-in-task_get_css.patch
- patches.suse/module-fix-livepatch-ftrace-module-text-permissions-race.patch
patches.suse/USB-usb-storage-Add-new-ID-to-ums-realtek.patch
patches.suse/USB-Fix-chipmunk-like-voice-when-using-Logitech-C270.patch
patches.suse/0001-usb-dwc2-host-Fix-wMaxPacketSize-handling-fix-webcam.patch
@@ -23822,7 +23821,6 @@
patches.suse/cpu-speculation-warn-on-unsupported-mitigations-parameter.patch
patches.suse/cifs-fix-crash-querying-symlinks-stored-as-reparse-points.patch
patches.suse/Bluetooth-Fix-faulty-expression-for-minimum-encrypti.patch
- patches.suse/ftrace-x86-remove-possible-deadlock-between-register_kprobe-and-ftrace_run_update_code.patch
patches.suse/tracing-snapshot-resize-spare-buffer-if-size-changed.patch
patches.suse/ptrace-Fix-ptracer_cred-handling-for-PTRACE_TRACEME.patch
patches.suse/ALSA-hda-realtek-Add-quirks-for-several-Clevo-notebo.patch