Thread (31 messages) read the whole thread 31 messages, 4 authors, 2015-03-25

Re: [PATCH v9 tip 6/9] samples: bpf: simple non-portable kprobe filter example

From: Alexei Starovoitov <hidden>
Date: 2015-03-23 17:32:55
Also in: lkml, netdev

On 3/23/15 12:35 AM, Ingo Molnar wrote:
* Alexei Starovoitov [off-list ref] wrote:
quoted
+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 ...
quoted
+		if (sz) {
... this test passes ...
quoted
+			buf[sz] = 0;
... and here we smash the stack?
good point. If it was normal file, for sure it's a bug, but trace_pipe
is a pseudo file and I think read cannot return -1. Regardless, it makes
sense to fix it. Will do. Do you mind I address it as follow up patch?
Or if the rest is ok, can you change the condition to sz>0 while
applying? I can respin the whole thing too, if you like.
Thanks!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help