linux-stable/drivers/i2c
Vincent Whitchurch 84e1d0bf1d i2c: virtio: disable timeout handling
If a timeout is hit, it can result is incorrect data on the I2C bus
and/or memory corruptions in the guest since the device can still be
operating on the buffers it was given while the guest has freed them.

Here is, for example, the start of a slub_debug splat which was
triggered on the next transfer after one transfer was forced to timeout
by setting a breakpoint in the backend (rust-vmm/vhost-device):

 BUG kmalloc-1k (Not tainted): Poison overwritten
 First byte 0x1 instead of 0x6b
 Allocated in virtio_i2c_xfer+0x65/0x35c age=350 cpu=0 pid=29
 	__kmalloc+0xc2/0x1c9
 	virtio_i2c_xfer+0x65/0x35c
 	__i2c_transfer+0x429/0x57d
 	i2c_transfer+0x115/0x134
 	i2cdev_ioctl_rdwr+0x16a/0x1de
 	i2cdev_ioctl+0x247/0x2ed
 	vfs_ioctl+0x21/0x30
 	sys_ioctl+0xb18/0xb41
 Freed in virtio_i2c_xfer+0x32e/0x35c age=244 cpu=0 pid=29
 	kfree+0x1bd/0x1cc
 	virtio_i2c_xfer+0x32e/0x35c
 	__i2c_transfer+0x429/0x57d
 	i2c_transfer+0x115/0x134
 	i2cdev_ioctl_rdwr+0x16a/0x1de
 	i2cdev_ioctl+0x247/0x2ed
 	vfs_ioctl+0x21/0x30
 	sys_ioctl+0xb18/0xb41

There is no simple fix for this (the driver would have to always create
bounce buffers and hold on to them until the device eventually returns
the buffers), so just disable the timeout support for now.

Fixes: 3cfc883804 ("i2c: virtio: add a virtio i2c frontend driver")
Acked-by: Jie Deng <jie.deng@intel.com>
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-23 10:55:48 +01:00
..
algos i2c: algo: bit: use new macro to specifiy capabilities 2021-01-22 09:59:21 +01:00
busses i2c: virtio: disable timeout handling 2021-11-23 10:55:48 +01:00
muxes i2c: muxes: i2c-arb-gpio-challenge: Demote non-conformant kernel-doc headers 2021-05-27 21:29:03 +02:00
Kconfig i2c: add slave testunit driver 2020-09-21 11:02:17 +02:00
Makefile i2c: add slave testunit driver 2020-09-21 11:02:17 +02:00
i2c-boardinfo.c i2c: Remove support for dangling device properties 2021-04-10 21:43:02 +02:00
i2c-core-acpi.c More ACPI updates for 5.16-rc1 2021-11-10 11:52:40 -08:00
i2c-core-base.c i2c: Allow an ACPI driver to manage the device's power state during probe 2021-11-03 19:03:55 +01:00
i2c-core-of.c i2c: use my kernel.org address from now on 2020-05-05 16:29:09 +02:00
i2c-core-slave.c i2c: slave: add sanity check when unregistering 2020-07-28 18:37:17 +02:00
i2c-core-smbus.c i2c: core-smbus: Expose PEC calculate function for generic use 2021-06-25 17:09:34 +02:00
i2c-core.h i2c: acpi: Remove dead code, i.e. i2c_acpi_match_device() 2020-08-25 09:22:09 +02:00
i2c-dev.c Merge branch 'i2c/for-mergewindow' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2021-08-31 14:34:01 -07:00
i2c-mux.c i2c: mux: add sysfs header 2019-06-22 07:32:33 +02:00
i2c-slave-eeprom.c i2c: busses: Use fallthrough pseudo-keyword 2020-07-23 22:04:08 +02:00
i2c-slave-testunit.c i2c: testunit: add support for block process calls 2021-02-12 11:11:04 +01:00
i2c-smbus.c i2c: smbus: add core function handling SMBus host-notify 2020-09-09 10:38:28 +02:00
i2c-stub.c i2c: stub: remove definition of DEBUG 2021-01-17 13:00:10 +01:00