All of lore.kernel.org
 help / color / mirror / Atom feed
* [BUG] perf tools: off-by-one error in map_groups__find_ams()
@ 2014-10-01 19:16 Stephane Eranian
  2014-10-02  8:36 ` Jiri Olsa
  0 siblings, 1 reply; 5+ messages in thread
From: Stephane Eranian @ 2014-10-01 19:16 UTC (permalink / raw)
  To: LKML
  Cc: Jiri Olsa, Namhyung Kim, Arnaldo Carvalho de Melo,
	Peter Zijlstra, mingo, David Ahern

Hi,

It appears that there is a off-by-one bug in map_groups__find_ams().
The upper-bound check in the test below should be >= because
end = start + len; The end address is outside the range.

Please confirm.


int map_groups__find_ams(struct addr_map_symbol *ams, symbol_filter_t filter)
{
                if (ams->addr < ams->map->start || ams->addr > ams->map->end) {

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] perf tools: off-by-one error in map_groups__find_ams()
  2014-10-01 19:16 [BUG] perf tools: off-by-one error in map_groups__find_ams() Stephane Eranian
@ 2014-10-02  8:36 ` Jiri Olsa
  2014-10-02 16:40   ` Stephane Eranian
  0 siblings, 1 reply; 5+ messages in thread
From: Jiri Olsa @ 2014-10-02  8:36 UTC (permalink / raw)
  To: Stephane Eranian
  Cc: LKML, Namhyung Kim, Arnaldo Carvalho de Melo, Peter Zijlstra,
	mingo, David Ahern

On Wed, Oct 01, 2014 at 09:16:31PM +0200, Stephane Eranian wrote:
> Hi,
> 
> It appears that there is a off-by-one bug in map_groups__find_ams().
> The upper-bound check in the test below should be >= because
> end = start + len; The end address is outside the range.
> 
> Please confirm.
> 
> 
> int map_groups__find_ams(struct addr_map_symbol *ams, symbol_filter_t filter)
> {
>                 if (ams->addr < ams->map->start || ams->addr > ams->map->end) {

yep, looks like bug to me

jirka

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] perf tools: off-by-one error in map_groups__find_ams()
  2014-10-02  8:36 ` Jiri Olsa
@ 2014-10-02 16:40   ` Stephane Eranian
  2014-10-03  8:09     ` Jiri Olsa
  0 siblings, 1 reply; 5+ messages in thread
From: Stephane Eranian @ 2014-10-02 16:40 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: LKML, Namhyung Kim, Arnaldo Carvalho de Melo, Peter Zijlstra,
	mingo, David Ahern

On Thu, Oct 2, 2014 at 10:36 AM, Jiri Olsa <jolsa@redhat.com> wrote:
> On Wed, Oct 01, 2014 at 09:16:31PM +0200, Stephane Eranian wrote:
>> Hi,
>>
>> It appears that there is a off-by-one bug in map_groups__find_ams().
>> The upper-bound check in the test below should be >= because
>> end = start + len; The end address is outside the range.
>>
>> Please confirm.
>>
>>
>> int map_groups__find_ams(struct addr_map_symbol *ams, symbol_filter_t filter)
>> {
>>                 if (ams->addr < ams->map->start || ams->addr > ams->map->end) {
>
> yep, looks like bug to me
>
Are you providing a fix or should I?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] perf tools: off-by-one error in map_groups__find_ams()
  2014-10-02 16:40   ` Stephane Eranian
@ 2014-10-03  8:09     ` Jiri Olsa
  2014-10-03 10:07       ` Stephane Eranian
  0 siblings, 1 reply; 5+ messages in thread
From: Jiri Olsa @ 2014-10-03  8:09 UTC (permalink / raw)
  To: Stephane Eranian
  Cc: LKML, Namhyung Kim, Arnaldo Carvalho de Melo, Peter Zijlstra,
	mingo, David Ahern

On Thu, Oct 02, 2014 at 06:40:14PM +0200, Stephane Eranian wrote:
> On Thu, Oct 2, 2014 at 10:36 AM, Jiri Olsa <jolsa@redhat.com> wrote:
> > On Wed, Oct 01, 2014 at 09:16:31PM +0200, Stephane Eranian wrote:
> >> Hi,
> >>
> >> It appears that there is a off-by-one bug in map_groups__find_ams().
> >> The upper-bound check in the test below should be >= because
> >> end = start + len; The end address is outside the range.
> >>
> >> Please confirm.
> >>
> >>
> >> int map_groups__find_ams(struct addr_map_symbol *ams, symbol_filter_t filter)
> >> {
> >>                 if (ams->addr < ams->map->start || ams->addr > ams->map->end) {
> >
> > yep, looks like bug to me
> >
> Are you providing a fix or should I?

please go ahead

jirka

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] perf tools: off-by-one error in map_groups__find_ams()
  2014-10-03  8:09     ` Jiri Olsa
@ 2014-10-03 10:07       ` Stephane Eranian
  0 siblings, 0 replies; 5+ messages in thread
From: Stephane Eranian @ 2014-10-03 10:07 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: LKML, Namhyung Kim, Arnaldo Carvalho de Melo, Peter Zijlstra,
	mingo, David Ahern

On Fri, Oct 3, 2014 at 10:09 AM, Jiri Olsa <jolsa@redhat.com> wrote:
> On Thu, Oct 02, 2014 at 06:40:14PM +0200, Stephane Eranian wrote:
>> On Thu, Oct 2, 2014 at 10:36 AM, Jiri Olsa <jolsa@redhat.com> wrote:
>> > On Wed, Oct 01, 2014 at 09:16:31PM +0200, Stephane Eranian wrote:
>> >> Hi,
>> >>
>> >> It appears that there is a off-by-one bug in map_groups__find_ams().
>> >> The upper-bound check in the test below should be >= because
>> >> end = start + len; The end address is outside the range.
>> >>
>> >> Please confirm.
>> >>
>> >>
>> >> int map_groups__find_ams(struct addr_map_symbol *ams, symbol_filter_t filter)
>> >> {
>> >>                 if (ams->addr < ams->map->start || ams->addr > ams->map->end) {
>> >
>> > yep, looks like bug to me
>> >
>> Are you providing a fix or should I?
>
> please go ahead
>
Based on the same reasoning, I am wondering about the following too:

util/map.c:
int map_groups__fixup_overlappings()
{

          after->start = map->end + 1;
                                                  ^^^ should not be there
}
The first byte after a map is at map->end. Range if [start;end[

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-03 10:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-01 19:16 [BUG] perf tools: off-by-one error in map_groups__find_ams() Stephane Eranian
2014-10-02  8:36 ` Jiri Olsa
2014-10-02 16:40   ` Stephane Eranian
2014-10-03  8:09     ` Jiri Olsa
2014-10-03 10:07       ` Stephane Eranian

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.