Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'probes-fixes-v6.14-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull probes fixes from Masami Hiramatsu:

- Clean up tprobe correctly when module unload

Tracepoint probes do not set TRACEPOINT_STUB on the 'tpoint' pointer
when unloading a module, thus they show as a normal 'fprobe' instead
of 'tprobe' and never come back

- Fix leakage of tprobe module refcount

When a tprobe's target module is loaded, it gets the module's
refcount in the module notifier but forgot to put it after
registering the probe on it.

Fix it by getting the refcount only when registering tprobe.

* tag 'probes-fixes-v6.14-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
tracing: tprobe-events: Fix leakage of module refcount
tracing: tprobe-events: Fix to clean up tprobe correctly when module unload

+14 -16
+14 -16
kernel/trace/trace_fprobe.c
··· 920 920 921 921 if (!data->tpoint && !strcmp(data->tp_name, tp->name)) { 922 922 data->tpoint = tp; 923 - if (!data->mod) { 923 + if (!data->mod) 924 924 data->mod = mod; 925 - if (!try_module_get(data->mod)) { 926 - data->tpoint = NULL; 927 - data->mod = NULL; 928 - } 929 - } 930 925 } 931 926 } 932 927 ··· 933 938 data->tpoint = tp; 934 939 } 935 940 936 - /* 937 - * Find a tracepoint from kernel and module. If the tracepoint is in a module, 938 - * this increments the module refcount to prevent unloading until the 939 - * trace_fprobe is registered to the list. After registering the trace_fprobe 940 - * on the trace_fprobe list, the module refcount is decremented because 941 - * tracepoint_probe_module_cb will handle it. 942 - */ 941 + /* Find a tracepoint from kernel and module. */ 943 942 static struct tracepoint *find_tracepoint(const char *tp_name, 944 943 struct module **tp_mod) 945 944 { ··· 962 973 } 963 974 } 964 975 976 + /* Find a tracepoint from specified module. */ 965 977 static struct tracepoint *find_tracepoint_in_module(struct module *mod, 966 978 const char *tp_name) 967 979 { ··· 998 1008 reenable_trace_fprobe(tf); 999 1009 } 1000 1010 } else if (val == MODULE_STATE_GOING && tp_mod->mod == tf->mod) { 1001 - tracepoint_probe_unregister(tf->tpoint, 1011 + unregister_fprobe(&tf->fp); 1012 + if (trace_fprobe_is_tracepoint(tf)) { 1013 + tracepoint_probe_unregister(tf->tpoint, 1002 1014 tf->tpoint->probestub, NULL); 1003 - tf->tpoint = NULL; 1004 - tf->mod = NULL; 1015 + tf->tpoint = TRACEPOINT_STUB; 1016 + tf->mod = NULL; 1017 + } 1005 1018 } 1006 1019 } 1007 1020 mutex_unlock(&event_mutex); ··· 1169 1176 if (is_tracepoint) { 1170 1177 ctx->flags |= TPARG_FL_TPOINT; 1171 1178 tpoint = find_tracepoint(symbol, &tp_mod); 1179 + /* lock module until register this tprobe. */ 1180 + if (tp_mod && !try_module_get(tp_mod)) { 1181 + tpoint = NULL; 1182 + tp_mod = NULL; 1183 + } 1172 1184 if (tpoint) { 1173 1185 ctx->funcname = kallsyms_lookup( 1174 1186 (unsigned long)tpoint->probestub,