Fix: lttng: truncated addresses and offsets on 32-bit builds
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 23 Feb 2022 22:40:06 +0000 (17:40 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 28 Feb 2022 21:46:11 +0000 (16:46 -0500)
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 <jeremie.galarneau@efficios.com>
Change-Id: If619e9e84413de5cd32d8c06f363152caaf5ac46

src/bin/lttng/commands/add_trigger.cpp
src/bin/lttng/commands/enable_events.cpp

index b09a1bf82dce418468c7e03fb52e32d8415a1873..85a75256472cc23c8e125679add23389f1719e98 100644 (file)
@@ -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.");
index 451a1eade8ce182eea37d94372cbeadca2b2ac5b..a2db2cbc22884f3a51c2c1355e42478075deb2d3 100644 (file)
@@ -129,7 +129,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;
@@ -163,7 +163,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);
This page took 0.027123 seconds and 4 git commands to generate.