From b45a296973730d7564a110e16bf50964916be3b7 Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Fri, 1 Oct 2021 16:10:24 -0400 Subject: [PATCH] Fix: userspace-probe: truncating binary path for SDT MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Issue ===== This issue was uncovered when we enabled the testing of the SDT userspace probe instrumentation on the CI, where the paths to file are specially long. The reported error is: - rule: ma-probe-sdt (type: kernel:uprobe, location type: SDT, location: /root/workspace/dev_gerrit_lttng-tools_rootbuild/arch/amd64/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/node/amd64-rootnode/test_type/base/src/lttng-tools/tests/utils/testapp/userspace-probe-sdt-binary/.libs/userspace-probe-sdt-binary:foobar:tp1) + rule: ma-probe-sdt (type: kernel:uprobe, location type: SDT, location: /root/workspace/dev_gerrit_lttng-tools_rootbuild/arch/amd64/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/node/amd64-rootnode/test_type/base/src/lttng-tools/tests/utils/testapp/userspace-probe-sdt-binary/.libs/userspace-probe-s:foobar:tp1) The important part to notice is that the path to the binary is truncated compared to was is expected by the test case. The problem is caused by the `lttng_userspace_probe_location_tracepoint_create_from_payload()` function that strdup() the path string using the wrong defined value. Fix === Use LTTNG_PATH_MAX rather then LTTNG_SYMBOL_NAME_LEN to copy the binary path. Signed-off-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau Change-Id: I24cbf413baba405bf4c4b534ccbc2b18f8d5d43f --- src/common/userspace-probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/userspace-probe.c b/src/common/userspace-probe.c index e5cba5ed2..50795c59c 100644 --- a/src/common/userspace-probe.c +++ b/src/common/userspace-probe.c @@ -1390,7 +1390,7 @@ int lttng_userspace_probe_location_tracepoint_create_from_payload( goto end; } - binary_path = lttng_strndup(binary_path_src, LTTNG_SYMBOL_NAME_LEN); + binary_path = lttng_strndup(binary_path_src, LTTNG_PATH_MAX); if (!binary_path) { PERROR("lttng_strndup"); goto end; -- 2.34.1