lkml.org 
[lkml]   [2009]   [Jan]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH v2] ftrace: unsigned idx cannot be less than 0
    >>>> -		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;


    \
     
     \ /
      Last update: 2009-01-03 16:59    [W:0.021 / U:125.000 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site