From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752756AbbCWRcz (ORCPT ); Mon, 23 Mar 2015 13:32:55 -0400 Received: from mail-qg0-f51.google.com ([209.85.192.51]:32933 "EHLO mail-qg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752508AbbCWRcv (ORCPT ); Mon, 23 Mar 2015 13:32:51 -0400 Message-ID: <55104E3D.20103@plumgrid.com> Date: Mon, 23 Mar 2015 10:32:45 -0700 From: Alexei Starovoitov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Ingo Molnar CC: Steven Rostedt , Namhyung Kim , Arnaldo Carvalho de Melo , Jiri Olsa , Masami Hiramatsu , "David S. Miller" , Daniel Borkmann , Peter Zijlstra , linux-api@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v9 tip 6/9] samples: bpf: simple non-portable kprobe filter example References: <1426894210-27441-1-git-send-email-ast@plumgrid.com> <1426894210-27441-7-git-send-email-ast@plumgrid.com> <20150323073506.GC25184@gmail.com> In-Reply-To: <20150323073506.GC25184@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/23/15 12:35 AM, Ingo Molnar wrote: > > * Alexei Starovoitov 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? 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!