Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp614322pxb; Wed, 27 Jan 2021 16:50:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRDzIhi/jS9eObnb6LteK4Hi+0FXYc56K2aAlHuZXeSwq6L/Lg5WZ2F0Cf3Ek5AxfYqxPS X-Received: by 2002:a17:906:b41:: with SMTP id v1mr8748537ejg.277.1611795021952; Wed, 27 Jan 2021 16:50:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611795021; cv=none; d=google.com; s=arc-20160816; b=Tyvfa/YvGaLoUNFapHnfFUaSE8ljwd9fbVB8bv42St0XGOeD/EA9Pp+m16O/Y5y7qC CNrZEItD/r7xGti7/Ld+XKb5OM6nAvkWtGSXie5J1ZZ/HSN5iqtboQ3yXXI6EXvdfpWm BynHmqa48ETmWpbuW2mBbdpKJL08wpBhDSVJz75/pBBNWSSbw25TKIEc3MnMJV6HJyKM nwzpZoV22sQdi6G1loxRhZ2AeEw2rEqfHAhu57IF/P6oIE9hRduZhGbUy37lOXlhJGt7 KmnrKvQL2JZ87hRxyYzr0xbygEv66btRIUpovpUKrcGxAwN4BZ71MBTr+9gcnv2+HhIC UJ6Q== 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 :dkim-signature; bh=uPToJq1lhCLh+rJFKXgV3sVbVTfyx31XksRLPP5xT+0=; b=jasTgl1O3HsOHUXtLbF2X2a4zvKkcRAxRrVEMB/hv5InMzuyrWH1+vn/qoZoZt07YK b/N3fUV+g7K7MPCbbyX7iFrkurAWs2Uj3W8nj1/kaDYTUh8g13DJosxFR401EClbXoUI MzVKSeeQF5ZYo1b32fol2qvOe5jGOQ40kfyesL7gaz38iDwTbe3FTbh0xJbsEhBMYIca 19qln+8/DfZQt2NPNXkxW9xeezRbnLzVH0RiVgSeegqDsQR9S9nC3i2iDMnp7Rru9FRg jwVatHrH01GkTuAE7ZZMy+LOtJ99v0bqZ5KRx0tSADIJZZqfIXNmiYsc0wes8Knx11K1 XW/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JoF8gime; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m15si1451511eje.225.2021.01.27.16.49.57; Wed, 27 Jan 2021 16:50:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JoF8gime; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229835AbhA1ALg (ORCPT + 99 others); Wed, 27 Jan 2021 19:11:36 -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