aboutsummaryrefslogtreecommitdiff
path: root/block/stream.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2021-03-09 18:34:51 +0100
committerKevin Wolf <kwolf@redhat.com>2021-03-19 10:15:06 +0100
commit1bf26076d677f693dd99a6e8ef2eca69b842d873 (patch)
treee070a9cc13c2c02e0a1a3c990db6f2b7da9fb406 /block/stream.c
parente21577707152c10017dcf4d3340e83b100057355 (diff)
stream: Don't crash when node permission is denied
The image streaming block job restricts shared permissions of the nodes it accesses. This can obviously fail when other users already got these permissions. &error_abort is therefore wrong and can crash. Handle these errors gracefully and just fail starting the block job. Reported-by: Nini Gu <ngu@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20210309173451.45152-1-kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/stream.c')
-rw-r--r--block/stream.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/block/stream.c b/block/stream.c
index 1fa742b0db..97bee482dc 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -206,7 +206,7 @@ void stream_start(const char *job_id, BlockDriverState *bs,
const char *filter_node_name,
Error **errp)
{
- StreamBlockJob *s;
+ StreamBlockJob *s = NULL;
BlockDriverState *iter;
bool bs_read_only;
int basic_flags = BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED;
@@ -214,6 +214,7 @@ void stream_start(const char *job_id, BlockDriverState *bs,
BlockDriverState *cor_filter_bs = NULL;
BlockDriverState *above_base;
QDict *opts;
+ int ret;
assert(!(base && bottom));
assert(!(backing_file_str && bottom));
@@ -303,7 +304,7 @@ void stream_start(const char *job_id, BlockDriverState *bs,
* queried only at the job start and then cached.
*/
if (block_job_add_bdrv(&s->common, "active node", bs, 0,
- basic_flags | BLK_PERM_WRITE, &error_abort)) {
+ basic_flags | BLK_PERM_WRITE, errp)) {
goto fail;
}
@@ -320,8 +321,11 @@ void stream_start(const char *job_id, BlockDriverState *bs,
for (iter = bdrv_filter_or_cow_bs(bs); iter != base;
iter = bdrv_filter_or_cow_bs(iter))
{
- block_job_add_bdrv(&s->common, "intermediate node", iter, 0,
- basic_flags, &error_abort);
+ ret = block_job_add_bdrv(&s->common, "intermediate node", iter, 0,
+ basic_flags, errp);
+ if (ret < 0) {
+ goto fail;
+ }
}
s->base_overlay = base_overlay;
@@ -337,6 +341,9 @@ void stream_start(const char *job_id, BlockDriverState *bs,
return;
fail:
+ if (s) {
+ job_early_fail(&s->common.job);
+ }
if (cor_filter_bs) {
bdrv_cor_filter_drop(cor_filter_bs);
}