Skip to content

Commit 8d6bc6a

Browse files
committed
Merge tag 'probes-fixes-v6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull probes fixes from Masami Hiramatsu: - uprobes: prevent mutex_lock() under rcu_read_lock(). Recent changes moved uprobe_cpu_buffer preparation which involves mutex_lock(), under __uprobe_trace_func() which is called inside rcu_read_lock(). Fix it by moving uprobe_cpu_buffer preparation outside of __uprobe_trace_func() - kprobe-events: handle the error case of btf_find_struct_member() * tag 'probes-fixes-v6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tracing/probes: fix error check in parse_btf_field() uprobes: prevent mutex_lock() under rcu_read_lock()
2 parents 2bfcfd5 + e569eb3 commit 8d6bc6a

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

kernel/trace/trace_probe.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,10 @@ static int parse_btf_field(char *fieldname, const struct btf_type *type,
554554
anon_offs = 0;
555555
field = btf_find_struct_member(ctx->btf, type, fieldname,
556556
&anon_offs);
557+
if (IS_ERR(field)) {
558+
trace_probe_log_err(ctx->offset, BAD_BTF_TID);
559+
return PTR_ERR(field);
560+
}
557561
if (!field) {
558562
trace_probe_log_err(ctx->offset, NO_BTF_FIELD);
559563
return -ENOENT;

kernel/trace/trace_uprobe.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -970,19 +970,17 @@ static struct uprobe_cpu_buffer *prepare_uprobe_buffer(struct trace_uprobe *tu,
970970

971971
static void __uprobe_trace_func(struct trace_uprobe *tu,
972972
unsigned long func, struct pt_regs *regs,
973-
struct uprobe_cpu_buffer **ucbp,
973+
struct uprobe_cpu_buffer *ucb,
974974
struct trace_event_file *trace_file)
975975
{
976976
struct uprobe_trace_entry_head *entry;
977977
struct trace_event_buffer fbuffer;
978-
struct uprobe_cpu_buffer *ucb;
979978
void *data;
980979
int size, esize;
981980
struct trace_event_call *call = trace_probe_event_call(&tu->tp);
982981

983982
WARN_ON(call != trace_file->event_call);
984983

985-
ucb = prepare_uprobe_buffer(tu, regs, ucbp);
986984
if (WARN_ON_ONCE(ucb->dsize > PAGE_SIZE))
987985
return;
988986

@@ -1014,13 +1012,16 @@ static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs,
10141012
struct uprobe_cpu_buffer **ucbp)
10151013
{
10161014
struct event_file_link *link;
1015+
struct uprobe_cpu_buffer *ucb;
10171016

10181017
if (is_ret_probe(tu))
10191018
return 0;
10201019

1020+
ucb = prepare_uprobe_buffer(tu, regs, ucbp);
1021+
10211022
rcu_read_lock();
10221023
trace_probe_for_each_link_rcu(link, &tu->tp)
1023-
__uprobe_trace_func(tu, 0, regs, ucbp, link->file);
1024+
__uprobe_trace_func(tu, 0, regs, ucb, link->file);
10241025
rcu_read_unlock();
10251026

10261027
return 0;
@@ -1031,10 +1032,13 @@ static void uretprobe_trace_func(struct trace_uprobe *tu, unsigned long func,
10311032
struct uprobe_cpu_buffer **ucbp)
10321033
{
10331034
struct event_file_link *link;
1035+
struct uprobe_cpu_buffer *ucb;
1036+
1037+
ucb = prepare_uprobe_buffer(tu, regs, ucbp);
10341038

10351039
rcu_read_lock();
10361040
trace_probe_for_each_link_rcu(link, &tu->tp)
1037-
__uprobe_trace_func(tu, func, regs, ucbp, link->file);
1041+
__uprobe_trace_func(tu, func, regs, ucb, link->file);
10381042
rcu_read_unlock();
10391043
}
10401044

0 commit comments

Comments
 (0)