android_kernel_samsung_a7y1.../kernel
Elazar Leibovich 14abb5143d tracing: Fix partial reading of trace event's id file
commit cbe08bcbbe787315c425dde284dcb715cfbf3f39 upstream.

When reading only part of the id file, the ppos isn't tracked correctly.
This is taken care by simple_read_from_buffer.

Reading a single byte, and then the next byte would result EOF.

While this seems like not a big deal, this breaks abstractions that
reads information from files unbuffered. See for example
https://github.com/golang/go/issues/29399

This code was mentioned as problematic in
commit cd458ba9d5a5
("tracing: Do not (ab)use trace_seq in event_id_read()")

An example C code that show this bug is:

  #include <stdio.h>
  #include <stdint.h>

  #include <sys/types.h>
  #include <sys/stat.h>
  #include <fcntl.h>
  #include <unistd.h>

  int main(int argc, char **argv) {
    if (argc < 2)
      return 1;
    int fd = open(argv[1], O_RDONLY);
    char c;
    read(fd, &c, 1);
    printf("First  %c\n", c);
    read(fd, &c, 1);
    printf("Second %c\n", c);
  }

Then run with, e.g.

  sudo ./a.out /sys/kernel/debug/tracing/events/tcp/tcp_set_state/id

You'll notice you're getting the first character twice, instead of the
first two characters in the id file.

Link: http://lkml.kernel.org/r/20181231115837.4932-1-elazar@lightbitslabs.com

Cc: Orit Wasserman <orit.was@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: stable@vger.kernel.org
Fixes: 23725aeeab10b ("ftrace: provide an id file for each event")
Signed-off-by: Elazar Leibovich <elazar@lightbitslabs.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-06 18:14:00 +02:00
..
bpf A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
configs A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
debug A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
events perf/core: Restore mmap record type correctly 2020-04-06 15:16:49 +02:00
gcov A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
irq genirq: Prevent use-after-free and work list corruption 2020-04-06 16:43:02 +02:00
livepatch A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
locking Revert "locking/lockdep: Add debug_locks check in __lock_downgrade()" 2020-04-06 15:57:19 +02:00
power PM / Hibernate: Call flush_icache_range() on pages restored in-place 2020-04-06 12:52:20 +02:00
printk A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
rcu A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sched sched: Add sched_smt_active() 2020-04-06 16:51:01 +02:00
time timer/debug: Change /proc/timer_stats from 0644 to 0600 2020-04-06 16:43:18 +02:00
trace tracing: Fix partial reading of trace event's id file 2020-04-06 18:14:00 +02:00
acct.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
async.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
audit_fsnotify.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
audit_tree.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
audit_watch.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
audit.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
audit.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
auditfilter.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
auditsc.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
backtracetest.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
bounds.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
capability.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cgroup_freezer.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cgroup_pids.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cgroup.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
compat.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
configs.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
context_tracking.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cpu_pm.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cpu.c cpu/speculation: Add 'mitigations=' cmdline option 2020-04-06 17:00:51 +02:00
cpuset.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
crash_dump.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cred.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
delayacct.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
dma.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
elfcore.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
exec_domain.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
exit.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
extable.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
fork.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
freezer.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
futex_compat.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
futex.c futex: Ensure that futex address is aligned in handle_futex_death() 2020-04-06 10:58:14 +02:00
groups.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
hung_task.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
irq_work.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
jump_label.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
kallsyms.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
kaslr.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
kcmp.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Kconfig.freezer A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Kconfig.hz A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Kconfig.locks A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Kconfig.preempt A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
kcov.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
kexec_core.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
kexec_file.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
kexec_internal.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
kexec.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
kmod.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
kprobes.c kprobes: Fix error check when reusing optimized probes 2020-04-06 15:57:04 +02:00
ksysfs.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
kthread.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
latencytop.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Makefile A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
membarrier.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
memremap.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
module_signing.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
module-internal.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
module.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
notifier.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
nsproxy.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
padata.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
panic.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
params.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
pid_namespace.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
pid.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
profile.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ptrace.c x86/speculation: Apply IBPB more strictly to avoid cross-process data leak 2020-04-06 16:50:35 +02:00
range.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
reboot.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
relay.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
resource.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
seccomp.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
signal.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
smp.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
smpboot.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
smpboot.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
softirq.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
stacktrace.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
stop_machine.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sys_ni.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sys.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sysctl_binary.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sysctl.c kernel/sysctl.c: fix out-of-bounds access when setting file-max 2020-04-06 15:57:22 +02:00
task_work.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
taskstats.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
test_kprobes.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
torture.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tracepoint.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tsacct.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
uid16.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
up.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
user_namespace.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
user-return-notifier.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
user.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
utsname_sysctl.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
utsname.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
watchdog.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
workqueue_internal.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
workqueue.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30