android_kernel_samsung_a7y1.../drivers/misc
Nadav Amit 7ccb2f4453 VMCI: Release resource if the work is already queued
commit ba03a9bbd17b149c373c0ea44017f35fc2cd0f28 upstream.

Francois reported that VMware balloon gets stuck after a balloon reset,
when the VMCI doorbell is removed. A similar error can occur when the
balloon driver is removed with the following splat:

[ 1088.622000] INFO: task modprobe:3565 blocked for more than 120 seconds.
[ 1088.622035]       Tainted: G        W         5.2.0 #4
[ 1088.622087] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1088.622205] modprobe        D    0  3565   1450 0x00000000
[ 1088.622210] Call Trace:
[ 1088.622246]  __schedule+0x2a8/0x690
[ 1088.622248]  schedule+0x2d/0x90
[ 1088.622250]  schedule_timeout+0x1d3/0x2f0
[ 1088.622252]  wait_for_completion+0xba/0x140
[ 1088.622320]  ? wake_up_q+0x80/0x80
[ 1088.622370]  vmci_resource_remove+0xb9/0xc0 [vmw_vmci]
[ 1088.622373]  vmci_doorbell_destroy+0x9e/0xd0 [vmw_vmci]
[ 1088.622379]  vmballoon_vmci_cleanup+0x6e/0xf0 [vmw_balloon]
[ 1088.622381]  vmballoon_exit+0x18/0xcc8 [vmw_balloon]
[ 1088.622394]  __x64_sys_delete_module+0x146/0x280
[ 1088.622408]  do_syscall_64+0x5a/0x130
[ 1088.622410]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 1088.622415] RIP: 0033:0x7f54f62791b7
[ 1088.622421] Code: Bad RIP value.
[ 1088.622421] RSP: 002b:00007fff2a949008 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
[ 1088.622426] RAX: ffffffffffffffda RBX: 000055dff8b55d00 RCX: 00007f54f62791b7
[ 1088.622426] RDX: 0000000000000000 RSI: 0000000000000800 RDI: 000055dff8b55d68
[ 1088.622427] RBP: 000055dff8b55d00 R08: 00007fff2a947fb1 R09: 0000000000000000
[ 1088.622427] R10: 00007f54f62f5cc0 R11: 0000000000000206 R12: 000055dff8b55d68
[ 1088.622428] R13: 0000000000000001 R14: 000055dff8b55d68 R15: 00007fff2a94a3f0

The cause for the bug is that when the "delayed" doorbell is invoked, it
takes a reference on the doorbell entry and schedules work that is
supposed to run the appropriate code and drop the doorbell entry
reference. The code ignores the fact that if the work is already queued,
it will not be scheduled to run one more time. As a result one of the
references would not be dropped. When the code waits for the reference
to get to zero, during balloon reset or module removal, it gets stuck.

Fix it. Drop the reference if schedule_work() indicates that the work is
already queued.

Note that this bug got more apparent (or apparent at all) due to
commit ce664331b248 ("vmw_balloon: VMCI_DOORBELL_SET does not check status").

Fixes: 83e2ec765be03 ("VMCI: doorbell implementation.")
Reported-by: Francois Rigault <rigault.francois@gmail.com>
Cc: Jorgen Hansen <jhansen@vmware.com>
Cc: Adit Ranadive <aditr@vmware.com>
Cc: Alexios Zavras <alexios.zavras@intel.com>
Cc: Vishnu DASA <vdasa@vmware.com>
Cc: stable@vger.kernel.org
Signed-off-by: Nadav Amit <namit@vmware.com>
Reviewed-by: Vishnu Dasa <vdasa@vmware.com>
Link: https://lore.kernel.org/r/20190820202638.49003-1-namit@vmware.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-06 21:33:52 +02:00
..
altera-stapl A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
c2port A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cb710 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cxl A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
echo A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
eeprom A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
genwqe genwqe: Prevent an integer overflow in the ioctl 2020-04-06 18:45:18 +02:00
gnss_if A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ibmasm A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
lis3lv02d A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mcu_ipc A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mei A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mic A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
modem_if A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
modem_v1 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
samsung A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sgi-gru A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sgi-xp A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ti-st A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tui A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tzdev A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
usim_det A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
vmw_vmci VMCI: Release resource if the work is already queued 2020-04-06 21:33:52 +02:00
ad525x_dpot-i2c.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ad525x_dpot-spi.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ad525x_dpot.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ad525x_dpot.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
apds990x.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
apds9802als.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
arm-charlcd.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
atmel_tclib.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
atmel-ssc.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
bh1770glc.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
bh1780gli.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
bmp085-i2c.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
bmp085-spi.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
bmp085.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
bmp085.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cs5535-mfgpt.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
dmverity_query.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ds1682.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
dummy-irq.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
enclosure.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
exynos_ima.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
fsa9480.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
hmc6352.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
hpilo.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
hpilo.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ics932s401.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ioc4.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
isl29003.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
isl29020.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Kconfig A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
kgdbts.c Drivers: misc: fix out-of-bounds access in function param_set_kgdbts_var 2020-04-06 19:03:10 +02:00
lattice-ecp3-config.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
lkdtm.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Makefile A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
memory_state_time.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
pch_phub.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
phantom.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
pti.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
qcom-coincell.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
spear13xx_pcie_gadget.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sram.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ti_dac7512.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tifm_7xx1.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tifm_core.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tima_debug_log.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tima_debug_test.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tsl2550.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tzic64.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
uid_cputime.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
uid_sys_stats.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
vexpress-syscfg.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
vmw_balloon.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30