• V
    block: fix bdrv_check_perm for non-tree subgraph · f962e961
    Vladimir Sementsov-Ogievskiy 提交于
    bdrv_check_perm in it's recursion checks each node in context of new
    permissions for one parent, because of nature of DFS. It works well,
    while children subgraph of top-most updated node is a tree, i.e. it
    doesn't have any kind of loops. But if we have a loop (not oriented,
    of course), i.e. we have two different ways from top-node to some
    child-node, then bdrv_check_perm will do wrong thing:
    
      top
      | \
      |  |
      v  v
      A  B
      |  |
      v  v
      node
    
    It will once check new permissions of node in context of new A
    permissions and old B permissions and once visa-versa. It's a wrong way
    and may lead to corruption of permission system. We may start with
    no-permissions and all-shared for both A->node and B->node relations
    and finish up with non shared write permission for both ways.
    
    The following commit will add a test, which shows this bug.
    
    To fix this situation, let's really set BdrvChild permissions during
    bdrv_check_perm procedure. And we are happy here, as check-perm is
    already written in transaction manner, so we just need to restore
    backed-up permissions in _abort.
    Signed-off-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
    Signed-off-by: NKevin Wolf <kwolf@redhat.com>
    f962e961
block.c 169.6 KB