lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <159896088779.20229.8498091230478204573.tip-bot2@tip-bot2>
Date:   Tue, 01 Sep 2020 11:48:07 -0000
From:   "tip-bot2 for Peter Zijlstra" <tip-bot2@...utronix.de>
To:     linux-tip-commits@...r.kernel.org
Cc:     "Peter Zijlstra (Intel)" <peterz@...radead.org>,
        Ingo Molnar <mingo@...nel.org>,
        "Steven Rostedt (VMware)" <rostedt@...dmis.org>,
        x86 <x86@...nel.org>, LKML <linux-kernel@...r.kernel.org>
Subject: [tip: core/static_call] jump_label,module: Fix module lifetime for
 __jump_label_mod_text_reserved()

The following commit has been merged into the core/static_call branch of tip:

Commit-ID:     0db6e3734b130207026df1e78455fa98ca1d6f50
Gitweb:        https://git.kernel.org/tip/0db6e3734b130207026df1e78455fa98ca1d6f50
Author:        Peter Zijlstra <peterz@...radead.org>
AuthorDate:    Tue, 18 Aug 2020 15:57:39 +02:00
Committer:     Ingo Molnar <mingo@...nel.org>
CommitterDate: Tue, 01 Sep 2020 09:58:04 +02:00

jump_label,module: Fix module lifetime for __jump_label_mod_text_reserved()

Nothing ensures the module exists while we're iterating
mod->jump_entries in __jump_label_mod_text_reserved(), take a module
reference to ensure the module sticks around.

Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Signed-off-by: Ingo Molnar <mingo@...nel.org>
Reviewed-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
Link: https://lore.kernel.org/r/20200818135804.504501338@infradead.org
---
 kernel/jump_label.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index cdb3ffa..e661c61 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -539,19 +539,25 @@ static void static_key_set_mod(struct static_key *key,
 static int __jump_label_mod_text_reserved(void *start, void *end)
 {
 	struct module *mod;
+	int ret;
 
 	preempt_disable();
 	mod = __module_text_address((unsigned long)start);
 	WARN_ON_ONCE(__module_text_address((unsigned long)end) != mod);
+	if (!try_module_get(mod))
+		mod = NULL;
 	preempt_enable();
 
 	if (!mod)
 		return 0;
 
-
-	return __jump_label_text_reserved(mod->jump_entries,
+	ret = __jump_label_text_reserved(mod->jump_entries,
 				mod->jump_entries + mod->num_jump_entries,
 				start, end);
+
+	module_put(mod);
+
+	return ret;
 }
 
 static void __jump_label_mod_update(struct static_key *key)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ