qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: xuwei@redhat.com, qemu-devel@nongnu.org
Subject: Re: [PATCH 1/2] block: Add BDRV_O_NO_SHARE for blk_new_open()
Date: Tue, 13 Apr 2021 08:41:10 -0500	[thread overview]
Message-ID: <da50e485-75be-17ce-85c4-357b3401fd7f@redhat.com> (raw)
In-Reply-To: <20210413132324.24043-2-kwolf@redhat.com>

On 4/13/21 8:23 AM, Kevin Wolf wrote:
> Normally, blk_new_open() just shares all permissions. This was fine
> originally when permissions only protected against uses in the same
> process because no other part of the code would actually get to access
> the block nodes opened with blk_new_open(). However, since we use it for
> file locking now, unsharing permissions becomes desirable.
> 
> Add a new BDRV_O_NO_SHARE flag that is used in blk_new_open() to unshare
> any permissions that can be unshared.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  include/block/block.h |  1 +
>  block/block-backend.c | 19 +++++++++++++------
>  2 files changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/include/block/block.h b/include/block/block.h
> index b3f6e509d4..735db05a39 100644
> --- a/include/block/block.h
> +++ b/include/block/block.h
> @@ -101,6 +101,7 @@ typedef struct HDGeometry {
>      uint32_t cylinders;
>  } HDGeometry;
>  
> +#define BDRV_O_NO_SHARE    0x0001 /* don't share permissons */
>  #define BDRV_O_RDWR        0x0002

Huh. We originally created BDRV_O_RDONLY = 0 and BDRV_O_RDWR = 2 back in
commit 83f6409109 (in 2006); I see no reason why we skipped 1 at that
time (maybe to allow BDRV_O_WRONLY? but who would use it), so exploiting
it now seems fine.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



  reply	other threads:[~2021-04-13 13:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13 13:23 [PATCH 0/2] qemu-img convert: Unshare write permission for source Kevin Wolf
2021-04-13 13:23 ` [PATCH 1/2] block: Add BDRV_O_NO_SHARE for blk_new_open() Kevin Wolf
2021-04-13 13:41   ` Eric Blake [this message]
2021-04-13 13:23 ` [PATCH 2/2] qemu-img convert: Unshare write permission for source Kevin Wolf
2021-04-13 13:43   ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=da50e485-75be-17ce-85c4-357b3401fd7f@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=xuwei@redhat.com \
    --subject='Re: [PATCH 1/2] block: Add BDRV_O_NO_SHARE for blk_new_open()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).