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: <20200107183907.3c87500a@gandalf.local.home>
Date:   Tue, 7 Jan 2020 18:39:07 -0500
From:   Steven Rostedt <rostedt@...dmis.org>
To:     Masami Hiramatsu <mhiramat@...nel.org>
Cc:     Ingo Molnar <mingo@...nel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Andy Lutomirski <luto@...nel.org>,
        Borislav Petkov <bp@...en8.de>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>, bristot@...hat.com,
        "Naveen N . Rao" <naveen.n.rao@...ux.ibm.com>,
        Anil S Keshavamurthy <anil.s.keshavamurthy@...el.com>,
        David Miller <davem@...emloft.net>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [BUGFIX PATCH] kprobes: Fix to cancel optimizing/unoptimizing
 kprobes correctly

On Tue,  7 Jan 2020 23:42:24 +0900
Masami Hiramatsu <mhiramat@...nel.org> wrote:

> optimize_kprobe() and unoptimize_kprobe() cancels if given kprobe
> is on the optimizing_list or unoptimizing_list. However, since
> commit f66c0447cca1 ("kprobes: Set unoptimized flag after
> unoptimizing code") modified the update timing of the
> KPROBE_FLAG_OPTIMIZED, it doesn't work as expected anymore.
> 
> The optimized_kprobe could be following states.
> 
> - [optimizing]: Before inserting jump instruction
>   op.kp->flags has KPROBE_FLAG_OPTIMIZED and
>   op->list is not empty.
> 
> - [optimized]: jump inserted
>   op.kp->flags has KPROBE_FLAG_OPTIMIZED and
>   op->list is empty.
> 
> - [unoptimizing]: Before removing jump instruction (including unused
>   optprobe)
>   op.kp->flags has KPROBE_FLAG_OPTIMIZED and
>   op->list is not empty.
> 
> - [unoptimized]: jump removed
>   op.kp->flags doesn't have KPROBE_FLAG_OPTIMIZED and
>   op->list is empty.
> 
> Current code mis-expects [unoptimizing] state doesn't have
> KPROBE_FLAG_OPTIMIZED, and that can cause wrong results.
> 
> This introduces optprobe_queued_unopt() to distinguish [optimizing]
> and [unoptimizing] states and fixes logics in optimize_kprobe() and
> unoptimize_kprobe().
> 
> Fixes: f66c0447cca1 ("kprobes: Set unoptimized flag after unoptimizing code")
> Signed-off-by: Masami Hiramatsu <mhiramat@...nel.org>

Looks good.

Reviewed-by: Steven Rostedt (VMware) <rostedt@...dmis.org>


>  		return;
>  	}
> +
>  	/* Optimized kprobe case */
> -	if (force)
> +	if (force) {
>  		/* Forcibly update the code: this is a special case */
>  		force_unoptimize_kprobe(op);
> -	else {
> +	} else {
>  		list_add(&op->list, &unoptimizing_list);
>  		kick_kprobe_optimizer();
>  	}

I see you added some clean up to this patch.

-- Steve

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ