Skip to content
Snippets Groups Projects
  • Hanna Reitz's avatar
    1046779e
    block: Ignore loosening perm restrictions failures · 1046779e
    Hanna Reitz authored
    
    We generally assume that loosening permission restrictions can never
    fail.  We have seen in the past that this assumption is wrong.  This has
    led to crashes because we generally pass &error_abort when loosening
    permissions.
    
    However, a failure in such a case should actually be handled in quite
    the opposite way: It is very much not fatal, so qemu may report it, but
    still consider the operation successful.  The only realistic problem is
    that qemu may then retain permissions and thus locks on images it
    actually does not require.  But again, that is not fatal.
    
    To implement this behavior, we make all functions that change
    permissions and that pass &error_abort to the initiating function
    (bdrv_check_perm() or bdrv_child_check_perm()) evaluate the
    @loosen_restrictions value introduced in the previous patch.  If it is
    true and an error did occur, we abort the permission update, discard the
    error, and instead report success to the caller.
    
    bdrv_child_try_set_perm() itself does not pass &error_abort, but it is
    the only public function to change permissions.  As such, callers may
    pass &error_abort to it, expecting dropping permission restrictions to
    never fail.
    
    Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    1046779e
    History
    block: Ignore loosening perm restrictions failures
    Hanna Reitz authored
    
    We generally assume that loosening permission restrictions can never
    fail.  We have seen in the past that this assumption is wrong.  This has
    led to crashes because we generally pass &error_abort when loosening
    permissions.
    
    However, a failure in such a case should actually be handled in quite
    the opposite way: It is very much not fatal, so qemu may report it, but
    still consider the operation successful.  The only realistic problem is
    that qemu may then retain permissions and thus locks on images it
    actually does not require.  But again, that is not fatal.
    
    To implement this behavior, we make all functions that change
    permissions and that pass &error_abort to the initiating function
    (bdrv_check_perm() or bdrv_child_check_perm()) evaluate the
    @loosen_restrictions value introduced in the previous patch.  If it is
    true and an error did occur, we abort the permission update, discard the
    error, and instead report success to the caller.
    
    bdrv_child_try_set_perm() itself does not pass &error_abort, but it is
    the only public function to change permissions.  As such, callers may
    pass &error_abort to it, expecting dropping permission restrictions to
    never fail.
    
    Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>