Re: [PATCH]: xarray: Fix potential out of bounds access

From: Cyrill Gorcunov
Date: Mon Jan 14 2019 - 14:14:23 EST


On Mon, Jan 14, 2019 at 11:01:20AM -0800, Matthew Wilcox wrote:
> On Mon, Jan 14, 2019 at 09:47:41PM +0300, Cyrill Gorcunov wrote:
> > Since the mark is used as an array index we should use
> > preincrement to not access the XA_MARK_MAX index.
>
> But XA_MARK_MAX is inclusive:
>
> include/linux/xarray.h:#define XA_MARK_MAX XA_MARK_2

Indeed, I misread the variable name.

> so we actually want to access XA_MARK_MAX. Now, we don't have a test
> in the test-suite that fails as a result of your patch, so that needs to get
> fixed. How about this:

Looks great. Thank you!