qemu/hw
Greg Kurz 1d20398694 9p: fix QEMU crash when renaming files
When using the 9P2000.u version of the protocol, the following shell
command line in the guest can cause QEMU to crash:

    while true; do rm -rf aa; mkdir -p a/b & touch a/b/c & mv a aa; done

With 9P2000.u, file renaming is handled by the WSTAT command. The
v9fs_wstat() function calls v9fs_complete_rename(), which calls
v9fs_fix_path() for every fid whose path is affected by the change.
The involved calls to v9fs_path_copy() may race with any other access
to the fid path performed by some worker thread, causing a crash like
shown below:

Thread 12 "qemu-system-x86" received signal SIGSEGV, Segmentation fault.
0x0000555555a25da2 in local_open_nofollow (fs_ctx=0x555557d958b8, path=0x0,
 flags=65536, mode=0) at hw/9pfs/9p-local.c:59
59          while (*path && fd != -1) {
(gdb) bt
#0  0x0000555555a25da2 in local_open_nofollow (fs_ctx=0x555557d958b8,
 path=0x0, flags=65536, mode=0) at hw/9pfs/9p-local.c:59
#1  0x0000555555a25e0c in local_opendir_nofollow (fs_ctx=0x555557d958b8,
 path=0x0) at hw/9pfs/9p-local.c:92
#2  0x0000555555a261b8 in local_lstat (fs_ctx=0x555557d958b8,
 fs_path=0x555556b56858, stbuf=0x7fff84830ef0) at hw/9pfs/9p-local.c:185
#3  0x0000555555a2b367 in v9fs_co_lstat (pdu=0x555557d97498,
 path=0x555556b56858, stbuf=0x7fff84830ef0) at hw/9pfs/cofile.c:53
#4  0x0000555555a1e9e2 in v9fs_stat (opaque=0x555557d97498)
 at hw/9pfs/9p.c:1083
#5  0x0000555555e060a2 in coroutine_trampoline (i0=-669165424, i1=32767)
 at util/coroutine-ucontext.c:116
#6  0x00007fffef4f5600 in __start_context () at /lib64/libc.so.6
#7  0x0000000000000000 in  ()
(gdb)

The fix is to take the path write lock when calling v9fs_complete_rename(),
like in v9fs_rename().

Impact:  DoS triggered by unprivileged guest users.

Fixes: CVE-2018-19489
Cc: P J P <ppandit@redhat.com>
Reported-by: zhibin hu <noirfate@gmail.com>
Reviewed-by: Prasad J Pandit <pjp@fedoraproject.org>
Signed-off-by: Greg Kurz <groug@kaod.org>
2018-11-23 13:28:03 +01:00
..
9pfs 9p: fix QEMU crash when renaming files 2018-11-23 13:28:03 +01:00
acpi hw/acpi/nvdimm: Don't take address of fields in packed structs 2018-11-12 15:14:06 +00:00
adc
alpha hw/alpha/typhoon: Remove unuseful code 2018-10-24 06:44:59 -03:00
arm hw/arm/sysbus-fdt: Only call match_fn callback if the type matches 2018-11-13 10:47:58 +00:00
audio audio: use TYPE_MV88W8618_AUDIO instead of hardcoded string 2018-10-29 13:50:15 +01:00
block nvme: fix bug with PCI IRQ pins on teardown 2018-11-22 19:37:31 +01:00
bt
char hw/arm/stm32f205: Fix the UART and Timer region size 2018-11-19 15:29:08 +00:00
core Machine queue, 2018-10-25 2018-10-25 20:17:12 +01:00
cpu hw/cpu/a15mpcore: If CPU has EL2, enable it on the GIC and wire it up 2018-08-24 13:17:34 +01:00
cris hw/cris: Use the IEC binary prefix definitions 2018-07-02 15:41:15 +02:00
display edid: silence a stringop-overflow warning 2018-11-12 14:14:18 +01:00
dma hw/dma/pl080: Remove hw_error() if DMA is enabled 2018-08-20 11:24:33 +01:00
gpio
hppa hw/hppa/dino: Remove unuseful code 2018-10-24 06:44:59 -03:00
hyperv hyperv_testdev: add SynIC message and event testmodes 2018-10-19 13:44:14 +02:00
i2c i2c: switch ddc to use the new edid generator 2018-10-15 09:57:33 +02:00
i386 hw/i386: add pc-i440fx-3.1 & pc-q35-3.1 2018-11-20 11:42:32 -02:00
ide replay: replay BH for IDE trim operation 2018-10-02 19:09:13 +02:00
input ps2: prevent changing irq state on save and load 2018-10-02 18:47:55 +02:00
intc target/arm: Move some system registers into a substructure 2018-10-24 07:50:16 +01:00
ipack
ipmi ipmi: Use proper struct reference for BT vmstate 2018-08-23 18:46:25 +02:00
isa configs: Add a CONFIG_SMC37C669 switch for the "smc37c669-superio" device 2018-10-24 07:33:44 +01:00
lm32 milkymist: Check for failure trying to load BIOS image 2018-11-06 11:32:14 +00:00
m68k
mem nvdimm: set non-volatile on the memory region 2018-11-06 21:35:05 +01:00
microblaze hw/microblaze/xlnx-zynqmp-pmu: Fix introspection problem in 'xlnx, zynqmp-pmu-soc' 2018-07-23 15:21:25 +01:00
mips hw/mips/malta: Remove unuseful code 2018-10-24 06:44:59 -03:00
misc pc-testdev: use HTTPS git URL 2018-11-12 11:26:02 +00:00
moxie change get_image_size return type to int64_t 2018-10-02 19:08:49 +02:00
net QEMU trivial patches collected between June and October 2018 2018-10-30 15:49:55 +00:00
nios2 hw/nios2: Use the IEC binary prefix definitions 2018-07-02 15:41:15 +02:00
nvram ppc: move at24c to its own CONFIG_ symbol 2018-10-30 09:12:09 +01:00
openrisc
pci pci_bridge: fix typo in comment 2018-11-05 13:24:02 -05:00
pci-bridge hw/pci-bridge/ioh3420: Remove unuseful header 2018-11-05 13:24:02 -05:00
pci-host ppc patch queue 2018-11-08 2018-11-08 14:42:37 +00:00
pcmcia
ppc ppc/spapr_caps: Add SPAPR_CAP_NESTED_KVM_HV 2018-11-08 13:08:35 +11:00
rdma config: split PVRDMA from RDMA 2018-08-18 18:01:34 +03:00
riscv hw/riscv/virt: Free the test device tree node name 2018-11-13 15:12:13 -08:00
s390x s390x/pci: properly fail if the zPCI device cannot be created 2018-11-13 16:46:55 +01:00
scsi scsi-disk: Fix crash if underlying host file or disk returns error 2018-11-22 16:43:48 +01:00
sd ssi-sd: Make devices picking up backends unavailable with -device 2018-10-24 07:50:16 +01:00
sh4 hw/sh4/sh_pci: Use DeviceState::realize rather than SysBusDevice::init 2018-10-24 06:44:59 -03:00
smbios smbios: Clean up error handling in smbios_add() 2018-10-19 14:51:34 +02:00
sparc sun4m: don't use legacy fw_cfg_init_mem() function 2018-08-20 19:18:31 +01:00
sparc64 hw/sparc64/niagara: Model the I/O Bridge with the 'unimplemented_device' 2018-10-24 06:44:59 -03:00
ssi hw/ssi/xilinx_spi: Use DeviceState::realize rather than SysBusDevice::init 2018-10-24 06:44:59 -03:00
timer hw/arm/stm32f205: Fix the UART and Timer region size 2018-11-19 15:29:08 +00:00
tpm tpm: use loop iterator to set sts data field 2018-11-14 15:47:24 -05:00
tricore hw/tricore: Use the IEC binary prefix definitions 2018-07-02 15:41:14 +02:00
unicore32
usb usb: fixes for ohci and smart card emulation. 2018-10-30 13:32:38 +00:00
vfio s390x/vfio-ap: report correct error 2018-11-05 09:55:01 +01:00
virtio Error reporting patches for 2018-10-22 2018-10-23 17:20:23 +01:00
watchdog qapi: Drop qapi_event_send_FOO()'s Error ** argument 2018-08-28 18:21:38 +02:00
xen xen: Use the PCI_DEVICE macro 2018-10-26 17:17:32 +02:00
xenpv
xtensa hw/xtensa: Use the IEC binary prefix definitions 2018-07-02 15:41:14 +02:00
Makefile.objs memory-device: introduce separate config option 2018-10-24 06:44:59 -03:00