On Wed, Feb 13, 2019 at 2:22 AM Jan Kara <jack@xxxxxxx> wrote: > > On Tue 12-02-19 13:24:56, Dan Williams wrote: > > The checks in __bdev_dax_supported() helped mitigate a potential data > > corruption bug in the pmem driver's handling of section alignment > > padding. Strengthen the checks, including checking the end of the range, > > to validate the dev_pagemap, Xarray entries, and sector-to-pfn > > translation established for pmem namespaces. > > > > Cc: Jan Kara <jack@xxxxxxx> > > Cc: "Darrick J. Wong" <darrick.wong@xxxxxxxxxx> > > Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx> > > --- > > drivers/dax/super.c | 39 +++++++++++++++++++++++++++++---------- > > 1 file changed, 29 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/dax/super.c b/drivers/dax/super.c > > index 6e928f37d084..a27395cfcec6 100644 > > --- a/drivers/dax/super.c > > +++ b/drivers/dax/super.c > > @@ -86,12 +86,14 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize) > > { > > struct dax_device *dax_dev; > > bool dax_enabled = false; > > + pgoff_t pgoff, pgoff_end; > > struct request_queue *q; > > - pgoff_t pgoff; > > - int err, id; > > - pfn_t pfn; > > - long len; > > char buf[BDEVNAME_SIZE]; > > + void *kaddr, *end_kaddr; > > + pfn_t pfn, end_pfn; > > + sector_t last_page; > > + long len, len2; > > + int err, id; > > > > if (blocksize != PAGE_SIZE) { > > pr_debug("%s: error: unsupported blocksize for dax\n", > > @@ -113,6 +115,15 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize) > > return false; > > } > > > > + last_page = ALIGN_DOWN(part_nr_sects_read(bdev->bd_part) > > + - PAGE_SIZE / 512, PAGE_SIZE / 512); > > Why not just (i_size_read(bdev->bd_inode) - 1) >> PAGE_SHIFT? Because that would be too elegant and straightforward? > Otherwise the patch looks good to me. Thanks, I'll fix up the last page calculation.