lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 20 Aug 2018 17:53:59 +0000
From:   "Verma, Vishal L" <vishal.l.verma@...el.com>
To:     "Zhang, Yu C" <yu.c.zhang@...el.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "yi.z.zhang@...ux.intel.com" <yi.z.zhang@...ux.intel.com>,
        "Williams, Dan J" <dan.j.williams@...el.com>,
        "linux-nvdimm@...ts.01.org" <linux-nvdimm@...ts.01.org>,
        "zwisler@...nel.org" <zwisler@...nel.org>,
        "Jiang, Dave" <dave.jiang@...el.com>, "jack@...e.cz" <jack@...e.cz>
CC:     "Zhang, Yi Z" <yi.z.zhang@...el.com>
Subject: Re: [PATCH V2 1/1] device-dax: check for vma range while dax_mmap.


On Mon, 2018-08-13 at 20:02 +0800, Zhang Yi wrote:
> This patch prevents a user mapping an illegal vma range that is larger
> than a dax device physical resource.
> 
> When qemu maps the dax device for virtual nvdimm's backend device, the
> v-nvdimm label area is defined at the end of mapped range. By using an
> illegal size that exceeds the range of the device dax, it will trigger a
> fault with qemu.
> 
> Signed-off-by: Zhang Yi <yi.z.zhang@...ux.intel.com>
> ---
>  drivers/dax/device.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 

Looks good to me:
Reviewed-by: Vishal Verma <vishal.l.verma@...el.com>

> diff --git a/drivers/dax/device.c b/drivers/dax/device.c
> index 108c37f..6fe8c30 100644
> --- a/drivers/dax/device.c
> +++ b/drivers/dax/device.c
> @@ -177,6 +177,33 @@ static const struct attribute_group *dax_attribute_groups[] = {
>  	NULL,
>  };
>  
> +static int check_vma_range(struct dev_dax *dev_dax, struct vm_area_struct *vma,
> +		const char *func)
> +{
> +	struct device *dev = &dev_dax->dev;
> +	struct resource *res;
> +	unsigned long size;
> +	int ret, i;
> +
> +	if (!dax_alive(dev_dax->dax_dev))
> +		return -ENXIO;
> +
> +	size = vma->vm_end - vma->vm_start + (vma->vm_pgoff << PAGE_SHIFT);
> +	ret = -EINVAL;
> +	for (i = 0; i < dev_dax->num_resources; i++) {
> +		res = &dev_dax->res[i];
> +		if (size > resource_size(res)) {
> +			dev_info_ratelimited(dev,
> +				"%s: %s: fail, vma range overflow\n",
> +				current->comm, func);
> +			ret = -EINVAL;
> +			continue;
> +		} else
> +			return 0;
> +	}
> +	return ret;
> +}
> +
>  static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma,
>  		const char *func)
>  {
> @@ -469,6 +496,8 @@ static int dax_mmap(struct file *filp, struct vm_area_struct *vma)
>  	 */
>  	id = dax_read_lock();
>  	rc = check_vma(dev_dax, vma, __func__);
> +	if (!rc)
> +		rc = check_vma_range(dev_dax, vma, __func__);
>  	dax_read_unlock(id);
>  	if (rc)
>  		return rc;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ