Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1832229rwd; Tue, 13 Jun 2023 15:08:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7L+pxfk7Cwwhyb218Moral4XFacWxHFDRiuaKAzrgo/HHwBIdBTeHiO8T1QtpbciIaKgH2 X-Received: by 2002:a05:6a21:3885:b0:10f:a954:47d1 with SMTP id yj5-20020a056a21388500b0010fa95447d1mr19599pzb.38.1686694135381; Tue, 13 Jun 2023 15:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686694135; cv=none; d=google.com; s=arc-20160816; b=gmhFBEFcqnk9n+ze1uSJTIsCjwsAXItzNyiBjws6OkZRD9o6w32QuRIBt/ll+d2ETZ mBfocted29063epCOA+vunH7bnxO4hKw86ZLF6tp1uiaT4GSQmO5MP0El/Nnj64N/ecG ySHGDRXaPo8YUVoiauHgBCBF1BHKvzDeDdoFw2cHubPFQ7QB7ELy7m/Whu+a4jlfy7g1 5S+uwKZp5uwznB1byVEb+dpeByiLAHtcc5mPFapLIk1HBK3HxvogeyQ+DKVr6K1T/yba t2+4TNOXhA4JfSSMm6rIGgKyzWqtWVOfQu6yY5FhcWY+HDZC+7f5LPzr8hSBF8r+OWNd 0zag== 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=oNKxsBUOawdFojma0hVFoGwq5648YN49viTHO5KMT84=; b=tlIy7xn1ynHw8eMo3mMBTzFa0boXl7kk4eX/TP7jo/5mtHWWpcOqcOwItUggL6jsnB bPyR6B1JRtlS5nRUkoc5hE5hnILrlfCL+MkBVkTquNeNl1HnNiyGmOlyC6uZv/UrrlMw VnraaIFErQYhyp/LQmgZAaE/D7JZphg75+9RsejtfqN5rQWosgKwCgr2X+UguMsz+8nv Yo+wlCI943qRLyjbIXo+gxxLyIG+/dCFTN8lgaToq57gY1xmxwKduY669PsNYiHkV/tx xtBXooLM5XSK3rZP14BOTtn37N07W58rcUHdxGtWzSphgkNp3qaP6eRjO5vQ66GqzJc6 YQAg== 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 f15-20020a170902ce8f00b001afe7ef68b6si6044227plg.452.2023.06.13.15.08.42; Tue, 13 Jun 2023 15:08:55 -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 S232258AbjFMVsz (ORCPT + 99 others); Tue, 13 Jun 2023 17:48:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234300AbjFMVsx (ORCPT ); Tue, 13 Jun 2023 17:48:53 -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 CCD441BD2; Tue, 13 Jun 2023 14:48:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6238B63B41; Tue, 13 Jun 2023 21:48:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F151C433C8; Tue, 13 Jun 2023 21:48:47 +0000 (UTC) Date: Tue, 13 Jun 2023 17:48:44 -0400 From: Steven Rostedt To: Jiri Olsa Cc: "Masami Hiramatsu (Google)" , LKML , Linux Trace Kernel , bpf@vger.kernel.org Subject: Re: [RFC] fprobe call of rethook_try_get faults Message-ID: <20230613174844.4d50991d@gandalf.local.home> In-Reply-To: References: 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=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Wed, 7 Jun 2023 09:42:30 -0700 Jiri Olsa wrote: > I can't really reliable reproduce this, but while checking the code, I wonder > we should call rethook_free only after we call unregister_ftrace_function like > in the patch below Yeah, I think you're right! > > jirka > > > --- > diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c > index 18d36842faf5..0121e8c0d54e 100644 > --- a/kernel/trace/fprobe.c > +++ b/kernel/trace/fprobe.c > @@ -364,19 +364,13 @@ int unregister_fprobe(struct fprobe *fp) > fp->ops.saved_func != fprobe_kprobe_handler)) > return -EINVAL; > > - /* > - * rethook_free() starts disabling the rethook, but the rethook handlers > - * may be running on other processors at this point. To make sure that all > - * current running handlers are finished, call unregister_ftrace_function() > - * after this. > - */ > - if (fp->rethook) > - rethook_free(fp->rethook); The above only waits for RCU to finish and then starts to free rethook. This also means that something could be on the trampoline already and was preempted. It could be that this code path gets preempted. Anyway, I don't see how freeing rethook is safe before disabling all users. Reviewed-by: Steven Rostedt (Google) -- Steve > - > ret = unregister_ftrace_function(&fp->ops); > if (ret < 0) > return ret; > > + if (fp->rethook) > + rethook_free(fp->rethook); > + > ftrace_free_filter(&fp->ops); > > return ret;