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: <20180828174939.a2f81bd978067a0f93dc5c4a@kernel.org>
Date:   Tue, 28 Aug 2018 17:49:39 +0900
From:   Masami Hiramatsu <mhiramat@...nel.org>
To:     Jiri Kosina <jikos@...nel.org>
Cc:     x86@...nel.org, Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Andy Lutomirski <luto@...nel.org>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/alternatives: lockdep-enforce text_mutex in
 text_poke*()

On Tue, 28 Aug 2018 08:55:14 +0200 (CEST)
Jiri Kosina <jikos@...nel.org> wrote:

> From: Jiri Kosina <jkosina@...e.cz>
> 
> text_poke() and text_poke_bp() must be called with text_mutex held.
> Let's put proper lockdep anotation in place instead of just mentioning
> the requirement in comment.

Thank you!

Acked-by: Masami Hiramatsu <mhiramat@...nel.org>

> 
> Reported-by: Peter Zijlstra <peterz@...radead.org>
> Signed-off-by: Jiri Kosina <jkosina@...e.cz>
> ---
>  arch/x86/kernel/alternative.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
> index 014f214da581..b9d5e7c9ef43 100644
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -684,8 +684,6 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
>   * It means the size must be writable atomically and the address must be aligned
>   * in a way that permits an atomic write. It also makes sure we fit on a single
>   * page.
> - *
> - * Note: Must be called under text_mutex.
>   */
>  void *text_poke(void *addr, const void *opcode, size_t len)
>  {
> @@ -700,6 +698,8 @@ void *text_poke(void *addr, const void *opcode, size_t len)
>  	 */
>  	BUG_ON(!after_bootmem);
>  
> +	lockdep_assert_held(&text_mutex);
> +
>  	if (!core_kernel_text((unsigned long)addr)) {
>  		pages[0] = vmalloc_to_page(addr);
>  		pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
> @@ -782,8 +782,6 @@ int poke_int3_handler(struct pt_regs *regs)
>   *	- replace the first byte (int3) by the first byte of
>   *	  replacing opcode
>   *	- sync cores
> - *
> - * Note: must be called under text_mutex.
>   */
>  void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
>  {
> @@ -792,6 +790,9 @@ void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
>  	bp_int3_handler = handler;
>  	bp_int3_addr = (u8 *)addr + sizeof(int3);
>  	bp_patching_in_progress = true;
> +
> +	lockdep_assert_held(&text_mutex);
> +
>  	/*
>  	 * Corresponding read barrier in int3 notifier for making sure the
>  	 * in_progress and handler are correctly ordered wrt. patching.
> 
> -- 
> Jiri Kosina
> SUSE Labs
> 


-- 
Masami Hiramatsu <mhiramat@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ