[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 7/9] raw: Prohibit dangerous writes for probe
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH v2 7/9] raw: Prohibit dangerous writes for probed images |
Date: |
Thu, 13 Nov 2014 10:46:22 +0000 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Fri, Nov 07, 2014 at 08:39:23PM +0100, Kevin Wolf wrote:
> diff --git a/block/raw_bsd.c b/block/raw_bsd.c
> index 401b967..462498e 100644
> --- a/block/raw_bsd.c
> +++ b/block/raw_bsd.c
> @@ -58,8 +58,52 @@ static int coroutine_fn raw_co_readv(BlockDriverState *bs,
> int64_t sector_num,
> static int coroutine_fn raw_co_writev(BlockDriverState *bs, int64_t
> sector_num,
> int nb_sectors, QEMUIOVector *qiov)
> {
> + void *buf = NULL;
> + BlockDriver *drv;
> + QEMUIOVector local_qiov;
> + int ret;
> +
> + if (bs->probed && sector_num == 0) {
> + /* As long as these conditions are true, we can't get partial writes
> to
> + * the probe buffer and can just directly check the request. */
> + QEMU_BUILD_BUG_ON(BLOCK_PROBE_BUF_SIZE != 512);
> + QEMU_BUILD_BUG_ON(BDRV_SECTOR_SIZE != 512);
> +
> + buf = qemu_try_blockalign(bs->file, 512);
> + if (!buf) {
> + ret = -ENOMEM;
> + goto fail;
> + }
> +
> + ret = qemu_iovec_to_buf(qiov, 0, buf, 512);
> + if (ret != 512) {
> + ret = -EINVAL;
> + goto fail;
> + }
Does this change the return value when nb_sectors == 0?
I couldn't find anything that prevents the nb_sectors edge case and I
guess we'd return 0 when nb_sectors == 0 && sector_num != 0.
pgpxmsUUYq09M.pgp
Description: PGP signature
- Re: [Qemu-devel] [PATCH v2 4/9] qtests: Specify image format explicitly, (continued)
- [Qemu-devel] [PATCH v2 5/9] block: Factor bdrv_probe_all() out of find_image_format(), Kevin Wolf, 2014/11/07
- [Qemu-devel] [PATCH v2 6/9] block: Read only one sector for format probing, Kevin Wolf, 2014/11/07
- [Qemu-devel] [PATCH v2 7/9] raw: Prohibit dangerous writes for probed images, Kevin Wolf, 2014/11/07
- [Qemu-devel] [PATCH v2 8/9] qemu-iotests: Fix stderr handling in common.qemu, Kevin Wolf, 2014/11/07
- [Qemu-devel] [PATCH v2 9/9] qemu-iotests: Test writing non-raw image headers to raw image, Kevin Wolf, 2014/11/07
- Re: [Qemu-devel] [PATCH v2 0/9] raw: Prohibit dangerous writes for probed images, Eric Blake, 2014/11/10
- Re: [Qemu-devel] [PATCH v2 0/9] raw: Prohibit dangerous writes for probed images, Markus Armbruster, 2014/11/11