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: <20200108120249.99d5a6d5201d1401e24447bc@kernel.org>
Date:   Wed, 8 Jan 2020 12:02:49 +0900
From:   Masami Hiramatsu <mhiramat@...nel.org>
To:     Steven Rostedt <rostedt@...dmis.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 18:39:07 -0500
Steven Rostedt <rostedt@...dmis.org> wrote:

> 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>

Thank you!

> 
> 
> >  		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.

Yeah, I felt somewhat uncomfortable for that. 

> 
> -- Steve


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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ