Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30203127rwd; Thu, 6 Jul 2023 02:22:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlFMNUs0c09t2/GrrS+wk7dluHllsdSYjO/wWqpM8ZiRHOLy3HAkCf9+QivykEiXzx7uyRDA X-Received: by 2002:a05:6a21:6d92:b0:12f:1f1f:db22 with SMTP id wl18-20020a056a216d9200b0012f1f1fdb22mr1109244pzb.52.1688635350712; Thu, 06 Jul 2023 02:22:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688635350; cv=none; d=google.com; s=arc-20160816; b=YFSbaFdlNkQbb6OfYRlAGhK6bJkW+yiuOCsR3mGy3vYEk3BFzJ18eTanvLCbZkADiB Ab1Ii+okdFy2FTsLKRxQUMkyRzefraNMSc3+4A0qWR3TC6ciU2g/zFSs/szyy54Y6coT Yo8d33NkBGjr2nACKlx6E29mDg6J+2Qg+UHR7wE5wcWJ8BgoWZywGRyCNXE4/C1RCcMY PbTFnrR+5OLofki3o6ssy3Y4+14wNjFbSzJOVf1SI+nqI6ymSv9ZLue05jifrfJ9j7f0 2q/YxgoXWwQZwQXRF8cqeUar7U9lHNcMnNjgwYiQyh51MkU/Don1yeUa8wGU0cuzltPO PJmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=C5P/qgkH3vvzZMLduqXXX/HpMIyAONSkihWuii0g79Y=; fh=fdP2Ov9YAcGJYDMYkq0Fasc5MLTSzAujd1O37HFULCY=; b=V1oUI6rnMnizPxnylPbiAcURAVxS3DoxcAa6yAJW3924rXfS3FZgNji9da8CZAw1b4 trMMHL5Bdpjl9sgYtepqkVy3EqGfVl3jkSuzg+h2hCegQp/7ZoVYE+j0o06ou25tMv2Q tPTzgoXX0O5UHhJ9PdYXJEdYRtHzqqdqDcl6hZxcvrr29UONH7FX3sEE/GhwuxRaoHFy 9oT2/nMZ/i3czo1BH4lPuOreU550Be8E99hUW/n++PiduEx7pIKUtU5KRdv81k9DL5hd DhaZccuFH/r9FHKDZ2jj84QLVEECSOJktsXqd5RtPbFm+pQM1X6KdoRR2xqKJoUiJxwb h8Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="jQ/F1QlX"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lc16-20020a170902fa9000b001b85ca73574si889051plb.285.2023.07.06.02.22.16; Thu, 06 Jul 2023 02:22:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="jQ/F1QlX"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231237AbjGFJAV (ORCPT + 99 others); Thu, 6 Jul 2023 05:00:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229489AbjGFJAU (ORCPT ); Thu, 6 Jul 2023 05:00:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5031A1BC8; Thu, 6 Jul 2023 02:00:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CB165618CB; Thu, 6 Jul 2023 09:00:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1132DC433C7; Thu, 6 Jul 2023 09:00:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688634018; bh=kUhi5w1JB2IJs4oDFUOm+9QXAiYHR4Uf/ijhCdJFvfQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jQ/F1QlXtsreGV/oJu2cGL/Xln/At0TcYnAd7nPR9SNSr/y39AqZicf4eJJui0j22 7IM+cM/XiQjOZ87wKh+HlUbqAgK6e4qMRRsVaGvlZ1DrHZLHwwDgKx+lAuX6Zn76LZ D4YhqcAo8Vv69FGRRsZELYkGZqbAkF39ziHJSgx4ts+Gpw1NoSH/+1MgP6DDETl79r cY7JnVt7p5DunRUPPPcmaLmV1LtYuDGZr6aPOFPUPxVMRbL4IuEe2Dr5ptelFYR5CJ NY+1wzfvP820rsv4gp6TRGnhrHUPaIWYoSoGxpRCkXW1u/TDx54xBnA5YHlHSClwiW PQxpan39yZwJg== Date: Thu, 6 Jul 2023 18:00:14 +0900 From: Masami Hiramatsu (Google) To: Peter Zijlstra Cc: Petr Pavlu , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, samitolvanen@google.com, x86@kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] x86/retpoline,kprobes: Avoid treating rethunk as an indirect jump Message-Id: <20230706180014.06705096a594b71250ff3c94@kernel.org> In-Reply-To: <20230706071705.GD2833176@hirez.programming.kicks-ass.net> References: <20230705081547.25130-1-petr.pavlu@suse.com> <20230705081547.25130-3-petr.pavlu@suse.com> <20230705085857.GG462772@hirez.programming.kicks-ass.net> <20230705232038.3a6d03e18f7bafb14cdfed42@kernel.org> <20230705145017.GC4253@hirez.programming.kicks-ass.net> <20230706094723.6934105e03f652923796bf7e@kernel.org> <20230706071705.GD2833176@hirez.programming.kicks-ass.net> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 6 Jul 2023 09:17:05 +0200 Peter Zijlstra wrote: > On Thu, Jul 06, 2023 at 09:47:23AM +0900, Masami Hiramatsu wrote: > > > > > If I understand correctly, all indirect jump will be replaced with JMP_NOSPEC. > > > > If you read the insn_jump_into_range, I onlu jecks the jump code, not call. > > > > So the functions only have indirect call still allow optprobe. > > > > > > With the introduction of kCFI JMP_NOSPEC is no longer an equivalent to a > > > C indirect jump. > > > > If I understand correctly, kCFI is enabled by CFI_CLANG, and clang is not > > using jump-tables by default, so we can focus on gcc. In that case > > current check still work, correct? > > IIRC clang can use jump tables, but like GCC needs RETPOLINE=n and > IBT=n, so effectively nobody has them. So if it requires RETPOLINE=n, current __indirect_thunk_start/end checking is not required, right? (that code is embraced with "#ifdef CONFIG_RETPOLINE") > > The reason I did mention kCFI though is that kCFI has a larger 'indirect > jump' sequence, and I'm not sure we've thought about what can go > sideways if that's optprobed. If I understand correctly, kCFI checks only indirect function call (check pointer), so no jump tables. Or does it use indirect 'jump' ? > > I suspect the UD2 that's in there will go 'funny' if it's relocated into > an optprobe, as in, it'll not be recognised as a CFI fail. UD2 can't be optprobed (kprobe neither) because it can change the dumped BUG address... Thank you, -- Masami Hiramatsu (Google)