X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fkernel.cpp;h=24c3180d5eabcb05310dfbca4d3ea2207674f91e;hb=83885b70dcfbcee908957d8a8057870c6f6c1273;hp=5b4fc086bde52ce333f8cf72cf9f3d627b0cc000;hpb=56047f5a23df5c2c583a102b8015bbec5a7da9f1;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/kernel.cpp b/src/bin/lttng-sessiond/kernel.cpp index 5b4fc086b..24c3180d5 100644 --- a/src/bin/lttng-sessiond/kernel.cpp +++ b/src/bin/lttng-sessiond/kernel.cpp @@ -16,7 +16,6 @@ #include "lttng-syscall.hpp" #include "modprobe.hpp" #include "notification-thread-commands.hpp" -#include "rotate.hpp" #include "sessiond-config.hpp" #include "tracker.hpp" #include "utils.hpp" @@ -63,6 +62,32 @@ static int kernel_tracer_event_notifier_group_fd = -1; static int kernel_tracer_event_notifier_group_notification_fd = -1; static struct cds_lfht *kernel_token_to_event_notifier_rule_ht; +namespace { +/* + * On some architectures, calling convention details are embedded in the symbol + * addresses. Uprobe requires a "clean" symbol offset (or at least, an address + * where an instruction boundary would be legal) to add + * instrumentation. sanitize_uprobe_offset implements that sanitization logic on + * a per-architecture basis. + */ +#if defined(__arm__) || defined(__aarch64__) +static inline uint64_t sanitize_uprobe_offset(uint64_t raw_offset) +{ + /* + * The least significant bit is used when branching to switch to thumb + * ISA. However, it's an invalid address for us; mask the least + * significant bit. + */ + return raw_offset &= ~0b1; +} +#else /* defined(__arm__) || defined(__aarch64__) */ +static inline uint64_t sanitize_uprobe_offset(uint64_t raw_offset) +{ + return raw_offset; +} +#endif +} /* namespace */ + /* * Add context on a kernel channel. * @@ -452,7 +477,7 @@ static int userspace_probe_add_callsite(const struct lttng_userspace_probe_locat goto end; } - callsite.u.uprobe.offset = offset; + callsite.u.uprobe.offset = sanitize_uprobe_offset(offset); ret = kernctl_add_callsite(fd, &callsite); if (ret) { WARN("Failed to add callsite to ELF userspace probe."); @@ -479,7 +504,7 @@ static int userspace_probe_add_callsite(const struct lttng_userspace_probe_locat goto end; } for (i = 0; i < offsets_count; i++) { - callsite.u.uprobe.offset = offsets[i]; + callsite.u.uprobe.offset = sanitize_uprobe_offset(offsets[i]); ret = kernctl_add_callsite(fd, &callsite); if (ret) { WARN("Failed to add callsite to SDT userspace probe");