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, 19 Dec 2011 15:25:27 -0500
From:	Vivek Goyal <vgoyal@...hat.com>
To:	Phillip Susi <psusi@....rr.com>
Cc:	joe@...ches.com, kzak@...hat.com, linux-kernel@...r.kernel.org,
	jaxboe@...ionio.com
Subject: Re: [PATCH 1/2] Add partition resize function to BLKPG ioctl

On Mon, Dec 12, 2011 at 07:16:21PM -0500, Phillip Susi wrote:

[..]
> +		case BLKPG_RESIZE_PARTITION:
> +			start = p.start >> 9;
> +			length = p.length >> 9;
> +			/* check for fit in a hd_struct */
> +			if (sizeof(sector_t) == sizeof(long) &&
> +			    sizeof(long long) > sizeof(long)) {
> +				long pstart = start, plength = length;
> +				if (pstart != start || plength != length
> +				    || pstart < 0 || plength < 0)
> +					return -EINVAL;
> +			}
> +
> +			mutex_lock(&bdev->bd_mutex);
> +
> +			/* overlap? */
> +			disk_part_iter_init(&piter, disk,
> +					    DISK_PITER_INCL_EMPTY);
> +			while ((part = disk_part_iter_next(&piter))) {
> +				if (part->partno != partno && !(start + length <= part->start_sect ||
> +				      start >= part->start_sect + part->nr_sects)) {
> +					disk_part_iter_exit(&piter);
> +					mutex_unlock(&bdev->bd_mutex);
> +					return -EBUSY;
> +				}
> +			}
> +			disk_part_iter_exit(&piter);
> +			part = disk_get_part(disk, partno);
> +			if (!part)
> +			{
> +				mutex_unlock(&bdev->bd_mutex);
> +				return -ENXIO;
> +			}
> +			if (start != part->start_sect)
> +			{
> +				mutex_unlock(&bdev->bd_mutex);
> +				disk_put_part(part);
> +				return -EINVAL;
> +			}
> +			part->nr_sects = length;
> +			bdevp = bdget(part_devt(part));
> +			mutex_lock(&bdevp->bd_mutex);

Are there any restrictions on order of partition bdev and disk bdev
locking.

I see that DEL_PARTITION ioctl first takes partition mutex and then 
disk mutex using mutex_lock_nested().

In your implementation you take disk mutex first and the partition 
bdev mutex. 

- Is that a problem from deadlock point of view? Two threads calling
  ioctl on same fd.

- Is it an issue from lock validator point of view. I am not familiar
  with mutex_lock_nested(). So thought of asking.

Thanks
Vivek
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ