linux-stable/kernel/trace
Wonhyuk Yang b27f266f74 tracing: Fix return value of trace_pid_write()
Setting set_event_pid with trailing whitespace lead to endless write
system calls like below.

    $ strace echo "123 " > /sys/kernel/debug/tracing/set_event_pid
    execve("/usr/bin/echo", ["echo", "123 "], ...) = 0
    ...
    write(1, "123 \n", 5)                   = 4
    write(1, "\n", 1)                       = 0
    write(1, "\n", 1)                       = 0
    write(1, "\n", 1)                       = 0
    write(1, "\n", 1)                       = 0
    write(1, "\n", 1)                       = 0
    ....

This is because, the result of trace_get_user's are not returned when it
read at least one pid. To fix it, update read variable even if
parser->idx == 0.

The result of applied patch is below.

    $ strace echo "123 " > /sys/kernel/debug/tracing/set_event_pid
    execve("/usr/bin/echo", ["echo", "123 "], ...) = 0
    ...
    write(1, "123 \n", 5)                   = 5
    close(1)                                = 0

Link: https://lkml.kernel.org/r/20220503050546.288911-1-vvghjk1234@gmail.com

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Baik Song An <bsahn@etri.re.kr>
Cc: Hong Yeon Kim <kimhy@etri.re.kr>
Cc: Taeung Song <taeung@reallinux.co.kr>
Cc: linuxgeek@linuxgeek.io
Cc: stable@vger.kernel.org
Fixes: 4909010788 ("tracing: Add set_event_pid directory for future use")
Signed-off-by: Wonhyuk Yang <vvghjk1234@gmail.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
2022-05-26 21:12:59 -04:00
..
Kconfig tracing: mark user_events as BROKEN 2022-04-02 10:32:14 -07:00
Makefile Networking changes for 5.18. 2022-03-24 13:13:26 -07:00
blktrace.c SCSI misc on 20220324 2022-03-24 19:37:53 -07:00
bpf_trace.c bpf: Fix sparse warnings in kprobe_multi_resolve_syms 2022-03-30 14:10:06 +02:00
bpf_trace.h
error_report-traces.c
fgraph.c ftrace: Make ftrace_graph_is_dead() a static branch 2022-04-02 08:40:09 -04:00
fprobe.c fprobe: Fix sparse warning for acccessing __rcu ftrace_hash 2022-03-28 19:05:40 -07:00
ftrace.c ftrace: Deal with error return code of the ftrace_process_locs() function 2022-05-26 21:12:59 -04:00
ftrace_internal.h
kprobe_event_gen_test.c
pid_list.c tracing: Cleanup double word in comment 2022-04-26 17:58:50 -04:00
pid_list.h tracing: Create a sparse bitmask for pid filtering 2021-10-05 17:38:45 -04:00
power-traces.c
preemptirq_delay_test.c
rethook.c rethook: Fix to use WRITE_ONCE() for rethook:: Handler 2022-03-30 19:28:17 -07:00
ring_buffer.c ring-buffer: Have 32 bit time stamps use all 64 bits 2022-04-27 17:19:30 -04:00
ring_buffer_benchmark.c
rpm-traces.c
synth_event_gen_test.c
trace.c tracing: Fix return value of trace_pid_write() 2022-05-26 21:12:59 -04:00
trace.h tracing: Have existing event_command.parse() implementations use helpers 2022-04-26 17:58:50 -04:00
trace_benchmark.c
trace_benchmark.h
trace_boot.c tracing: Fix missing trace_boot_init_histograms kstrdup NULL checks 2021-10-26 09:18:10 -04:00
trace_branch.c
trace_clock.c tracing: Do no increment trace_clock_global() by one 2021-06-18 09:10:00 -04:00
trace_dynevent.c tracing: Use trace_create_file() to simplify creation of tracefs entries 2022-05-26 21:12:52 -04:00
trace_dynevent.h tracing: Add DYNAMIC flag for dynamic events 2021-08-18 18:10:32 -04:00
trace_entries.h trace: Add timerlat tracer 2021-06-25 19:57:24 -04:00
trace_eprobe.c tracing: Remove check of list iterator against head past the loop body 2022-04-27 17:19:31 -04:00
trace_event_perf.c tracing: Show size of requested perf buffer 2021-10-27 12:25:09 -04:00
trace_events.c tracing: Use trace_create_file() to simplify creation of tracefs entries 2022-05-26 21:12:52 -04:00
trace_events_filter.c tracing: Add ustring operation to filtering string pointers 2022-01-14 03:42:24 -05:00
trace_events_filter_test.h
trace_events_hist.c tracing: Fix potential double free in create_var_ref() 2022-05-26 21:12:59 -04:00
trace_events_inject.c tracing: Support __rel_loc relative dynamic data location attribute 2021-12-06 15:37:21 -05:00
trace_events_synth.c tracing: Fix strncpy warning in trace_events_synth.c 2022-03-11 11:49:24 -05:00
trace_events_trigger.c tracing: Replace usage of found with dedicated list iterator variable 2022-04-27 17:19:31 -04:00
trace_events_user.c tracing: mark user_events as BROKEN 2022-04-02 10:32:14 -07:00
trace_export.c
trace_functions.c ftrace: disable preemption when recursion locked 2021-10-27 11:21:49 -04:00
trace_functions_graph.c tracing: in_irq() cleanup 2021-10-13 18:19:41 -04:00
trace_hwlat.c trace/hwlat: make use of the helper function kthread_run_on_cpu() 2022-01-15 16:30:24 +02:00
trace_irqsoff.c
trace_kdb.c kdb: Rename members of struct kdbtab_t 2021-07-27 17:05:06 +01:00
trace_kprobe.c tracing: Use trace_create_file() to simplify creation of tracefs entries 2022-05-26 21:12:52 -04:00
trace_kprobe_selftest.c
trace_kprobe_selftest.h
trace_mmiotrace.c
trace_nop.c
trace_osnoise.c Linux 5.17-rc8 2022-03-15 10:28:12 +01:00
trace_output.c tracing: Remove usage of list iterator after the loop body 2022-04-27 17:19:30 -04:00
trace_output.h
trace_preemptirq.c
trace_printk.c tracing: Disable "other" permission bits in the tracefs files 2021-10-08 18:08:43 -04:00
trace_probe.c eprobes: Remove redundant event type information 2022-02-25 12:07:01 -05:00
trace_probe.h eprobes: Remove redundant event type information 2022-02-25 12:07:01 -05:00
trace_probe_tmpl.h tracing/probes: Have process_fetch_insn() take a void * instead of pt_regs 2021-08-19 09:09:03 -04:00
trace_recursion_record.c tracing: Use trace_create_file() to simplify creation of tracefs entries 2022-05-26 21:12:52 -04:00
trace_sched_switch.c Tracing updates for 5.18: 2022-03-23 11:40:25 -07:00
trace_sched_wakeup.c sched/tracing: Don't re-read p->state when emitting sched_switch event 2022-03-01 16:18:39 +01:00
trace_selftest.c tracing: Reset the function filter after completing trampoline/graph selftest 2022-05-25 16:57:37 -04:00
trace_selftest_dynamic.c
trace_seq.c
trace_stack.c tracing: Disable "other" permission bits in the tracefs files 2021-10-08 18:08:43 -04:00
trace_stat.c tracing: Disable "other" permission bits in the tracefs files 2021-10-08 18:08:43 -04:00
trace_stat.h
trace_synth.h tracing: synth events: increase max fields count 2021-09-08 15:29:16 -04:00
trace_syscalls.c tracing: Make tp_printk work on syscall tracepoints 2022-04-26 17:58:52 -04:00
trace_uprobe.c Tracing updates for 5.17: 2022-01-16 10:15:32 +02:00
tracing_map.c tracing: Fix tracing_map_sort_entries() kernel-doc comment 2022-04-26 17:58:51 -04:00
tracing_map.h