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 X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01322CA9EA0 for ; Fri, 18 Oct 2019 17:03:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D472021835 for ; Fri, 18 Oct 2019 17:03:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2634403AbfJRRDA (ORCPT ); Fri, 18 Oct 2019 13:03:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:50240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387714AbfJRRDA (ORCPT ); Fri, 18 Oct 2019 13:03:00 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 819952064A; Fri, 18 Oct 2019 17:02:58 +0000 (UTC) Date: Fri, 18 Oct 2019 13:02:57 -0400 From: Steven Rostedt To: Sami Tolvanen Cc: Will Deacon , Catalin Marinas , Ard Biesheuvel , Dave Martin , Kees Cook , Laura Abbott , Mark Rutland , Nick Desaulniers , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Masami Hiramatsu Subject: Re: [PATCH 10/18] kprobes: fix compilation without CONFIG_KRETPROBES Message-ID: <20191018130257.3376e397@gandalf.local.home> In-Reply-To: <20191018161033.261971-11-samitolvanen@google.com> References: <20191018161033.261971-1-samitolvanen@google.com> <20191018161033.261971-11-samitolvanen@google.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Added Masami who's the maintainer of kprobes. -- Steve On Fri, 18 Oct 2019 09:10:25 -0700 Sami Tolvanen wrote: > kprobe_on_func_entry and arch_kprobe_on_func_entry need to be available > even if CONFIG_KRETPROBES is not selected. > > Signed-off-by: Sami Tolvanen > --- > kernel/kprobes.c | 38 +++++++++++++++++++------------------- > 1 file changed, 19 insertions(+), 19 deletions(-) > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > index 53534aa258a6..b5e20a4669b8 100644 > --- a/kernel/kprobes.c > +++ b/kernel/kprobes.c > @@ -1829,6 +1829,25 @@ unsigned long __weak arch_deref_entry_point(void *entry) > return (unsigned long)entry; > } > > +bool __weak arch_kprobe_on_func_entry(unsigned long offset) > +{ > + return !offset; > +} > + > +bool kprobe_on_func_entry(kprobe_opcode_t *addr, const char *sym, unsigned long offset) > +{ > + kprobe_opcode_t *kp_addr = _kprobe_addr(addr, sym, offset); > + > + if (IS_ERR(kp_addr)) > + return false; > + > + if (!kallsyms_lookup_size_offset((unsigned long)kp_addr, NULL, &offset) || > + !arch_kprobe_on_func_entry(offset)) > + return false; > + > + return true; > +} > + > #ifdef CONFIG_KRETPROBES > /* > * This kprobe pre_handler is registered with every kretprobe. When probe > @@ -1885,25 +1904,6 @@ static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs) > } > NOKPROBE_SYMBOL(pre_handler_kretprobe); > > -bool __weak arch_kprobe_on_func_entry(unsigned long offset) > -{ > - return !offset; > -} > - > -bool kprobe_on_func_entry(kprobe_opcode_t *addr, const char *sym, unsigned long offset) > -{ > - kprobe_opcode_t *kp_addr = _kprobe_addr(addr, sym, offset); > - > - if (IS_ERR(kp_addr)) > - return false; > - > - if (!kallsyms_lookup_size_offset((unsigned long)kp_addr, NULL, &offset) || > - !arch_kprobe_on_func_entry(offset)) > - return false; > - > - return true; > -} > - > int register_kretprobe(struct kretprobe *rp) > { > int ret = 0;