Re: [PATCH] MIPS: cevt-r4k: fix array out-of-bounds access

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.




[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux