Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2182564imn; Mon, 1 Aug 2022 14:23:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1urXiNTAdUkwtCZEFL8UmTMMFM6qyHMXDwLnPQBFaMLY41NRU+jgUcsiOskErFCZSagQLah X-Received: by 2002:a17:906:8501:b0:711:bf65:2a47 with SMTP id i1-20020a170906850100b00711bf652a47mr14211352ejx.150.1659389032824; Mon, 01 Aug 2022 14:23:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659389032; cv=none; d=google.com; s=arc-20160816; b=gEd2AWav/trGlmryDu0hGo/rm+PPyAAssSLfUbnV9x495E0CEmWP7ovq8p1ST9isMX 9JRZ20Kazh6GqBrldQvfq0wxtYZusDI8So8CSJX1CtmNAcqcpm/bapDpt/H2hDLbVmTK /a7MY0+rS5LOX4zltl3FHbCwwN3ZRWYY4QRrQ7k6lYnrQUglduadreOkRWj6cEuT0/tT 1ppo7AcjmYojaiQSeu/8c0uyQdGkm3XPV+dzictRyjg+r1/wwNVRTUICvlML3V49l7br Pq7vWMS2kKx6IMoVk0i/KuOF9lCWmO1Mo3DsH03nXJNPPUqsBLgf0U9F3311nztlM8It ht2g== 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; bh=OS5ZWwFzZNgXZKCc8bB0Xc8Ut420rnjAMmBY/VxP9qA=; b=E0cuJloagr8wbVgl9noQ+dW8NxWLtsm2mqlx1XtHINuHFVQnAsF5Qy2MJaBRa0rLrG CrICde7jk+KUKjvb0VhwyEMvFEkl/WVfitmi9ZsVGWfz73avDdygjwaxfJZb0jiyQX1w 93n69R5RvyAA2Xcd302iauZI9c93XnamS5yUp6Il5y55AQwBr8H3UZls2BOqgLookPMa FAaE20/wvb9WligALuczr28qtFB+MegoI1Rfd9+UekMEwdjwhxzlIuVgnjqhxW7aAYjA Ur+m0F1KKcMpyGogRKOHQoYu2Swlum/UNFye/zv14gS9nzAWuF2TKsUxaTY963wpolci +n/w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk37-20020a1709077fa500b007305f9cf344si1226097ejc.853.2022.08.01.14.23.26; Mon, 01 Aug 2022 14:23:52 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234465AbiHAUvw (ORCPT + 99 others); Mon, 1 Aug 2022 16:51:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234425AbiHAUvv (ORCPT ); Mon, 1 Aug 2022 16:51:51 -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 C2774BE3D; Mon, 1 Aug 2022 13:51:50 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 62399611C5; Mon, 1 Aug 2022 20:51:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B779C433D6; Mon, 1 Aug 2022 20:51:48 +0000 (UTC) Date: Mon, 1 Aug 2022 16:51:46 -0400 From: Steven Rostedt To: Jiri Olsa Cc: 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: <20220801165146.26fdeca2@gandalf.local.home> In-Reply-To: References: <20220801033719.228248-1-chenzhongjin@huawei.com> X-Mailer: Claws Mail 3.17.8 (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=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,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 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? -- 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 > >