Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp344010rbe; Thu, 29 Feb 2024 00:52:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVIpXGHVgZOz49tvxwn2+CVgGvz82pmm+cdnCPd+Ylj+mjCR5imNFClf9iS6oDkY/347aLW5ak3BI+DU2iE7JQ2cJlbKGwYUDW0zoeuFg== X-Google-Smtp-Source: AGHT+IHnGx0VnTM+GcWr+g+7spf5ejS5nBdkYeWBaXL4BCojeReZmV8xI4aOVOCArm6rlAdiJ29I X-Received: by 2002:a17:906:a291:b0:a40:2c33:1f42 with SMTP id i17-20020a170906a29100b00a402c331f42mr934081ejz.15.1709196767026; Thu, 29 Feb 2024 00:52:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709196767; cv=pass; d=google.com; s=arc-20160816; b=ujsKp3/zA5pYcciintx9kQ8wP2+ifUB89M8dAAOEWQbB3BrNho5bC3446y7M5uFvCi NVQfoq+Uctn4d9ek3+6PnAcWZVWa6tf+lrvX/N9hLESS9+aOnxO5ojBw+Klg05Ot7NVn tnyohaQWAGDVxkDdTCAyB21MCMwvZ3nEtE7cYToXtYSRhSJ2fOWUzyYAEe8MGUbeMeRk nRS+80fNNlqLbH8QDZRNswfBIE8tNJM76N4y7LBwMxUk+O5dUlhNDibEQV/JC0UOxtxw JvvahdFtayc/aD+t+ZBjMtRfFbLDwoI8QvSSSrt/TwNpqG0iV6Q3xYwjW7AcV4SWYqbF y38Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=oZTnmQoQVrQ1P+f+OcICTUT3BEU9LJmx8Bzts73pgr8=; fh=GZ3hBNN7A3v/lButcpOijLAs06CZYqAhqOKWAt+e9fU=; b=rbZL4CJaNHu0Kkk7DXeol2ZeoVzuXCYSR89KREPlYmSPqmMqHImt7OiL46lHTqa/H5 Jg8peYOQmRAE6phreKjpqg7tO7WBx9gKzhLrNSY5vWFCktc1Cjt9/M+3C8UET3+SvabS 4lIYSMCypfGv6sf6MSvRqOKfslTgcnwj1vz/0HCPCfWQMfYbT+9mWyD8YDwpeUGGEbYU cobmmON6duQDvsXsQwb+dGkmP/uuKPFhcaOddOXAjsQrautOc1RVJJowr1RzDTbtl+vs HRuGPAV3s24lVvOEmAml2WN338grZer2qe/Mu5sn9imxDiA+hiw3AatB1vHFJPxaiy5u w+TA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qNexrZMo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-86347-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86347-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g12-20020a170906198c00b00a440be663f0si398421ejd.44.2024.02.29.00.52.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 00:52:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86347-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qNexrZMo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-86347-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86347-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C70751F25DBF for ; Thu, 29 Feb 2024 08:52:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D16D156460; Thu, 29 Feb 2024 08:52:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qNexrZMo" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC63454FA9; Thu, 29 Feb 2024 08:52:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709196742; cv=none; b=owYsw1+F8bm6j8izg+D/Z/Q+BBESBQqwbGqxvyuQuSvBTKdmJwCH3zuNiXuEq0mYPUR+bCt2r/CTZqKi9p/X1fXq1kZUudTDiLhpADk5WZW7hp8UNxwL1O6PTlkYhsKpSt44kg7G3dznyKkJPgbFPe2a5KBd5YqmohQdTdlS0Zc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709196742; c=relaxed/simple; bh=h+PuR60VQc/pChn5sYT/Cgrh7xTZzneJkEBH+LhG32A=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=GAmtraSvhxoHkBrhSjAYxnwntz32AqE5EaydNcKkoo6G2cQM22S3CTEwX5I9/Sg3EWBjD3xR+WOunWktUrkG4ukOjIrUBya2Ms5+DwypwUjajYUOl+Lqi/JD/LxT6SfsDJd4R51ST9XdcWH/xl7C9v5TzlVnQZmR5NbwIwvYS8Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qNexrZMo; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD97AC43394; Thu, 29 Feb 2024 08:52:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709196741; bh=h+PuR60VQc/pChn5sYT/Cgrh7xTZzneJkEBH+LhG32A=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qNexrZMoKDoA+1DL96h/s746iYZhicncl4TcZHi5yY/4ffvbifGSPwHxX9FfBhebE mbNHdhPCjXkAyKyemDbgdBGGlDMkah6Zdkah5W17aWF1UMAbje+8vWgFVQ0KArY0nk Oxfb9RyLZTkEPZ0ck80RicUdHVvVxgPZOxKMWwstb/CA7VNVbmuA3+yLRxUDMAnUS4 w5gpw3dWvpfzet0SzyPlBLkQ415JXPCARdytJ8aAdJiAnZr8kUjv/qtlQPoUS/rTxR tU3prhQJQ0CmLrPm3emcsK9rHRm6AFJtgMlLqh9/qsoF03SiO94geK78G+9d/WptWI cFaVzYODZ3dJQ== Date: Thu, 29 Feb 2024 17:52:16 +0900 From: Masami Hiramatsu (Google) To: Masami Hiramatsu (Google) Cc: Jiri Olsa , Steven Rostedt , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v2 0/7] tracing/probes: Support function parameter access from return probe Message-Id: <20240229175216.96bb2e16b510f81e3802ef23@kernel.org> In-Reply-To: <20240229161320.978190f42dcc1a521c192e7d@kernel.org> References: <170891987362.609861.6767830614537418260.stgit@devnote2> <20240229145139.a215085c44add62302463312@kernel.org> <20240229153855.6fe3fb454cf56eebc6ea9953@kernel.org> <20240229161320.978190f42dcc1a521c192e7d@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 29 Feb 2024 16:13:20 +0900 Masami Hiramatsu (Google) wrote: > On Thu, 29 Feb 2024 15:38:55 +0900 > Masami Hiramatsu (Google) wrote: > > > Hmm, this seems arch_rethook_trampoline caused the issue. > > > > And curiously, it depends on the number of stored data. > > > > OK: > > /sys/kernel/tracing # echo 'f vfs_read%return $arg1 $arg2 $arg3' >> dynamic_events > > /sys/kernel/tracing # echo 1 > events/fprobes/enable > > > > NG: > > /sys/kernel/tracing # echo 'f vfs_read%return $arg1 $arg2 $arg3 $arg4' >> dynamic_events > > /sys/kernel/tracing # echo 1 > events/fprobes/enable > > > > I also confirmed that on 'vfs_write' caused the same result. 3 arguments(24 bytes) is OK, > > but 4 arguments (32bytes) is NG. > > And this may be the fprobe bug. kretprobe events doesn't show this issue. > > OK: > /sys/kernel/tracing # echo 'r vfs_read $arg*' >> kprobe_events > /sys/kernel/tracing # echo 1 > events/kprobes/enable > > But this is strange because both uses same rethook... Lol, I haven't allocate the entry data size when initialize rethook. That's a bug. Please try below. diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c index 6cd2a4e3afb8..9ff018245840 100644 --- a/kernel/trace/fprobe.c +++ b/kernel/trace/fprobe.c @@ -189,9 +189,6 @@ static int fprobe_init_rethook(struct fprobe *fp, int num) { int size; - if (num <= 0) - return -EINVAL; - if (!fp->exit_handler) { fp->rethook = NULL; return 0; @@ -199,15 +196,16 @@ static int fprobe_init_rethook(struct fprobe *fp, int num) /* Initialize rethook if needed */ if (fp->nr_maxactive) - size = fp->nr_maxactive; + num = fp->nr_maxactive; else - size = num * num_possible_cpus() * 2; - if (size <= 0) + num *= num_possible_cpus() * 2; + if (num <= 0) return -EINVAL; + size = sizeof(struct fprobe_rethook_node) + fp->entry_data_size; + /* Initialize rethook */ - fp->rethook = rethook_alloc((void *)fp, fprobe_exit_handler, - sizeof(struct fprobe_rethook_node), size); + fp->rethook = rethook_alloc((void *)fp, fprobe_exit_handler, size, num); if (IS_ERR(fp->rethook)) return PTR_ERR(fp->rethook); -- Masami Hiramatsu (Google)