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=-11.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 20E71C433E0 for ; Thu, 28 Jan 2021 00:12:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E088564DCC for ; Thu, 28 Jan 2021 00:12:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231737AbhA1ALm (ORCPT ); Wed, 27 Jan 2021 19:11:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:51004 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231158AbhA1AKa (ORCPT ); Wed, 27 Jan 2021 19:10:30 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0491164DD4; Thu, 28 Jan 2021 00:09:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611792579; bh=yIpnzFhNO8N5c81rba3vMGRndNhLraXNGRD2B4tTl70=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=JoF8gimer+Mt/jrIl4dXfxH+0bSuhkYTJBBVrCqI7ppCwLVoM5shYYUCJrjT1s/JI tNUXWBhLOrHEgu8sKcd+ZiRK3ksioiMx/74ywrLJsTRn7IOF2c1f+HVL3N2Y9Z2nAN ZoNXHGk8JFhRCCM6pqo6tYTtPIfPvTCvTyyAwxQMfivf/RoG3OfW9TBqeA1vLY5vzB WX+71wAUk1r18HPIjbB8oLwbU3wb/GdYYUuMom2jdbW+PN5HDpcBM2QgFN+0vRXCAV 8puZKwa0zD6gpDnbXUOdGFyk8YUTEsETLlc1VEw8dp/G9oTKMgQahMLwy3d8sqNUpL OK2GiHwV69vCg== Date: Thu, 28 Jan 2021 09:09:35 +0900 From: Masami Hiramatsu To: Steven Rostedt Cc: Jianlin Lv , Oleg Nesterov , Ingo Molnar , linux-kernel@vger.kernel.org Subject: Re: [PATCH] tracing/kprobe: Fix to support kretprobe events on unloaded modules Message-Id: <20210128090935.719ac21fbfa2b6cfc91dea9c@kernel.org> In-Reply-To: <20210127172950.7911317a@gandalf.local.home> References: <161176187132.1067016.8118042342894378981.stgit@devnote2> <20210127172950.7911317a@gandalf.local.home> X-Mailer: Sylpheed 3.7.0 (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: linux-kernel@vger.kernel.org On Wed, 27 Jan 2021 17:29:50 -0500 Steven Rostedt wrote: > On Thu, 28 Jan 2021 00:37:51 +0900 > Masami Hiramatsu wrote: > > > Fix kprobe_on_func_entry() returns error code instead of false so that > > register_kretprobe() can return an appropriate error code. > > > > append_trace_kprobe() expects the kprobe registration returns -ENOENT > > when the target symbol is not found, and it checks whether the target > > module is unloaded or not. If the target module doesn't exist, it > > defers to probe the target symbol until the module is loaded. > > > > However, since register_kretprobe() returns -EINVAL instead of -ENOENT > > in that case, it always fail on putting the kretprobe event on unloaded > > modules. e.g. > > > > Kprobe event: > > /sys/kernel/debug/tracing # echo p xfs:xfs_end_io >> kprobe_events > > [ 16.515574] trace_kprobe: This probe might be able to register after target module is loaded. Continue. > > > > Kretprobe event: (p -> r) > > /sys/kernel/debug/tracing # echo r xfs:xfs_end_io >> kprobe_events > > sh: write error: Invalid argument > > /sys/kernel/debug/tracing # cat error_log > > [ 41.122514] trace_kprobe: error: Failed to register probe event > > Command: r xfs:xfs_end_io > > ^ > > > > To fix this bug, change kprobe_on_func_entry() to detect symbol lookup > > failure and return -ENOENT in that case. Otherwise it returns -EINVAL > > or 0 (succeeded, given address is on the entry). > > > > Reported-by: Jianlin Lv > > Signed-off-by: Masami Hiramatsu > > Is this something that should go to stable? And if so, can you supply a > Fixes tag? Yes, I thought that had not supported previously, but that's wrong. I found below commit introduced -ENOENT check in trace_kprobe side. Fixes: 59158ec4aef7 ("tracing/kprobes: Check the probe on unloaded module correctly") Thank you, -- Masami Hiramatsu