No description
Find a file
Markus Armbruster 843c4cfcf4 virtio-net: Fix duplex=... and speed=... error handling
virtio_net_device_realize() rejects invalid duplex and speed values.
The error handling is broken:

    $ ../qemu/bld-sani/x86_64-softmmu/qemu-system-x86_64 -S -display none -monitor stdio
    QEMU 4.2.93 monitor - type 'help' for more information
    (qemu) device_add virtio-net,duplex=x
    Error: 'duplex' must be 'half' or 'full'
    (qemu) c
    =================================================================
    ==15654==ERROR: AddressSanitizer: heap-use-after-free on address 0x62e000014590 at pc 0x560b75c8dc13 bp 0x7fffdf1a6950 sp 0x7fffdf1a6940
    READ of size 8 at 0x62e000014590 thread T0
	#0 0x560b75c8dc12 in object_dynamic_cast_assert /work/armbru/qemu/qom/object.c:826
	#1 0x560b74c38ac0 in virtio_vmstate_change /work/armbru/qemu/hw/virtio/virtio.c:3210
	#2 0x560b74d9765e in vm_state_notify /work/armbru/qemu/softmmu/vl.c:1271
	#3 0x560b7494ba72 in vm_prepare_start /work/armbru/qemu/cpus.c:2156
	#4 0x560b7494bacd in vm_start /work/armbru/qemu/cpus.c:2162
	#5 0x560b75a7d890 in qmp_cont /work/armbru/qemu/monitor/qmp-cmds.c:160
	#6 0x560b75a8d70a in hmp_cont /work/armbru/qemu/monitor/hmp-cmds.c:1043
	#7 0x560b75a799f2 in handle_hmp_command /work/armbru/qemu/monitor/hmp.c:1082
    [...]

    0x62e000014590 is located 33168 bytes inside of 42288-byte region [0x62e00000c400,0x62e000016930)
    freed by thread T1 here:
	#0 0x7feadd39491f in __interceptor_free (/lib64/libasan.so.5+0x10d91f)
	#1 0x7feadcebcd7c in g_free (/lib64/libglib-2.0.so.0+0x55d7c)
	#2 0x560b75c8fd40 in object_unref /work/armbru/qemu/qom/object.c:1128
	#3 0x560b7498a625 in memory_region_unref /work/armbru/qemu/memory.c:1762
	#4 0x560b74999fa4 in do_address_space_destroy /work/armbru/qemu/memory.c:2788
	#5 0x560b762362fc in call_rcu_thread /work/armbru/qemu/util/rcu.c:283
	#6 0x560b761c8884 in qemu_thread_start /work/armbru/qemu/util/qemu-thread-posix.c:519
	#7 0x7fead9be34bf in start_thread (/lib64/libpthread.so.0+0x84bf)

    previously allocated by thread T0 here:
	#0 0x7feadd394d18 in __interceptor_malloc (/lib64/libasan.so.5+0x10dd18)
	#1 0x7feadcebcc88 in g_malloc (/lib64/libglib-2.0.so.0+0x55c88)
	#2 0x560b75c8cf8a in object_new /work/armbru/qemu/qom/object.c:699
	#3 0x560b75010ad9 in qdev_device_add /work/armbru/qemu/qdev-monitor.c:654
	#4 0x560b750120c2 in qmp_device_add /work/armbru/qemu/qdev-monitor.c:805
	#5 0x560b75012c1b in hmp_device_add /work/armbru/qemu/qdev-monitor.c:905
    [...]
    ==15654==ABORTING

Cause: virtio_net_device_realize() neglects to bail out after setting
the error.  Fix that.

Fixes: 9473939ed7
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200422130719.28225-9-armbru@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
2020-04-29 08:01:52 +02:00
.github .github: Enable repo-lockdown bot to refuse GitHub pull requests 2020-04-07 16:19:18 +01:00
.gitlab-ci.d
accel tcg: Remove softmmu code_gen_buffer fixed address 2020-03-28 14:09:44 -07:00
audio dsoundaudio: dsound_get_buffer_in should honor *size 2020-04-06 13:29:53 +02:00
authz
backends cryptodev: Fix cryptodev_builtin_cleanup() error API violation 2020-04-29 08:01:52 +02:00
block block/file-posix: Fix check_cache_dropped() error handling 2020-04-29 08:01:52 +02:00
bsd-user
capstone@22ead3e0bf
chardev
contrib vhost-user-gpu: Release memory returned by vu_queue_pop() with free() 2020-04-15 19:00:39 +01:00
crypto
default-configs Add rx-softmmu 2020-03-19 17:58:05 +01:00
disas
docs Deprecate KVM support for AArch32 2020-04-14 17:20:22 +01:00
dtc@88f18909db
dump various: Remove suspicious '\' character outside of #define in C code 2020-04-29 08:01:51 +02:00
fpu softfloat: Fix BAD_SHIFT from normalizeFloatx80Subnormal 2020-04-07 16:19:49 +01:00
fsdev
gdb-xml target/rx: CPU definitions 2020-03-19 17:58:05 +01:00
hw virtio-net: Fix duplex=... and speed=... error handling 2020-04-29 08:01:52 +02:00
include qemu-img: Move is_valid_option_list() to qemu-img.c and rewrite 2020-04-29 08:01:52 +02:00
io
libdecnumber
linux-headers
linux-user ppc patch queue for 2020-04-17 2020-04-20 19:57:18 +01:00
migration migration: fix cleanup_bh leak on resume 2020-04-02 14:55:45 -04:00
monitor migration: use "" instead of (null) for tls-authz 2020-03-25 12:31:38 +00:00
nbd nbd/server: use bdrv_dirty_bitmap_next_dirty_area 2020-03-18 14:03:46 -04:00
net net/colo-compare.c: Expose "expired_scan_cycle" to users 2020-03-31 21:14:35 +08:00
pc-bios pseries: Update SLOF firmware image 2020-04-07 08:55:11 +10:00
plugins lockable: add QemuRecMutex support 2020-03-17 15:18:45 +01:00
po
python/qemu python/qemu: Kill QEMU process if 'quit' doesn't work 2020-03-21 22:37:32 +00:00
qapi qmp: fix leak on callbacks that return both value and error 2020-04-02 14:55:46 -04:00
qga qga: Restrict guest-file-read count to 48 MB to avoid crashes 2020-04-15 09:18:48 -05:00
qobject json: Fix check for unbalanced right curly brace 2020-04-07 13:10:11 +02:00
qom object-add: don't create return value if failed 2020-04-02 14:56:10 -04:00
replay
roms pseries: Update SLOF firmware image 2020-04-07 08:55:11 +10:00
scripts kernel-doc: Use c:struct for Sphinx 3.0 and later 2020-04-14 17:15:33 +01:00
scsi
slirp@2faae0f778 slirp: update to fix CVE-2020-1983 2020-04-21 18:39:20 +01:00
softmmu vl.c: error out if -mem-path is used together with -M memory-backend 2020-04-13 02:56:18 -04:00
storage-daemon
stubs
target various: Remove suspicious '\' character outside of #define in C code 2020-04-29 08:01:51 +02:00
tcg tcg/mips: mips sync* encode error 2020-04-12 14:07:07 -07:00
tests test-qemu-opts: Simplify test_has_help_option() after bug fix 2020-04-29 08:01:51 +02:00
tools/virtiofsd tools/virtiofsd/passthrough_ll: Fix double close() 2020-03-25 12:31:38 +00:00
trace
ui ui/input-linux: Do not ignore ioctl() return value 2020-03-25 09:55:03 +01:00
util qemu-img: Move is_valid_option_list() to qemu-img.c and rewrite 2020-04-29 08:01:52 +02:00
.cirrus.yml
.dir-locals.el
.editorconfig
.exrc
.gdbinit
.gitignore
.gitlab-ci-edk2.yml
.gitlab-ci-opensbi.yml
.gitlab-ci.yml
.gitmodules
.gitpublish
.mailmap MAINTAINERS: Adjust maintainer's email 2020-03-17 13:51:24 +01:00
.patchew.yml
.readthedocs.yml
.shippable.yml
.travis.yml .travis.yml: Cache acceptance-test assets 2020-04-06 20:03:14 +02:00
arch_init.c Add rx-softmmu 2020-03-19 17:58:05 +01:00
balloon.c
block.c block: fix bdrv_root_attach_child forget to unref child_bs 2020-03-27 14:47:23 +01:00
blockdev-nbd.c
blockdev.c job: take each job's lock individually in job_txn_apply 2020-04-07 14:34:47 +02:00
blockjob.c
bootdevice.c
Changelog
CODING_STYLE.rst
configure configure: disable PIE for Windows builds 2020-04-15 11:38:23 +01:00
COPYING
COPYING.LIB
cpus-common.c
cpus.c cpus: Proper range-checking for -icount shift=N 2020-04-29 08:01:52 +02:00
device_tree.c device_tree: Add info message when dumping dtb to file 2020-03-20 14:55:44 -07:00
disas.c
dma-helpers.c
exec-vary.c
exec.c exec: Fix for qemu_ram_resize() callback 2020-04-13 06:55:54 -04:00
gdbstub.c gdbstub: fix compiler complaining 2020-04-07 16:19:49 +01:00
gitdm.config
hmp-commands-info.hx
hmp-commands.hx
ioport.c
iothread.c
job-qmp.c job: take each job's lock individually in job_txn_apply 2020-04-07 14:34:47 +02:00
job.c job: take each job's lock individually in job_txn_apply 2020-04-07 14:34:47 +02:00
Kconfig.host
LICENSE
MAINTAINERS scripts/run-coverity-scan: Script to run Coverity Scan build 2020-04-14 09:44:31 +01:00
Makefile configure: Honour --disable-werror for Sphinx 2020-04-14 13:15:40 +01:00
Makefile.objs
Makefile.target update syscall numbers to linux 5.5 (with scripts) 2020-03-20 16:00:21 +00:00
memory.c memory: Simplify memory_region_init_rom_nomigrate() to ease review 2020-03-17 15:18:46 +01:00
memory_ldst.inc.c
memory_mapping.c
module-common.c
os-posix.c
os-win32.c
qdev-monitor.c
qemu-bridge-helper.c
qemu-edid.c
qemu-img-cmds.hx
qemu-img.c qemu-img: Reject broken -o "" 2020-04-29 08:01:52 +02:00
qemu-io-cmds.c
qemu-io.c
qemu-keymap.c
qemu-nbd.c
qemu-options-wrapper.h
qemu-options.h
qemu-options.hx docs: Improve our gdbstub documentation 2020-04-14 13:15:40 +01:00
qemu-seccomp.c
qemu-storage-daemon.c
qemu.nsi
qemu.sasl
qtest.c
README.rst
replication.c
replication.h
rules.mak
thunk.c
tpm.c
trace-events
VERSION Update version for v5.0.0 release 2020-04-28 17:46:57 +01:00
version.rc

===========
QEMU README
===========

QEMU is a generic and open source machine & userspace emulator and
virtualizer.

QEMU is capable of emulating a complete machine in software without any
need for hardware virtualization support. By using dynamic translation,
it achieves very good performance. QEMU can also integrate with the Xen
and KVM hypervisors to provide emulated hardware while allowing the
hypervisor to manage the CPU. With hypervisor support, QEMU can achieve
near native performance for CPUs. When QEMU emulates CPUs directly it is
capable of running operating systems made for one machine (e.g. an ARMv7
board) on a different machine (e.g. an x86_64 PC board).

QEMU is also capable of providing userspace API virtualization for Linux
and BSD kernel interfaces. This allows binaries compiled against one
architecture ABI (e.g. the Linux PPC64 ABI) to be run on a host using a
different architecture ABI (e.g. the Linux x86_64 ABI). This does not
involve any hardware emulation, simply CPU and syscall emulation.

QEMU aims to fit into a variety of use cases. It can be invoked directly
by users wishing to have full control over its behaviour and settings.
It also aims to facilitate integration into higher level management
layers, by providing a stable command line interface and monitor API.
It is commonly invoked indirectly via the libvirt library when using
open source applications such as oVirt, OpenStack and virt-manager.

QEMU as a whole is released under the GNU General Public License,
version 2. For full licensing details, consult the LICENSE file.


Building
========

QEMU is multi-platform software intended to be buildable on all modern
Linux platforms, OS-X, Win32 (via the Mingw64 toolchain) and a variety
of other UNIX targets. The simple steps to build QEMU are:


.. code-block:: shell

  mkdir build
  cd build
  ../configure
  make

Additional information can also be found online via the QEMU website:

* `<https://qemu.org/Hosts/Linux>`_
* `<https://qemu.org/Hosts/Mac>`_
* `<https://qemu.org/Hosts/W32>`_


Submitting patches
==================

The QEMU source code is maintained under the GIT version control system.

.. code-block:: shell

   git clone https://git.qemu.org/git/qemu.git

When submitting patches, one common approach is to use 'git
format-patch' and/or 'git send-email' to format & send the mail to the
qemu-devel@nongnu.org mailing list. All patches submitted must contain
a 'Signed-off-by' line from the author. Patches should follow the
guidelines set out in the CODING_STYLE.rst file.

Additional information on submitting patches can be found online via
the QEMU website

* `<https://qemu.org/Contribute/SubmitAPatch>`_
* `<https://qemu.org/Contribute/TrivialPatches>`_

The QEMU website is also maintained under source control.

.. code-block:: shell

  git clone https://git.qemu.org/git/qemu-web.git

* `<https://www.qemu.org/2017/02/04/the-new-qemu-website-is-up/>`_

A 'git-publish' utility was created to make above process less
cumbersome, and is highly recommended for making regular contributions,
or even just for sending consecutive patch series revisions. It also
requires a working 'git send-email' setup, and by default doesn't
automate everything, so you may want to go through the above steps
manually for once.

For installation instructions, please go to

*  `<https://github.com/stefanha/git-publish>`_

The workflow with 'git-publish' is:

.. code-block:: shell

  $ git checkout master -b my-feature
  $ # work on new commits, add your 'Signed-off-by' lines to each
  $ git publish

Your patch series will be sent and tagged as my-feature-v1 if you need to refer
back to it in the future.

Sending v2:

.. code-block:: shell

  $ git checkout my-feature # same topic branch
  $ # making changes to the commits (using 'git rebase', for example)
  $ git publish

Your patch series will be sent with 'v2' tag in the subject and the git tip
will be tagged as my-feature-v2.

Bug reporting
=============

The QEMU project uses Launchpad as its primary upstream bug tracker. Bugs
found when running code built from QEMU git or upstream released sources
should be reported via:

* `<https://bugs.launchpad.net/qemu/>`_

If using QEMU via an operating system vendor pre-built binary package, it
is preferable to report bugs to the vendor's own bug tracker first. If
the bug is also known to affect latest upstream code, it can also be
reported via launchpad.

For additional information on bug reporting consult:

* `<https://qemu.org/Contribute/ReportABug>`_


Contact
=======

The QEMU community can be contacted in a number of ways, with the two
main methods being email and IRC

* `<mailto:qemu-devel@nongnu.org>`_
* `<https://lists.nongnu.org/mailman/listinfo/qemu-devel>`_
* #qemu on irc.oftc.net

Information on additional methods of contacting the community can be
found online via the QEMU website:

* `<https://qemu.org/Contribute/StartHere>`_