All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roel Kluin <roel.kluin@gmail.com>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	lkml <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>
Subject: [PATCH v2] ftrace: unsigned idx cannot be less than 0
Date: Sat, 03 Jan 2009 16:55:50 +0100	[thread overview]
Message-ID: <495F8A86.7040403@gmail.com> (raw)
In-Reply-To: <20090102211140.GA5770@nowhere>

>>>> -		if (iter->idx < 0)
>>>> +		if (iter->idx == 0)

>>> I'm not sure this is the right fix.
>>> If you look at t_next, if there is no more page to look at,
>>> iter_idx takes -1.
>>>
>>> A 0 value would mean: we are in the first index on the page, which means
>>> there is something to read and we don't want to return NULL.
>>>
>>> I guess that would be better to turn idx into a signed int.

>> If we turn idx in a signed int, isn't it true that
>> in kernel/trace/ftrace.c, line 806:

>> since iter->pg->index is an unsigned long, when larger than INT_MAX this
>> could result in an endless loop?
> 
> Actually, this is not supposed to reach such a threshold.
> Looks like it wouldn't increase over ENTRIES_PER_PAGE (defined
> in ftrace.c) which is smaller than PAGE_SIZE.
> So it will stay far from an overflow.

unless signed idx cannot become less than 0

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 2f32969..e256648 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -786,7 +786,7 @@ enum {
 
 struct ftrace_iterator {
 	struct ftrace_page	*pg;
-	unsigned		idx;
+	int			idx;
 	unsigned		flags;
 	unsigned char		buffer[FTRACE_BUFF_MAX+1];
 	unsigned		buffer_idx;


  reply	other threads:[~2009-01-03 15:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-02 14:49 [PATCH] ftrace: unsigned idx cannot be less than 0 Roel Kluin
2009-01-02 15:48 ` Frederic Weisbecker
2009-01-02 19:20   ` Roel Kluin
2009-01-02 21:11     ` Frederic Weisbecker
2009-01-03 15:55       ` Roel Kluin [this message]
2009-01-06 15:49   ` Steven Rostedt
2009-01-06 15:58     ` Frédéric Weisbecker

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=495F8A86.7040403@gmail.com \
    --to=roel.kluin@gmail.com \
    --cc=fweisbec@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.