Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2235817imn; Mon, 1 Aug 2022 16:45:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR7qXqRRYa5raymXqLrd9iHH8oiDY5fqonVB9JaGF0HZL9/4z49UvrjuG7rHyHJSUP0QQrx5 X-Received: by 2002:a17:90a:9418:b0:1f1:e251:cabf with SMTP id r24-20020a17090a941800b001f1e251cabfmr21117739pjo.79.1659397536325; Mon, 01 Aug 2022 16:45:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659397536; cv=none; d=google.com; s=arc-20160816; b=zo/3TEGvdcWMuIU1dvD6UHpwoIJRQ99PAC1yMfs2+f74hn8mGT/qMrN9hthv+MQU7Z os+8QTPKysk3lZ+ZCRr1EBQZI2G3jjGiG32LWQi+K0JfdNgp5OBNe2R29c7b+wppjdXv LzsAnApg4uqI9io+7KFiIXW7XPkkkNSy7x8YYHbooXMiMdt2aM8ievfga+10rOm4MUH5 BOm29KRThSdUSfzkKvpVVF3drr9YBJOfKfRJZhVnKPpOhcl04oLOLiC9KEhFGsuHv98X 9/radJzlLbLPXolJUkqqvvKZtOH2/iJoMb7lLr2YYYMdfEHhFn793kTZuZA5RBjoMWkI TS8g== 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=rb8D5L1BQq5xDN+QINTcpqFkqB4eFuKKSLBda0vTMGo=; b=AvXnBKnPbwQbdtuW/TyXhjijw5AAImB/gRjzynDklRjJuSlw6SyuBAMSjPz8Z8C3Ry HJKHZqfhseMp4YX4JHPyGWf3mRbTeMY/DX43GLxR+JI+y2LDszTcckpGBdT5u1METVi8 5zn7M5dKlM+ORRx0S1cQLWBPaeVw3hPD+44ZnqKBo7UlA5nvkmqwNFX7ZYibt7BgcU/W 0yLB3tamjnEguT4hC+HS1Qk8TBLA9RhdGnBhXVfOSycEjNJW91Z3f+bRRl/Pe/osCEt2 agWIH4u3UlgEcjpHQwP41Mzw+icwDjp108YCYGC9j3gAs4P4BT1G1QVadLZsWPmqqUho 0POQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="MIcSVcE/"; 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 w4-20020a17090a460400b001f20c50d659si11857544pjg.116.2022.08.01.16.45.21; Mon, 01 Aug 2022 16:45:36 -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="MIcSVcE/"; 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 S232527AbiHAX3a (ORCPT + 99 others); Mon, 1 Aug 2022 19:29:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234368AbiHAX32 (ORCPT ); Mon, 1 Aug 2022 19:29:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ED4F422E1; Mon, 1 Aug 2022 16:29:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 63D27B81250; Mon, 1 Aug 2022 23:29:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFFF6C433D6; Mon, 1 Aug 2022 23:29:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659396565; bh=+tAKH5U9MjYkNE752i6vdc4km3iU4Hah9sUp7Z5hwiQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=MIcSVcE/eFcKum0Ze1NoWJMNTpuglLoqZPMH5tSjiCHZ3VR5SIrf90902toEB42yR dbzqkfoo7S7IaqZKw3A5uM0lV6nCdRPhlegwNjinUathfxIpiUZEVJD24UgqTjES9H xMaFKga15S9s6sAPZ72xQrSX8rhQg+ooaHG/zBS0IyeToajmZyssvlImIYspxQFuVQ f2bN5FbxSwTPu9axy3im8eOLhASBtXggy/JLEYJIKovVMyV4gBXyflbOp6Oq7agqpo zkJPROBImOnKljAblSWk31Q/yCNduUis3kwBj4U4okqPtWZuhX9P41VWqr2SD73geW GIgyN36NpwYgg== Date: Tue, 2 Aug 2022 08:29:19 +0900 From: Masami Hiramatsu (Google) To: Steven Rostedt Cc: Jiri Olsa , Chen Zhongjin , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, naveen.n.rao@linux.ibm.com, anil.s.keshavamurthy@intel.com, davem@davemloft.net, mhiramat@kernel.org, peterz@infradead.org, mingo@kernel.org, ast@kernel.org, daniel@iogearbox.net Subject: Re: [PATCH v3] kprobes: Forbid probing on trampoline and bpf prog Message-Id: <20220802082919.449c691237155cee9e190713@kernel.org> In-Reply-To: <20220801165146.26fdeca2@gandalf.local.home> References: <20220801033719.228248-1-chenzhongjin@huawei.com> <20220801165146.26fdeca2@gandalf.local.home> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; 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=-7.7 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_HI,SPF_HELO_NONE,SPF_PASS 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 Mon, 1 Aug 2022 16:51:46 -0400 Steven Rostedt wrote: > On Mon, 1 Aug 2022 22:41:19 +0200 > Jiri Olsa wrote: > > > LGTM cc-ing Steven because it affects ftrace as well > > Thanks for the Cc, but I don't quite see how it affects ftrace. > > Unless you are just saying how it can affect kprobe_events? Maybe kprobe_events can probe the ftrace trampoline buffer if CONFIG_KPROBE_EVENTS_ON_NOTRACE=y. > > -- Steve > > > > > > jirka > > > > > > > > v1 -> v2: > > > Check core_kernel_text and is_module_text_address rather than > > > only kprobe_insn. > > > Also fix title and commit message for this. See old patch at [1]. > > > --- > > > kernel/kprobes.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > > > index f214f8c088ed..80697e5e03e4 100644 > > > --- a/kernel/kprobes.c > > > +++ b/kernel/kprobes.c > > > @@ -1560,7 +1560,8 @@ static int check_kprobe_address_safe(struct kprobe *p, > > > preempt_disable(); > > > > > > /* Ensure it is not in reserved area nor out of text */ > > > - if (!kernel_text_address((unsigned long) p->addr) || > > > + if (!(core_kernel_text((unsigned long) p->addr) || > > > + is_module_text_address((unsigned long) p->addr)) || > > > within_kprobe_blacklist((unsigned long) p->addr) || > > > jump_label_text_reserved(p->addr, p->addr) || > > > static_call_text_reserved(p->addr, p->addr) || > > > -- > > > 2.17.1 > > > > -- Masami Hiramatsu (Google)