mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wang Liming <liming.wang@windriver.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] function tracing: fix wrong position computing of stack_trace
Date: Fri, 21 Nov 2008 16:13:22 +0800	[thread overview]
Message-ID: <49266DA2.3060705@windriver.com> (raw)
In-Reply-To: <20081121075256.GA16242@elte.hu>

Ingo Molnar wrote:
> * Liming Wang <liming.wang@windriver.com> wrote:
> 
>> Impact: make output of stack_trace complete if buffer overflow
>>
>> When read buffer overflows, the output of stack_trace isn't 
>> complete.
>>
>> When printing records with seq_printf in t_show, if the read buffer 
>> has overflowed by the current record, then this record won't be 
>> printed to user space through read buffer, it will just be dropped 
>> in this printing.
>>
>> When next printing, t_start should return the "*pos"th record, which 
>> is the one dropped by previous printing, but it just returns 
>> (m->private + *pos)th record.
>>
>> Here we use a more sane method to implement seq_operations which can 
>> be found in kernel code. Thus we needn't initialize m->private.
>>
>> About testing, it's not easy to overflow read buffer, but we can use 
>> seq_printf to print more padding bytes in t_show, then it's easy to 
>> check whether or not records are lost.
>>
>> This commit has been tested on both condition of overflow and non 
>> overflow.
>>
>> Signed-off-by: Liming Wang <liming.wang@windriver.com>
>> ---
>>  kernel/trace/trace_stack.c |   24 +++++++++++++++---------
>>  1 files changed, 15 insertions(+), 9 deletions(-)
> 
> applied to tip/tracing/urgent, thanks!
> 
> Note, i changed 'buffer overflow' to 'buffer overrun'. (buffer 
> overflow is a term typically used in a security context)
OK.

> 
>> -	i++;
>> +	if (v == SEQ_START_TOKEN )
>> +		i = 0;
>> +	else {
>> +		i = *(long *)v;
>> +		i++;
>> +	}
> 
> i also fixed these two minor style problems pointed out by 
> scripts/checkpatch.pl:
> 
> | ERROR: space prohibited before that close parenthesis ')'
> | #47: FILE: kernel/trace/trace_stack.c:187:
> | +	if (v == SEQ_START_TOKEN )
> |
> | ERROR: space prohibited before that close parenthesis ')'
> | #82: FILE: kernel/trace/trace_stack.c:245:
> | +	if (v == SEQ_START_TOKEN ) {
> |
> | total: 2 errors, 0 warnings, 0 checks, 64 lines checked
It's my fault, thanks a lot!

walimis
> 
> 	Ingo
> 


  reply	other threads:[~2008-11-21  8:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-21  3:00 [PATCH 0/1] " Liming Wang
2008-11-21  3:00 ` [PATCH 1/1] " Liming Wang
2008-11-21  7:52   ` Ingo Molnar
2008-11-21  8:13     ` Wang Liming [this message]
2008-11-21 13:14   ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49266DA2.3060705@windriver.com \
    --to=liming.wang@windriver.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®