[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1528371714.iz71qgzxv3.naveen@linux.ibm.com>
Date: Thu, 07 Jun 2018 17:12:18 +0530
From: "Naveen N. Rao" <naveen.n.rao@...ux.vnet.ibm.com>
To: Masami Hiramatsu <mhiramat@...nel.org>,
Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Alexei Starovoitov <ast@...nel.org>,
Catalin Marinas <catalin.marinas@....com>,
Rich Felker <dalias@...c.org>,
"David S. Miller" <davem@...emloft.net>,
Fenghua Yu <fenghua.yu@...el.com>,
Heiko Carstens <heiko.carstens@...ibm.com>,
"H . Peter Anvin" <hpa@...or.com>, Josef Bacik <jbacik@...com>,
James Hogan <jhogan@...nel.org>, linux-arch@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
Russell King <linux@...linux.org.uk>,
linux-ia64@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-mips@...ux-mips.org, linuxppc-dev@...ts.ozlabs.org,
linux-s390@...r.kernel.org, linux-sh@...r.kernel.org,
linux-snps-arc@...ts.infradead.org, Ingo Molnar <mingo@...hat.com>,
Paul Mackerras <paulus@...ba.org>,
Ralf Baechle <ralf@...ux-mips.org>,
Steven Rostedt <rostedt@...dmis.org>,
Martin Schwidefsky <schwidefsky@...ibm.com>,
sparclinux@...r.kernel.org, Tony Luck <tony.luck@...el.com>,
Vineet Gupta <vgupta@...opsys.com>,
Will Deacon <will.deacon@....com>, x86@...nel.org,
Yoshinori Sato <ysato@...rs.sourceforge.jp>
Subject: Re: [RFC PATCH -tip v5 24/27] bpf: error-inject: kprobes: Clear
current_kprobe and enable preempt in kprobe
Masami Hiramatsu wrote:
> Clear current_kprobe and enable preemption in kprobe
> even if pre_handler returns !0.
>
> This simplifies function override using kprobes.
>
> Jprobe used to require to keep the preemption disabled and
> keep current_kprobe until it returned to original function
> entry. For this reason kprobe_int3_handler() and similar
> arch dependent kprobe handers checks pre_handler result
> and exit without enabling preemption if the result is !0.
>
> After removing the jprobe, Kprobes does not need to
> keep preempt disabled even if user handler returns !0
> anymore.
>
> But since the function override handler in error-inject
> and bpf is also returns !0 if it overrides a function,
> to balancing the preempt count, it enables preemption
> and reset current kprobe by itself.
>
> That is a bad design that is very buggy. This fixes
> such unbalanced preempt-count and current_kprobes setting
> in kprobes, bpf and error-inject.
>
> Note: for powerpc and x86, this removes all preempt_disable
> from kprobe_ftrace_handler because ftrace callbacks are
> called under preempt disabled.
>
> Signed-off-by: Masami Hiramatsu <mhiramat@...nel.org>
> Cc: Vineet Gupta <vgupta@...opsys.com>
> Cc: Russell King <linux@...linux.org.uk>
> Cc: Catalin Marinas <catalin.marinas@....com>
> Cc: Will Deacon <will.deacon@....com>
> Cc: Tony Luck <tony.luck@...el.com>
> Cc: Fenghua Yu <fenghua.yu@...el.com>
> Cc: Ralf Baechle <ralf@...ux-mips.org>
> Cc: James Hogan <jhogan@...nel.org>
> Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>
> Cc: Paul Mackerras <paulus@...ba.org>
> Cc: Michael Ellerman <mpe@...erman.id.au>
> Cc: Martin Schwidefsky <schwidefsky@...ibm.com>
> Cc: Heiko Carstens <heiko.carstens@...ibm.com>
> Cc: Yoshinori Sato <ysato@...rs.sourceforge.jp>
> Cc: Rich Felker <dalias@...c.org>
> Cc: "David S. Miller" <davem@...emloft.net>
> Cc: "Naveen N. Rao" <naveen.n.rao@...ux.vnet.ibm.com>
> Cc: Josef Bacik <jbacik@...com>
> Cc: Alexei Starovoitov <ast@...nel.org>
> Cc: x86@...nel.org
> Cc: linux-snps-arc@...ts.infradead.org
> Cc: linux-kernel@...r.kernel.org
> Cc: linux-arm-kernel@...ts.infradead.org
> Cc: linux-ia64@...r.kernel.org
> Cc: linux-mips@...ux-mips.org
> Cc: linuxppc-dev@...ts.ozlabs.org
> Cc: linux-s390@...r.kernel.org
> Cc: linux-sh@...r.kernel.org
> Cc: sparclinux@...r.kernel.org
> ---
> Changes in v5:
> - Fix kprobe_ftrace_handler in arch/powerpc too.
> ---
> arch/arc/kernel/kprobes.c | 5 +++--
> arch/arm/probes/kprobes/core.c | 10 +++++-----
> arch/arm64/kernel/probes/kprobes.c | 10 +++++-----
> arch/ia64/kernel/kprobes.c | 13 ++++---------
> arch/mips/kernel/kprobes.c | 4 ++--
> arch/powerpc/kernel/kprobes-ftrace.c | 15 ++++++---------
> arch/powerpc/kernel/kprobes.c | 7 +++++--
For the powerpc bits:
Acked-by: Naveen N. Rao <naveen.n.rao@...ux.vnet.ibm.com>
Thanks,
Naveen
Powered by blists - more mailing lists