[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191023152932.217ef516@gandalf.local.home>
Date: Wed, 23 Oct 2019 15:29:32 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org, mhiramat@...nel.org,
bristot@...hat.com, jbaron@...mai.com,
torvalds@...ux-foundation.org, tglx@...utronix.de,
mingo@...nel.org, namit@...are.com, hpa@...or.com, luto@...nel.org,
ard.biesheuvel@...aro.org, jpoimboe@...hat.com
Subject: Re: [PATCH v2 4/4] jump_label,module: Fix module lifetime for
__jump_label_mod_text_reserved
On Mon, 07 Oct 2019 10:25:45 +0200
Peter Zijlstra <peterz@...radead.org> wrote:
> 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>
Reviewed-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
-- Steve
> ---
> kernel/jump_label.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> --- a/kernel/jump_label.c
> +++ b/kernel/jump_label.c
> @@ -539,19 +539,25 @@ static void static_key_set_mod(struct st
> 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