From b448ef3c46885b2e713b1fda0b53134d01bb6301 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 23 Feb 2022 17:40:06 -0500 Subject: [PATCH] Fix: lttng: truncated addresses and offsets on 32-bit builds MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The lttng client parses hexadecimal addresses using, at some point, strtoul(). Using this function effectively caps addresses and offsets to MAX_UINT32 resulting in failures to enable kprobes against a 64-bit kernel using a 32-bit client. Signed-off-by: Jérémie Galarneau Change-Id: If619e9e84413de5cd32d8c06f363152caaf5ac46 --- src/bin/lttng/commands/add_trigger.c | 4 ++-- src/bin/lttng/commands/enable_events.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bin/lttng/commands/add_trigger.c b/src/bin/lttng/commands/add_trigger.c index 4395c182b..c1926b4d6 100644 --- a/src/bin/lttng/commands/add_trigger.c +++ b/src/bin/lttng/commands/add_trigger.c @@ -355,7 +355,7 @@ static int parse_kernel_probe_opts(const char *source, PERROR("Failed to copy kernel probe location symbol name."); goto error; } - offset = strtoul(s_hex, NULL, 0); + offset = strtoull(s_hex, NULL, 0); *location = lttng_kernel_probe_location_symbol_create( symbol_name, offset); @@ -401,7 +401,7 @@ static int parse_kernel_probe_opts(const char *source, goto error; } - address = strtoul(s_hex, NULL, 0); + address = strtoull(s_hex, NULL, 0); *location = lttng_kernel_probe_location_address_create(address); if (!*location) { ERR("Failed to create symbol kernel probe location."); diff --git a/src/bin/lttng/commands/enable_events.c b/src/bin/lttng/commands/enable_events.c index 388c5ac36..30d28cb26 100644 --- a/src/bin/lttng/commands/enable_events.c +++ b/src/bin/lttng/commands/enable_events.c @@ -130,7 +130,7 @@ static int parse_probe_opts(struct lttng_event *ev, char *opt) ret = CMD_ERROR; goto end; } - ev->attr.probe.offset = strtoul(s_hex, NULL, 0); + ev->attr.probe.offset = strtoull(s_hex, NULL, 0); DBG("probe offset %" PRIu64, ev->attr.probe.offset); ev->attr.probe.addr = 0; goto end; @@ -164,7 +164,7 @@ static int parse_probe_opts(struct lttng_event *ev, char *opt) ret = CMD_ERROR; goto end; } - ev->attr.probe.addr = strtoul(s_hex, NULL, 0); + ev->attr.probe.addr = strtoull(s_hex, NULL, 0); DBG("probe addr %" PRIu64, ev->attr.probe.addr); ev->attr.probe.offset = 0; memset(ev->attr.probe.symbol_name, 0, LTTNG_SYMBOL_NAME_LEN); -- 2.34.1