From 0d2ff68f1830682b13e903690d6410262dad201e Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 3 Feb 2021 10:21:42 -0500 Subject: [PATCH] Fix: use MT-safe strtok_r in multithreaded context MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit append_list_to_probes uses the non-multithread-safe "strtok" while in multithreaded context. It is called by modprobe_lttng_data(), which is called from init_kernel_tracer(). init_kernel_tracer is used from main() after other threads are created, and also from process_client_msg() when a user attempts to interact with the kernel domain if the kernel tracer has not yet been successfully initialized. Fixed by using the MT-safe strtok_r() instead. Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau Change-Id: Ic3f81551b8508451e0f9733c5de56a4d4407b813 --- src/bin/lttng-sessiond/modprobe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng-sessiond/modprobe.c b/src/bin/lttng-sessiond/modprobe.c index cf9c12b3c..81e32bed9 100644 --- a/src/bin/lttng-sessiond/modprobe.c +++ b/src/bin/lttng-sessiond/modprobe.c @@ -486,7 +486,7 @@ static int append_list_to_probes(const char *list) { char *next; int ret; - char *tmp_list, *cur_list; + char *tmp_list, *cur_list, *saveptr; assert(list); @@ -500,7 +500,7 @@ static int append_list_to_probes(const char *list) size_t name_len; struct kern_modules_param *cur_mod; - next = strtok(cur_list, ","); + next = strtok_r(cur_list, ",", &saveptr); if (!next) { break; } -- 2.34.1