Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2425891rwb; Sat, 24 Sep 2022 08:08:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4AZlDLIMBilgbRcE4TokJkKUonhYzrcc99RxRRlYPDdCRYfeDcLkTp2e4UDsSYXYDAWDdG X-Received: by 2002:a63:3508:0:b0:439:57e4:5859 with SMTP id c8-20020a633508000000b0043957e45859mr12644259pga.54.1664032131246; Sat, 24 Sep 2022 08:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664032131; cv=none; d=google.com; s=arc-20160816; b=kL91LGMdiLKQqA2L6Kys/I5nlU1+KHiHFQzm/LG6T8PLMkXMZgcr5NGNbZwLDPBFf/ VE3J9Gq7c6oqwPeVaVSTAozzhqCanlLiapS/yHN+h/GWsqKyfmJXcPw3Nxhix0wg2TWk Funb+DbhoGl3GHE+xflzcBsIRhTV47j8JiqOytVAakfAc+g9bx9nBBT+44zPtQB7qmLv PBcHXlxN464z8p87lT+aNYKl4vFbCcWRQ+awAtdgXQWegMebWr0h8UMBq3ZPVrpWoZ11 xsS0LY7eeZqrGR6e7UZO9ZbskkXkZbvtp9oqqlGDljbFMK2553nqh8W8QeOu7cfvWaOK ymLg== 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=3qHbwQsGRMrL6x5ukzIGARktqjtWFS0OPnIAQa3Rf5s=; b=gNXHfgJyMyUaTtr5sz8G12RFX2UEwKe7lh6as9GqpzcAiUpNx0H+oYQN5UisUbj51N nEg//cBq/arAEiIYGm1Q+YiSTZz92wJdTIoVAIm0HrC34b2cEJ7TJVgMsUNPa6BPrSQl cbXBuK0nAZNZ0qxTKutEDm/derhpiXsJGHkznn9ZFdS21Yt10aEXDwzU/wuqOhSmmooU ImN3bQYJE5E7QSyEw0iDu066eeyAF/kPvMHAjKpaLqg+k+mFRCsegV07cRe/XO6/rYCt KK70GiS+wPTfHMDl2SYJOxDrKE3wMa4YzNHXdNJ5T5Oa5H2rlz8OsjOGlH1PQgHIn8dp bTtQ== 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 ck10-20020a17090afe0a00b001fe41707a2esi5436794pjb.90.2022.09.24.08.08.35; Sat, 24 Sep 2022 08:08:51 -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 S231324AbiIXPBV (ORCPT + 99 others); Sat, 24 Sep 2022 11:01:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230249AbiIXPBT (ORCPT ); Sat, 24 Sep 2022 11:01:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B140413F22 for ; Sat, 24 Sep 2022 08:01:17 -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 62114B80AE2 for ; Sat, 24 Sep 2022 15:01:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B02BC433C1; Sat, 24 Sep 2022 15:01:14 +0000 (UTC) Date: Sat, 24 Sep 2022 11:01:13 -0400 From: Steven Rostedt To: Song Liu Cc: , , "Naveen N . Rao" Subject: Re: [PATCH] ftrace: fix recursive locking direct_mutex in ftrace_modify_direct_caller Message-ID: <20220924110113.64c6701b@rorschach.local.home> In-Reply-To: <20220919172955.1196326-1-song@kernel.org> References: <20220919172955.1196326-1-song@kernel.org> 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, 19 Sep 2022 10:29:55 -0700 Song Liu wrote: > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index 439e2ab6905e..d308d0674805 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -5461,7 +5461,7 @@ int __weak ftrace_modify_direct_caller(struct ftrace_func_entry *entry, > if (ret) > goto out_lock; > > - ret = register_ftrace_function(&stub_ops); > + ret = register_ftrace_function_nolock(&stub_ops); > if (ret) { > ftrace_set_filter_ip(&stub_ops, ip, 1, 0); > goto out_lock; > -- We need to update the comments to this function, as well add an: #define lock_direct_assert_held() lockdep_assert_held(&direct_mutex); And call that in this function. Otherwise, we can be calling this code without it held and cause races. -- Steve