Error reporting patches for 2019-12-02
PATCH 1+2 fix a crash in virtio-net failover error handling. Failover is new in 4.2. Jens Freimann would prefer this fix to go into 4.2.
PATCH 3 fixes a crash in Linux AIO initialization error handling. Stefan Hajnoczi thinks it's worth including in 4.2.
Both fixes are straightforward.
The following changes since commit fb2246882a2c8d7f084ebe0617e97ac78467d156:
.travis.yml: drop xcode9.4 from build matrix (2019-11-29 15:51:52 +0000)
are available in the Git repository at:
git://repo.or.cz/qemu/armbru.git tags/pull-error-2019-12-02
for you to fetch changes up to cb09104ea8418d9521d9a9d36ea0527b84ce51ac:
block/file-posix: Fix laio_init() error handling crash bug (2019-12-02 16:14:41 +0100)
----------------------------------------------------------------
Error reporting patches for 2019-12-02
----------------------------------------------------------------
Markus Armbruster (3):
net/virtio: Drop useless n->primary_dev not null checks net/virtio: Fix failover error handling crash bugs block/file-posix: Fix laio_init() error handling crash bug
block/file-posix.c | 2 +- hw/net/virtio-net.c | 27 ++++++++++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-)
Signature · 1 line
2.21.0
[PULL for-4.2 3/3] block/file-posix: Fix laio_init() error handling crash bug
raw_aio_attach_aio_context() passes uninitialized Error *local_err by reference to laio_init() via aio_setup_linux_aio(). When laio_init() fails, it passes it on to error_setg_errno(), tripping error_setv()'s assertion unless @local_err is null by dumb luck.
Fix by initializing @local_err properly.
Message-Id: <[email protected]>
--- block/file-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/file-posix.c +1 -1
@@ -1973,7 +1973,7 @@ static void raw_aio_attach_aio_context(BlockDriverState *bs,#ifdef CONFIG_LINUX_AIO BDRVRawState *s = bs->opaque;if (s->use_linux_aio) { -Error *local_err; +Error *local_err =NULL ;if (!aio_setup_linux_aio (new_context, &local_err)) {error_reportf_err (local_err,"Unable to use native AIO, " "falling back to thread pool: " );
Signature · 1 line
2.21.0
[PULL for-4.2 2/3] net/virtio: Fix failover error handling crash bugs
In reply to Markus ArmbrusterFunctions that take an Error ** parameter to pass an error to the caller expect the parameter to point to null. failover_replug_primary() violates this precondition in several places:
* After qemu_opts_from_qdict() failed, *errp is no longer null. Passing it to error_setg() is wrong, and will trip the assertion in error_setv(). Messed up in commit 150ab54aa6 "net/virtio: fix re-plugging of primary device". Simply drop the error_setg().
* Passing @errp to qemu_opt_set_bool(), hotplug_handler_pre_plug(), and hotplug_handler_plug() is wrong. If one of the first two fails, *errp is no longer null. Risks tripping the same assertion. Moreover, continuing after such errors is unsafe. Messed up in commit 9711cd0dfc "net/virtio: add failover support". Fix by handling each error properly.
failover_replug_primary() crashes when passed a null @errp. Also messed up in commit 9711cd0dfc. This bug can't bite as no caller actually passes null. Fix it anyway.
Message-Id: <[email protected]>
--- hw/net/virtio-net.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
hw/net/virtio-net.c +13 -6
@@ -2795,6 +2795,7 @@ static bool failover_unplug_primary(VirtIONet *n)static bool failover_replug_primary (VirtIONet *n,Error **errp) { +Error *err =NULL ;HotplugHandler *hotplug_ctrl;PCIDevice *pdev =PCI_DEVICE (n->primary_dev);
@@ -2806,27 +2807,33 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp)qemu_find_opts ("device" ), n->primary_device_dict, errp);if (!n->primary_device_opts) { -error_setg (errp,"virtio_net: couldn't find primary device opts" ); - goto out; +return false; } } n->primary_bus = n->primary_dev->parent_bus;if (!n->primary_bus) {error_setg (errp,"virtio_net: couldn't find primary bus" ); - goto out; +return false; }qdev_set_parent_bus (n->primary_dev, n->primary_bus); n->primary_should_be_hidden = false;qemu_opt_set_bool (n->primary_device_opts, -"partially_hotplugged" , true, errp); +"partially_hotplugged" , true, &err); +if (err) { + goto out; + } hotplug_ctrl =qdev_get_hotplug_handler (n->primary_dev);if (hotplug_ctrl) { -hotplug_handler_pre_plug (hotplug_ctrl, n->primary_dev, errp); +hotplug_handler_pre_plug (hotplug_ctrl, n->primary_dev, &err); +if (err) { + goto out; + }hotplug_handler_plug (hotplug_ctrl, n->primary_dev, errp); } out: -return *errp ==NULL ; +error_propagate (errp, err); +return !err; } static void virtio_net_handle_migration_primary(VirtIONet *n,
Signature · 1 line
2.21.0
[PULL for-4.2 1/3] net/virtio: Drop useless n->primary_dev not null checks
In reply to Markus Armbrustervirtio_net_handle_migration_primary() returns early when it can't ensure n->primary_dev is non-null. Checking it again right after that early return is redundant. Drop.
If n->primary_dev is null on entering failover_replug_primary(), @pdev will become null, and pdev->partially_hotplugged will crash. Checking n->primary_dev later is useless. It can't actually be null, because its caller virtio_net_handle_migration_primary() ensures it isn't. Drop the useless check.
Message-Id: <[email protected]>
--- hw/net/virtio-net.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
hw/net/virtio-net.c +1 -7
@@ -2810,11 +2810,6 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp) goto out; } } -if (!n->primary_dev) { -error_setg (errp,"virtio_net: couldn't find primary device" ); - goto out; - } - n->primary_bus = n->primary_dev->parent_bus;if (!n->primary_bus) {error_setg (errp,"virtio_net: couldn't find primary bus" );
@@ -2849,8 +2844,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n, } } -if (migration_in_setup (s) && !should_be_hidden && - n->primary_dev) { +if (migration_in_setup (s) && !should_be_hidden) {if (failover_unplug_primary (n)) {vmstate_unregister (n->primary_dev,qdev_get_vmsd (n->primary_dev), n->primary_dev);
Signature · 1 line
2.21.0
Peter Maydell
AppliedQuoted 17 lines · Markus Armbruster
PATCH 1+2 fix a crash in virtio-net failover error handling. Failover is new in 4.2. Jens Freimann would prefer this fix to go into 4.2.
PATCH 3 fixes a crash in Linux AIO initialization error handling. Stefan Hajnoczi thinks it's worth including in 4.2.
Both fixes are straightforward.
The following changes since commit
fb2246882a2c8d7f084ebe0617e97ac78467d156:.travis.yml: drop xcode9.4 from build matrix (2019-11-29 15:51:52 +0000)
are available in the Git repository at:
git://repo.or.cz/qemu/armbru.gittags/pull-error-2019-12-02
Quoted 8 lines
for you to fetch changes up to
cb09104ea8418d9521d9a9d36ea0527b84ce51ac:
block/file-posix: Fixlaio_init()error handling crash bug (2019-12-02 16:14:41 +0100)----------------------------------------------------------------
Error reporting patches for 2019-12-02----------------------------------------------------------------
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/4.2
for any user-visible changes.
-- PMM
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Subject: [PULL for-4.2 0/3] Error reporting patches for 2019-12-02
Type: series
Message-id: [email protected]
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
From https://github.com/patchew-project/qemu
fb22468..3903298 master -> master
From https://github.com/patchew-project/qemu
- [tag update] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
=== OUTPUT BEGIN ===
checkpatch.pl: no revisions returned for revlist '1' === OUTPUT END ===
Test command exited with code: 255
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]