linux-stable/drivers
Jan Dabros 23393c6461 char: tpm: Protect tpm_pm_suspend with locks
Currently tpm transactions are executed unconditionally in
tpm_pm_suspend() function, which may lead to races with other tpm
accessors in the system.

Specifically, the hw_random tpm driver makes use of tpm_get_random(),
and this function is called in a loop from a kthread, which means it's
not frozen alongside userspace, and so can race with the work done
during system suspend:

  tpm tpm0: tpm_transmit: tpm_recv: error -52
  tpm tpm0: invalid TPM_STS.x 0xff, dumping stack for forensics
  CPU: 0 PID: 1 Comm: init Not tainted 6.1.0-rc5+ #135
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.0-20220807_005459-localhost 04/01/2014
  Call Trace:
   tpm_tis_status.cold+0x19/0x20
   tpm_transmit+0x13b/0x390
   tpm_transmit_cmd+0x20/0x80
   tpm1_pm_suspend+0xa6/0x110
   tpm_pm_suspend+0x53/0x80
   __pnp_bus_suspend+0x35/0xe0
   __device_suspend+0x10f/0x350

Fix this by calling tpm_try_get_ops(), which itself is a wrapper around
tpm_chip_start(), but takes the appropriate mutex.

Signed-off-by: Jan Dabros <jsd@semihalf.com>
Reported-by: Vlastimil Babka <vbabka@suse.cz>
Tested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Tested-by: Vlastimil Babka <vbabka@suse.cz>
Link: https://lore.kernel.org/all/c5ba47ef-393f-1fba-30bd-1230d1b4b592@suse.cz/
Cc: stable@vger.kernel.org
Fixes: e891db1a18 ("tpm: turn on TPM on suspend for TPM 1.x")
[Jason: reworked commit message, added metadata]
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-12-04 12:49:13 -08:00
..
accessibility speakup: replace utils' u_char with unsigned char 2022-11-09 15:25:24 +01:00
acpi ACPI: HMAT: Fix initiator registration for single-initiator systems 2022-11-18 23:55:40 -08:00
amba
android binder: validate alloc->mm in ->mmap() handler 2022-11-09 15:41:27 +01:00
ata ata: libata-core: do not issue non-internal commands once EH is pending 2022-11-12 07:51:06 +09:00
atm
auxdisplay
base ACPI and device properties fixes for 6.1-rc3 2022-10-28 16:48:29 -07:00
bcma
block block-6.1-2022-11-25 2022-11-25 17:50:57 -08:00
bluetooth Bluetooth: virtio_bt: Use skb_put to set length 2022-11-02 14:15:42 -07:00
bus bus: ixp4xx: Don't touch bit 7 on IXP42x 2022-11-22 23:12:18 +01:00
cdrom
char char: tpm: Protect tpm_pm_suspend with locks 2022-12-04 12:49:13 -08:00
clk clk: qcom: gcc-sc8280xp: add cxo as parent for three ufs ref clks 2022-11-22 18:27:07 -08:00
clocksource Revert "clocksource/drivers/riscv: Events are stopped during CPU suspend" 2022-12-01 12:05:29 +01:00
comedi
connector
counter counter: 104-quad-8: Fix race getting function mode and direction 2022-10-23 20:39:26 -04:00
cpufreq cpufreq: amd-pstate: add amd-pstate driver parameter for mode selection 2022-11-22 19:57:15 +01:00
cpuidle
crypto
cxl cxl/region: Recycle region ids 2022-11-04 16:03:43 -07:00
dax device-dax: Fix duplicate 'hmem' device registration 2022-11-21 15:34:40 -08:00
dca
devfreq
dio
dma dmaengine: at_hdmac: Check return code of dma_async_device_register 2022-11-08 10:43:57 +05:30
dma-buf dma-buf: fix racing conflict of dma_heap_add() 2022-11-22 18:27:56 +05:30
edac
eisa
extcon extcon: usbc-tusb320: Call the Type-C IRQ handler only if a port is registered 2022-11-08 16:45:31 +01:00
firewire
firmware Char/Misc driver fixes for 6.1-rc6 2022-11-18 10:29:25 -08:00
fpga fpga: m10bmc-sec: Fix kconfig dependencies 2022-11-15 21:46:58 +08:00
fsi
gnss
gpio gpio: tegra: Convert to immutable irq chip 2022-10-20 13:47:54 +02:00
gpu drm fixes for 6.1-rc8 2022-12-02 15:35:21 -08:00
greybus
hid for-linus-2022111101 2022-11-11 09:03:19 -08:00
hsi
hte
hv Drivers: hv: vmbus: fix possible memory leak in vmbus_device_register() 2022-11-21 10:57:42 +00:00
hwmon hwmon: (asus-ec-sensors) Add checks for devm_kcalloc 2022-12-01 09:20:55 -08:00
hwspinlock
hwtracing coresight: cti: Fix hang in cti_disable_hw() 2022-10-25 19:08:07 +02:00
i2c i2c: imx: Only DMA messages with I2C_M_DMA_SAFE flag set 2022-12-02 00:12:25 +01:00
i3c
idle
iio iio: adc: aspeed: Remove the trim valid dts property. 2022-11-14 20:20:08 +00:00
infiniband RDMA/qedr: clean up work queue on failure in qedr_alloc_resources() 2022-10-28 12:59:40 -03:00
input Input updates for v6.1-rc7 2022-12-04 12:18:37 -08:00
interconnect
iommu iommu/vt-d: Fix PCI device refcount leak in dmar_dev_scope_init() 2022-12-02 11:45:33 +01:00
ipack
irqchip
isdn mISDN: fix misuse of put_device() in mISDN_register_device() 2022-11-14 10:43:13 +00:00
leds leds: simatic-ipc-leds-gpio: fix incorrect LED to GPIO mapping 2022-10-24 11:32:10 +02:00
macintosh
mailbox
mcb
md block-6.1-2022-11-18 2022-11-18 13:59:45 -08:00
media v4l2: don't fall back to follow_pfn() if pin_user_pages_fast() fails 2022-12-02 13:33:57 -08:00
memory
memstick
message
mfd Revert "mfd: syscon: Remove repetition of the regmap_get_val_endian()" 2022-10-23 12:04:56 -07:00
misc misc/vmw_vmci: fix an infoleak in vmci_host_do_receive_datagram() 2022-11-09 15:40:03 +01:00
mmc mmc: sdhci-sprd: Fix no reset data and command after voltage switch 2022-12-01 11:28:39 +01:00
most
mtd mtd: onenand: omap2: add dependency on GPMC 2022-11-07 16:53:04 +01:00
mux
net net: ethernet: renesas: ravb: Fix promiscuous mode after system resumed 2022-11-29 08:41:01 -08:00
nfc nfc: st-nci: fix incorrect sizing calculations in EVT_TRANSACTION 2022-11-23 20:01:50 -08:00
ntb
nubus
nvdimm
nvme block-6.1-2022-12-02 2022-12-02 16:27:15 -08:00
nvmem nvmem: lan9662-otp: Change return type of lan9662_otp_wait_flag_clear() 2022-11-22 18:22:05 +01:00
of of: property: decrement node refcount in of_fwnode_get_reference_args() 2022-11-22 17:22:52 -06:00
opp
parisc parisc: Export iosapic_serial_irq() symbol for serial port driver 2022-10-27 09:12:05 +02:00
parport parport_pc: Avoid FIFO port location truncation 2022-11-09 15:40:32 +01:00
pci PCI: hv: Only reuse existing IRTE allocation for Multi-MSI 2022-11-12 12:43:59 +00:00
pcmcia
peci
perf
phy phy: ralink: mt7621-pci: add sentinel to quirks table 2022-11-05 13:01:25 +05:30
pinctrl pinctrl: intel: Save and restore pins in "direct IRQ" mode 2022-11-28 21:41:31 +01:00
platform platform-drivers-x86 for v6.1-4 2022-11-16 10:36:13 -08:00
pnp
power power: supply: ab8500: Defer thermal zone probe 2022-11-01 01:00:32 +01:00
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator regulator: Late fixes for v6.1 2022-11-25 13:54:48 -08:00
remoteproc
reset
rpmsg
rtc rtc: cmos: fix build on non-ACPI platforms 2022-10-18 22:36:54 +02:00
s390 block-6.1-2022-11-25 2022-11-25 17:50:57 -08:00
sbus
scsi hyperv-fixes for 6.1-rc7 2022-11-25 12:32:42 -08:00
sh
siox siox: fix possible memory leak in siox_device_add() 2022-11-09 15:40:14 +01:00
slimbus slimbus: qcom-ngd: Fix build error when CONFIG_SLIM_QCOM_NGD_CTRL=y && CONFIG_QCOM_RPROC_COMMON=m 2022-11-10 18:45:40 +01:00
soc soc: imx8m: Enable OCOTP clock before reading the register 2022-11-14 15:52:53 +08:00
soundwire soundwire: qcom: check for outanding writes before doing a read 2022-10-28 17:00:38 +05:30
spi spi: Fixes for v6.1 2022-11-23 11:19:06 -08:00
spmi
ssb
staging Staging driver fix for 6.1-rc6 2022-11-18 12:02:38 -08:00
target scsi: target: tcm_loop: Fix possible name leak in tcm_loop_setup_hba_bus() 2022-11-17 17:46:16 +00:00
tc
tee tee: optee: fix possible memory leak in optee_register_device() 2022-11-17 09:22:12 +01:00
thermal
thunderbolt
tty TTY/Serial driver fixes for 6.1-rc6 2022-11-18 10:59:52 -08:00
ufs scsi: ufs: core: Fix typo in comment 2022-10-22 03:29:32 +00:00
uio
usb usb: cdnsp: fix issue with ZLP - added TD_SIZE = 1 2022-11-22 16:52:05 +01:00
vdpa
vfio vfio/pci: Check the device set open count on reset 2022-11-10 12:03:36 -07:00
vhost
video Merge tag 'drm-misc-fixes-2022-11-24' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes 2022-11-25 09:21:11 +10:00
virt virt/sev-guest: Prevent IV reuse in the SNP guest driver 2022-11-21 11:03:40 +01:00
virtio
vlynq
w1
watchdog linux-watchdog 6.1-rc4 tag 2022-11-01 12:21:53 -07:00
xen xen: branch for v6.1-rc6 2022-11-16 10:49:06 -08:00
zorro
Kconfig
Makefile