From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751454AbdBXBFC (ORCPT ); Thu, 23 Feb 2017 20:05:02 -0500 Received: from mail.kernel.org ([198.145.29.136]:54510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751298AbdBXBFA (ORCPT ); Thu, 23 Feb 2017 20:05:00 -0500 Date: Fri, 24 Feb 2017 10:04:51 +0900 From: Masami Hiramatsu To: Peter Zijlstra Cc: Borislav Petkov , linux-kernel@vger.kernel.org, Ingo Molnar , Thomas Gleixner Subject: Re: kprobes vs __ex_table[] Message-Id: <20170224100451.31ca3855ddb36963b93d0768@kernel.org> In-Reply-To: <20170223183002.GD6557@twins.programming.kicks-ass.net> References: <20170223183002.GD6557@twins.programming.kicks-ass.net> X-Mailer: Sylpheed 3.5.0 (GTK+ 2.24.30; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 23 Feb 2017 19:30:02 +0100 Peter Zijlstra wrote: > Hi Masami, > > I just wondered what would happen if I put a probe on an instruction > that was listed in __ex_table[] or __bug_table[]. Ah, thanks for reporting, I know __ex_table issue and fixed, but I didn't care about __bug_table. > And it looks like it will happily do that. It will then run the > instruction out-of-line, and when said instruction traps, the > instruction address will not match the one listed in either __ex_table[] > or __bug_table[] and badness will happen. For the __ex_table[], at least on x86, kprobes already handles it in kprobe_fault_handler, which restore regs->ip to original place when a pagefault happens on singlestepping. > If kprobes does indeed not check this, we should probably fix it, if it > does do check this, could you point me to it? Yeah, for BUG() case, as far as I can see, there is no check about that. So, there are 2 ways to fix it up, one is to just reject to put kprobes on UD2, another is fixup trap address as we did for exceptions_table. I think latter is better because if there is a divide error happening on single-step, anyway we should fixup the address... Thank you, -- Masami Hiramatsu