All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rabin Vincent <rabin.vincent@axis.com>
To: James Hogan <james.hogan@imgtec.com>
Cc: ralf@linux-mips.org, linux-mips@linux-mips.org
Subject: Re: [PATCH] MIPS: cevt-r4k: fix array out-of-bounds access
Date: Wed, 5 Apr 2017 15:08:45 +0200	[thread overview]
Message-ID: <20170405130845.GA16092@axis.com> (raw)
In-Reply-To: <20170404203219.GK31606@jhogan-linux.le.imgtec.org>

On Tue, Apr 04, 2017 at 09:32:19PM +0100, James Hogan wrote:
> I think the correct fix is to prevent the read rather than change the
> size of the array. buf2[] is intentionally 3 so that out of 5 sorted
> samples the last element is the median, whereas buf1 is 4 elements so as
> to work out the 75th percentile.
> 
> When inserting the 5th sample into buf1 (i.e. j = 4), there are already
> 4 entries, so the highest element it needs to compare against is the 4th
> one (buf1[k=3]), so thats fine.
> 
> For buf2 however its still trying to insert 5 elements, so by the 5th
> one (i.e. i = 4) it may try to compare against the 4th element to know
> whether to insert before it, at which point we simply don't care about
> the ordering as its past the median.
> 
> So I think something like this would be more correct. Does that fix your
> problem?

Yes, this fixes it too.  Please feel free to submit it yourself with
your explanation.  You can add my Tested-by if you like.

Thanks.

      reply	other threads:[~2017-04-05 13:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04  7:42 Rabin Vincent
2017-04-04 20:32 ` James Hogan
2017-04-04 20:32   ` James Hogan
2017-04-05 13:08   ` Rabin Vincent [this message]

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=20170405130845.GA16092@axis.com \
    --to=rabin.vincent@axis.com \
    --cc=james.hogan@imgtec.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --subject='Re: [PATCH] MIPS: cevt-r4k: fix array out-of-bounds access' \
    /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

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.