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:   Tue, 10 Aug 2021 11:04:03 +0200
From:   Christoph Hellwig <hch@...radead.org>
To:     Alex Williamson <alex.williamson@...hat.com>
Cc:     linux-kernel@...r.kernel.org, kvm@...r.kernel.org, jgg@...dia.com,
        peterx@...hat.com
Subject: Re: [PATCH 6/7] vfio: Add vfio_device_io_remap_mapping_range()

> +int vfio_device_io_remap_mapping_range(struct vfio_device *device,
> +				       loff_t start, loff_t len)
> +{
> +	struct address_space *mapping = device->inode->i_mapping;
> +	int ret = 0;
> +
> +	i_mmap_lock_write(mapping);
> +	if (mapping_mapped(mapping)) {
> +		struct rb_root_cached *root = &mapping->i_mmap;
> +		pgoff_t pgstart = start >> PAGE_SHIFT;
> +		pgoff_t pgend = (start + len - 1) >> PAGE_SHIFT;
> +		struct vm_area_struct *vma;
> +
> +		vma_interval_tree_foreach(vma, root, pgstart, pgend) {

There is no need for the mapping_mapped check here,
vma_interval_tree_foreach will the right thing for an empty tree.
That also allows to move a few more instructions out of the lock.

> +			/*
> +			 * Force NOFS memory allocation context to avoid
> +			 * deadlock while we hold i_mmap_rwsem.
> +			 */
> +			flags = memalloc_nofs_save();

Please move this out of the loop.

> +extern int vfio_device_io_remap_mapping_range(struct vfio_device *device,
> +					      loff_t start, loff_t len);

No need for the extern.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ