History

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

Pull kprobes updates from Masami Hiramatsu: - Skip negative return code check for snprintf in eprobe - Add recursive call test cases for kprobe unit test - Add 'char' type to probe events to show it as the character instead of value - Update kselftest kprobe-event testcase to ignore '__pfx_' symbols - Fix kselftest to check filter on eprobe event correctly - Add filter on eprobe to the README file in tracefs - Fix optprobes to check whether there is 'under unoptimizing' optprobe when optimizing another kprobe correctly - Fix optprobe to check whether there is 'under unoptimizing' optprobe when fetching the original instruction correctly - Fix optprobe to free 'forcibly unoptimized' optprobe correctly * tag 'probes-v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tracing/eprobe: no need to check for negative ret value for snprintf test_kprobes: Add recursed kprobe test case tracing/probe: add a char type to show the character value of traced arguments selftests/ftrace: Fix probepoint testcase to ignore __pfx_* symbols selftests/ftrace: Fix eprobe syntax test case to check filter support tracing/eprobe: Fix to add filter on eprobe description in README file x86/kprobes: Fix arch_check_optimized_kprobe check within optimized_kprobe range x86/kprobes: Fix __recover_optprobed_insn check optimizing logic kprobes: Fix to handle forcibly unoptimized kprobes on freeing_list

Linus Torvalds committed 3 years ago

Commit 2b79eb72 parents 0df8218 c96abae12 files · +117 −33Browse files

Showing the changes to kernel (5 of 12 files). Show all

Unified · Split

5 files
  1. kernel/kprobes.c +12 −15
  2. kernel/trace/trace.c +2 −2
  3. kernel/trace/trace_eprobe.c +4 −8
  4. kernel/trace/trace_probe.c +2 −0
  5. kernel/trace/trace_probe.h +1 −0
kernel/kprobes.c+12−15
@@ -458,7 +458,7 @@ static inline int kprobe_optready(struct kprobe *p) · 457 unmodified lines
458}458}
459 459
460/* Return true if the kprobe is disarmed. Note: p must be on hash list */460/* Return true if the kprobe is disarmed. Note: p must be on hash list */
461static inline bool kprobe_disarmed(struct kprobe *p)461bool kprobe_disarmed(struct kprobe *p)
462{462{
463 struct optimized_kprobe *op;463 struct optimized_kprobe *op;
464 464
@@ -555,17 +555,15 @@ static void do_unoptimize_kprobes(void) · 90 unmodified lines
555 /* See comment in do_optimize_kprobes() */555 /* See comment in do_optimize_kprobes() */
556 lockdep_assert_cpus_held();556 lockdep_assert_cpus_held();
557 557
558 /* Unoptimization must be done anytime */558 if (!list_empty(&unoptimizing_list))
559 if (list_empty(&unoptimizing_list))559 arch_unoptimize_kprobes(&unoptimizing_list, &freeing_list);
560 return;
561 560
562 arch_unoptimize_kprobes(&unoptimizing_list, &freeing_list);561 /* Loop on 'freeing_list' for disarming and removing from kprobe hash list */
563 /* Loop on 'freeing_list' for disarming */
564 list_for_each_entry_safe(op, tmp, &freeing_list, list) {562 list_for_each_entry_safe(op, tmp, &freeing_list, list) {
565 /* Switching from detour code to origin */563 /* Switching from detour code to origin */
566 op->kp.flags &= ~KPROBE_FLAG_OPTIMIZED;564 op->kp.flags &= ~KPROBE_FLAG_OPTIMIZED;
567 /* Disarm probes if marked disabled */565 /* Disarm probes if marked disabled and not gone */
568 if (kprobe_disabled(&op->kp))566 if (kprobe_disabled(&op->kp) && !kprobe_gone(&op->kp))
569 arch_disarm_kprobe(&op->kp);567 arch_disarm_kprobe(&op->kp);
570 if (kprobe_unused(&op->kp)) {568 if (kprobe_unused(&op->kp)) {
571 /*569 /*
@@ -662,7 +660,7 @@ void wait_for_kprobe_optimizer(void) · 90 unmodified lines
662 mutex_unlock(&kprobe_mutex);660 mutex_unlock(&kprobe_mutex);
663}661}
664 662
665static bool optprobe_queued_unopt(struct optimized_kprobe *op)663bool optprobe_queued_unopt(struct optimized_kprobe *op)
666{664{
667 struct optimized_kprobe *_op;665 struct optimized_kprobe *_op;
668 666
@@ -797,14 +795,13 @@ static void kill_optimized_kprobe(struct kprobe *p) · 128 unmodified lines
797 op->kp.flags &= ~KPROBE_FLAG_OPTIMIZED;795 op->kp.flags &= ~KPROBE_FLAG_OPTIMIZED;
798 796
799 if (kprobe_unused(p)) {797 if (kprobe_unused(p)) {
800 /* Enqueue if it is unused */
801 list_add(&op->list, &freeing_list);
802 /*798 /*
803 * Remove unused probes from the hash list. After waiting799 * Unused kprobe is on unoptimizing or freeing list. We move it
804 * for synchronization, this probe is reclaimed.800 * to freeing_list and let the kprobe_optimizer() remove it from
805 * (reclaiming is done by do_free_cleaned_kprobes().)801 * the kprobe hash list and free it.
806 */802 */
807 hlist_del_rcu(&op->kp.hlist);803 if (optprobe_queued_unopt(op))
804 list_move(&op->list, &freeing_list);
808 }805 }
809 806
810 /* Don't touch the code, because it is already freed. */807 /* Don't touch the code, because it is already freed. */
kernel/trace/trace.c+2−2
@@ -5646,7 +5646,7 @@ static const char readme_msg[] = · 5645 unmodified lines
5646#ifdef CONFIG_HIST_TRIGGERS5646#ifdef CONFIG_HIST_TRIGGERS
5647 "\t s:[synthetic/]<event> <field> [<field>]\n"5647 "\t s:[synthetic/]<event> <field> [<field>]\n"
5648#endif5648#endif
5649 "\t e[:[<group>/][<event>]] <attached-group>.<attached-event> [<args>]\n"5649 "\t e[:[<group>/][<event>]] <attached-group>.<attached-event> [<args>] [if <filter>]\n"
5650 "\t -:[<group>/][<event>]\n"5650 "\t -:[<group>/][<event>]\n"
5651#ifdef CONFIG_KPROBE_EVENTS5651#ifdef CONFIG_KPROBE_EVENTS
5652 "\t place: [<module>:]<symbol>[+<offset>]|<memaddr>\n"5652 "\t place: [<module>:]<symbol>[+<offset>]|<memaddr>\n"
@@ -5663,7 +5663,7 @@ static const char readme_msg[] = · 10 unmodified lines
5663 "\t $stack<index>, $stack, $retval, $comm,\n"5663 "\t $stack<index>, $stack, $retval, $comm,\n"
5664#endif5664#endif
5665 "\t +|-[u]<offset>(<fetcharg>), \\imm-value, \\\"imm-string\"\n"5665 "\t +|-[u]<offset>(<fetcharg>), \\imm-value, \\\"imm-string\"\n"
5666 "\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, string, symbol,\n"5666 "\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, char, string, symbol,\n"
5667 "\t b<bit-width>@<bit-offset>/<container-size>, ustring,\n"5667 "\t b<bit-width>@<bit-offset>/<container-size>, ustring,\n"
5668 "\t symstr, <type>\\[<array-size>\\]\n"5668 "\t symstr, <type>\\[<array-size>\\]\n"
5669#ifdef CONFIG_HIST_TRIGGERS5669#ifdef CONFIG_HIST_TRIGGERS
kernel/trace/trace_eprobe.c+4−8
@@ -923,17 +923,13 @@ static int trace_eprobe_parse_filter(struct trace_eprobe *ep, int argc, const ch · 922 unmodified lines
923 923
924 p = ep->filter_str;924 p = ep->filter_str;
925 for (i = 0; i < argc; i++) {925 for (i = 0; i < argc; i++) {
926 ret = snprintf(p, len, "%s ", argv[i]);926 if (i)
927 if (ret < 0)927 ret = snprintf(p, len, " %s", argv[i]);
928 goto error;928 else
929 if (ret > len) {929 ret = snprintf(p, len, "%s", argv[i]);
930 ret = -E2BIG;
931 goto error;
932 }
933 p += ret;930 p += ret;
934 len -= ret;931 len -= ret;
935 }932 }
936 p[-1] = '\0';
937 933
938 /*934 /*
939 * Ensure the filter string can be parsed correctly. Note, this935 * Ensure the filter string can be parsed correctly. Note, this
kernel/trace/trace_probe.c+2−0
@@ -50,6 +50,7 @@ DEFINE_BASIC_PRINT_TYPE_FUNC(x8, u8, "0x%x") · 49 unmodified lines
50DEFINE_BASIC_PRINT_TYPE_FUNC(x16, u16, "0x%x")50DEFINE_BASIC_PRINT_TYPE_FUNC(x16, u16, "0x%x")
51DEFINE_BASIC_PRINT_TYPE_FUNC(x32, u32, "0x%x")51DEFINE_BASIC_PRINT_TYPE_FUNC(x32, u32, "0x%x")
52DEFINE_BASIC_PRINT_TYPE_FUNC(x64, u64, "0x%Lx")52DEFINE_BASIC_PRINT_TYPE_FUNC(x64, u64, "0x%Lx")
53DEFINE_BASIC_PRINT_TYPE_FUNC(char, u8, "'%c'")
53 54
54int PRINT_TYPE_FUNC_NAME(symbol)(struct trace_seq *s, void *data, void *ent)55int PRINT_TYPE_FUNC_NAME(symbol)(struct trace_seq *s, void *data, void *ent)
55{56{
@@ -95,6 +96,7 @@ static const struct fetch_type probe_fetch_types[] = { · 39 unmodified lines
95 ASSIGN_FETCH_TYPE_ALIAS(x16, u16, u16, 0),96 ASSIGN_FETCH_TYPE_ALIAS(x16, u16, u16, 0),
96 ASSIGN_FETCH_TYPE_ALIAS(x32, u32, u32, 0),97 ASSIGN_FETCH_TYPE_ALIAS(x32, u32, u32, 0),
97 ASSIGN_FETCH_TYPE_ALIAS(x64, u64, u64, 0),98 ASSIGN_FETCH_TYPE_ALIAS(x64, u64, u64, 0),
99 ASSIGN_FETCH_TYPE_ALIAS(char, u8, u8, 0),
98 ASSIGN_FETCH_TYPE_ALIAS(symbol, ADDR_FETCH_TYPE, ADDR_FETCH_TYPE, 0),100 ASSIGN_FETCH_TYPE_ALIAS(symbol, ADDR_FETCH_TYPE, ADDR_FETCH_TYPE, 0),
99 101
100 ASSIGN_FETCH_TYPE_END102 ASSIGN_FETCH_TYPE_END
kernel/trace/trace_probe.h+1−0
@@ -166,6 +166,7 @@ DECLARE_BASIC_PRINT_TYPE_FUNC(x16); · 165 unmodified lines
166DECLARE_BASIC_PRINT_TYPE_FUNC(x32);166DECLARE_BASIC_PRINT_TYPE_FUNC(x32);
167DECLARE_BASIC_PRINT_TYPE_FUNC(x64);167DECLARE_BASIC_PRINT_TYPE_FUNC(x64);
168 168
169DECLARE_BASIC_PRINT_TYPE_FUNC(char);
169DECLARE_BASIC_PRINT_TYPE_FUNC(string);170DECLARE_BASIC_PRINT_TYPE_FUNC(string);
170DECLARE_BASIC_PRINT_TYPE_FUNC(symbol);171DECLARE_BASIC_PRINT_TYPE_FUNC(symbol);
171 172