Skip to content

Commit 1b5d466

Browse files
committed
Merge tag 'trace-v6.17-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing fixes from Steven Rostedt: - Remove redundant __GFP_NOWARN flag is kmalloc As now __GFP_NOWARN is part of __GFP_NOWAIT, it can be removed from kmalloc as it is redundant. - Use copy_from_user_nofault() instead of _inatomic() for trace markers The trace_marker files are written to to allow user space to quickly write into the tracing ring buffer. Back in 2016, the get_user_pages_fast() and the kmap() logic was replaced by a __copy_from_user_inatomic(), but didn't properly disable page faults around it. Since the time this was added, copy_from_user_nofault() was added which does the required page fault disabling for us. - Fix the assembly markup in the ftrace direct sample code The ftrace direct sample code (which is also used for selftests), had the size directive between the "leave" and the "ret" instead of after the ret. This caused objtool to think the code was unreachable. - Only call unregister_pm_notifier() on outer most fgraph registration There was an error path in register_ftrace_graph() that did not call unregister_pm_notifier() on error, so it was added in the error path. The problem with that fix, is that register_pm_notifier() is only called by the initial user of fgraph. If that succeeds, but another fgraph registration were to fail, then unregister_pm_notifier() would be called incorrectly. - Fix a crash in osnoise when zero size cpumask is passed in If a zero size CPU mask is passed in, the kmalloc() would return ZERO_SIZE_PTR which is not checked, and the code would continue thinking it had real memory and crash. If zero is passed in as the size of the write, simply return 0. - Fix possible warning in trace_pid_write() If while processing a series of numbers passed to the "set_event_pid" file, and one of the updates fails to allocate (triggered by a fault injection), it can cause a warning to trigger. Check the return value of the call to trace_pid_list_set() and break out early with an error code if it fails. * tag 'trace-v6.17-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tracing: Silence warning when chunk allocation fails in trace_pid_write tracing/osnoise: Fix null-ptr-deref in bitmap_parselist() trace/fgraph: Fix error handling ftrace/samples: Fix function size computation tracing: Fix tracing_marker may trigger page fault during preempt_disable trace: Remove redundant __GFP_NOWARN
2 parents 9dd1835 + cd4453c commit 1b5d466

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

kernel/trace/fgraph.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,8 @@ int register_ftrace_graph(struct fgraph_ops *gops)
13971397
ftrace_graph_active--;
13981398
gops->saved_func = NULL;
13991399
fgraph_lru_release_index(i);
1400-
unregister_pm_notifier(&ftrace_suspend_notifier);
1400+
if (!ftrace_graph_active)
1401+
unregister_pm_notifier(&ftrace_suspend_notifier);
14011402
}
14021403
return ret;
14031404
}

kernel/trace/trace.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,10 @@ int trace_pid_write(struct trace_pid_list *filtered_pids,
834834
/* copy the current bits to the new max */
835835
ret = trace_pid_list_first(filtered_pids, &pid);
836836
while (!ret) {
837-
trace_pid_list_set(pid_list, pid);
837+
ret = trace_pid_list_set(pid_list, pid);
838+
if (ret < 0)
839+
goto out;
840+
838841
ret = trace_pid_list_next(filtered_pids, pid + 1, &pid);
839842
nr_pids++;
840843
}
@@ -871,6 +874,7 @@ int trace_pid_write(struct trace_pid_list *filtered_pids,
871874
trace_parser_clear(&parser);
872875
ret = 0;
873876
}
877+
out:
874878
trace_parser_put(&parser);
875879

876880
if (ret < 0) {
@@ -7209,7 +7213,7 @@ static ssize_t write_marker_to_buffer(struct trace_array *tr, const char __user
72097213
entry = ring_buffer_event_data(event);
72107214
entry->ip = ip;
72117215

7212-
len = __copy_from_user_inatomic(&entry->buf, ubuf, cnt);
7216+
len = copy_from_user_nofault(&entry->buf, ubuf, cnt);
72137217
if (len) {
72147218
memcpy(&entry->buf, FAULTED_STR, FAULTED_SIZE);
72157219
cnt = FAULTED_SIZE;
@@ -7306,7 +7310,7 @@ static ssize_t write_raw_marker_to_buffer(struct trace_array *tr,
73067310

73077311
entry = ring_buffer_event_data(event);
73087312

7309-
len = __copy_from_user_inatomic(&entry->id, ubuf, cnt);
7313+
len = copy_from_user_nofault(&entry->id, ubuf, cnt);
73107314
if (len) {
73117315
entry->id = -1;
73127316
memcpy(&entry->buf, FAULTED_STR, FAULTED_SIZE);

kernel/trace/trace_events_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ static bool user_event_enabler_queue_fault(struct user_event_mm *mm,
496496
{
497497
struct user_event_enabler_fault *fault;
498498

499-
fault = kmem_cache_zalloc(fault_cache, GFP_NOWAIT | __GFP_NOWARN);
499+
fault = kmem_cache_zalloc(fault_cache, GFP_NOWAIT);
500500

501501
if (!fault)
502502
return false;

kernel/trace/trace_osnoise.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,6 +2322,9 @@ osnoise_cpus_write(struct file *filp, const char __user *ubuf, size_t count,
23222322
int running, err;
23232323
char *buf __free(kfree) = NULL;
23242324

2325+
if (count < 1)
2326+
return 0;
2327+
23252328
buf = kmalloc(count, GFP_KERNEL);
23262329
if (!buf)
23272330
return -ENOMEM;

samples/ftrace/ftrace-direct-modify.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ asm (
7575
CALL_DEPTH_ACCOUNT
7676
" call my_direct_func1\n"
7777
" leave\n"
78-
" .size my_tramp1, .-my_tramp1\n"
7978
ASM_RET
79+
" .size my_tramp1, .-my_tramp1\n"
8080

8181
" .type my_tramp2, @function\n"
8282
" .globl my_tramp2\n"

0 commit comments

Comments
 (0)