lkml.org 
[lkml]   [2015]   [Mar]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v9 tip 6/9] samples: bpf: simple non-portable kprobe filter example

* Alexei Starovoitov <ast@plumgrid.com> wrote:

> +void read_trace_pipe(void)
> +{
> + int trace_fd;
> +
> + trace_fd = open(DEBUGFS "trace_pipe", O_RDONLY, 0);
> + if (trace_fd < 0)
> + return;
> +
> + while (1) {
> + static char buf[4096];
> + ssize_t sz;
> +
> + sz = read(trace_fd, buf, sizeof(buf));

read() will return -1 on failure ...

> + if (sz) {

... this test passes ...

> + buf[sz] = 0;

... and here we smash the stack?

> + puts(buf);
> + }
> + }


Thanks,

Ingo


\
 
 \ /
  Last update: 2015-03-23 08:41    [W:0.152 / U:0.632 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site