From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00C86C38145 for ; Tue, 6 Sep 2022 08:47:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239259AbiIFIrv (ORCPT ); Tue, 6 Sep 2022 04:47:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239501AbiIFIr2 (ORCPT ); Tue, 6 Sep 2022 04:47:28 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1398D19C21 for ; Tue, 6 Sep 2022 01:44:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=2Bbm1s4tGmDwrvOXctiEn8DCONI5zA4ymbplPiGKl7g=; b=fTY3AicCz/iJ6M/ACyUBU1cF3G 5K/9gNAkvGSnn6V0wOh9V3x37SeDqEwiGm2sqO00OzDRE6Pp1RebFfrqPgawrLcUzZ8p6j380BR/g XDaLCmeBonTKixdsqd9i1c4NLrt+i2XoX8d/noIZYlU/aynyKafXBFY8oN7zYb3SuHMIbe5gAPXSX +qUJHfkuAMan7h22A76G++UyNrbxfQVhsApX0FfKuRCV4t+NEFaB9BzdUdww6N0t717360RjrJRFR S7lIG8COLK3H1cMEx6qkhFK1YFxIrxkUwHZGSlcDpDMWWVUJo8n5TercB2uAPMXRBN1odJ7gxE9nj lPFmiv5g==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVUBm-00AEwS-Fa; Tue, 06 Sep 2022 08:44:10 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 8084730030F; Tue, 6 Sep 2022 10:44:08 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 2DFDD2012A05B; Tue, 6 Sep 2022 10:44:08 +0200 (CEST) Date: Tue, 6 Sep 2022 10:44:08 +0200 From: Peter Zijlstra To: Masami Hiramatsu Cc: Borislav Petkov , Josh Poimboeuf , linux-kernel@vger.kernel.org, Steven Rostedt , Ingo Molnar Subject: Re: CONFIG_RETHUNK int3 filling prevents kprobes in function body Message-ID: References: <20220904230713.a461f8fe85329663226c755f@kernel.org> <20220906103329.a2e79b1763bad299c0e1f11e@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220906103329.a2e79b1763bad299c0e1f11e@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 06, 2022 at 10:33:29AM +0900, Masami Hiramatsu wrote: > On Mon, 5 Sep 2022 17:52:29 +0200 > Peter Zijlstra wrote: > > > On Mon, Sep 05, 2022 at 05:09:16PM +0200, Peter Zijlstra wrote: > > > > > > This is because kprobes decodes function body to ensure the probed address > > > > is an instruction boundary, and if it finds the 0xcc (int3), it stops > > > > decoding and reject probing because the int3 is usually used for a > > > > software breakpoint and is replacing some other instruction. Without > > > > recovering the instruction, it can not continue decoding safely. > > > > > > I can't follow this logic. Decoding the single byte int3 instruction is > > > trivial. If you want a sanity check, follow the branches you found while > > > decoding the instruction starting at +0. > > > > Specifically, kprobe is the only one scribbling random [*] instructions > > with int3 in kernel text, so if kprobes doesn't know about the int3, it > > must be padding. > > No, kgdb is also handles int3 for its breakpoint. Of course we can > ignore it or ask kgdb to expose the API to decode it. I'm thinking kgdb has worse issues anyway. Much of it seems to be wishful thinking.