qemu-devel
[Top][All Lists]
Advanced

[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.

Attachment: pgpxmsUUYq09M.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]