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=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=no 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 DF7BEC4363A for ; Thu, 29 Oct 2020 14:37:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C4FB20825 for ; Thu, 29 Oct 2020 14:37:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727290AbgJ2Ohs (ORCPT ); Thu, 29 Oct 2020 10:37:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:54402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726676AbgJ2Ohr (ORCPT ); Thu, 29 Oct 2020 10:37:47 -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 3FEE7204EF; Thu, 29 Oct 2020 14:37:46 +0000 (UTC) Date: Thu, 29 Oct 2020 10:37:44 -0400 From: Steven Rostedt To: Miroslav Benes Cc: linux-kernel@vger.kernel.org, Masami Hiramatsu , Andrew Morton , Josh Poimboeuf , Jiri Kosina , Petr Mladek , Joe Lawrence , live-patching@vger.kernel.org Subject: Re: [PATCH 6/9] livepatch/ftrace: Add recursion protection to the ftrace callback Message-ID: <20201029103744.0f7f52dc@gandalf.local.home> In-Reply-To: References: <20201028115244.995788961@goodmis.org> <20201028115613.291169246@goodmis.org> 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 Precedence: bulk List-ID: X-Mailing-List: live-patching@vger.kernel.org On Thu, 29 Oct 2020 14:51:06 +0100 (CET) Miroslav Benes wrote: > > index b552cf2d85f8..6c0164d24bbd 100644 > > --- a/kernel/livepatch/patch.c > > +++ b/kernel/livepatch/patch.c > > @@ -45,9 +45,13 @@ static void notrace klp_ftrace_handler(unsigned long ip, > > struct klp_ops *ops; > > struct klp_func *func; > > int patch_state; > > + int bit; > > > > ops = container_of(fops, struct klp_ops, fops); > > > > + bit = ftrace_test_recursion_trylock(); > > + if (bit < 0) > > + return; > > This means that the original function will be called in case of recursion. > That's probably fair, but I'm wondering if we should at least WARN about > it. It's probably what happens today. But if you add a WARN_ON_ONCE() it may not hurt. I also plan on adding code that reports when recursion has happened, because even if it's not a problem, recursion adds extra overhead. -- Steve