linux/drivers
Pavan Kumar Paluri ce3d2d6b15 crypto: ccp - Properly unregister /dev/sev on sev PLATFORM_STATUS failure
In case of sev PLATFORM_STATUS failure, sev_get_api_version() fails
resulting in sev_data field of psp_master nulled out. This later becomes
a problem when unloading the ccp module because the device has not been
unregistered (via misc_deregister()) before clearing the sev_data field
of psp_master. As a result, on reloading the ccp module, a duplicate
device issue is encountered as can be seen from the dmesg log below.

on reloading ccp module via modprobe ccp

Call Trace:
  <TASK>
  dump_stack_lvl+0xd7/0xf0
  dump_stack+0x10/0x20
  sysfs_warn_dup+0x5c/0x70
  sysfs_create_dir_ns+0xbc/0xd
  kobject_add_internal+0xb1/0x2f0
  kobject_add+0x7a/0xe0
  ? srso_alias_return_thunk+0x5/0xfbef5
  ? get_device_parent+0xd4/0x1e0
  ? __pfx_klist_children_get+0x10/0x10
  device_add+0x121/0x870
  ? srso_alias_return_thunk+0x5/0xfbef5
  device_create_groups_vargs+0xdc/0x100
  device_create_with_groups+0x3f/0x60
  misc_register+0x13b/0x1c0
  sev_dev_init+0x1d4/0x290 [ccp]
  psp_dev_init+0x136/0x300 [ccp]
  sp_init+0x6f/0x80 [ccp]
  sp_pci_probe+0x2a6/0x310 [ccp]
  ? srso_alias_return_thunk+0x5/0xfbef5
  local_pci_probe+0x4b/0xb0
  work_for_cpu_fn+0x1a/0x30
  process_one_work+0x203/0x600
  worker_thread+0x19e/0x350
  ? __pfx_worker_thread+0x10/0x10
  kthread+0xeb/0x120
  ? __pfx_kthread+0x10/0x10
  ret_from_fork+0x3c/0x60
  ? __pfx_kthread+0x10/0x10
  ret_from_fork_asm+0x1a/0x30
  </TASK>
  kobject: kobject_add_internal failed for sev with -EEXIST, don't try to register things with the same name in the same directory.
  ccp 0000:22:00.1: sev initialization failed
  ccp 0000:22:00.1: psp initialization failed
  ccp 0000:a2:00.1: no command queues available
  ccp 0000:a2:00.1: psp enabled

Address this issue by unregistering the /dev/sev before clearing out
sev_data in case of PLATFORM_STATUS failure.

Fixes: 200664d523 ("crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support")
Cc: stable@vger.kernel.org
Signed-off-by: Pavan Kumar Paluri <papaluri@amd.com>
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2024-08-30 18:22:30 +08:00
..
accel
accessibility
acpi RISC-V Patches for the 6.11 Merge Window, Part 2 2024-07-27 10:14:34 -07:00
amba
android binder: fix hang of unregistered readers 2024-07-12 11:31:37 +02:00
ata Char/Misc and other driver changes for 6.11-rc1 2024-07-19 15:55:08 -07:00
atm
auxdisplay auxdisplay updates for v6.11 2024-07-26 11:04:28 -07:00
base regmap: Fix for v6.11 2024-07-27 12:26:09 -07:00
bcma
block block-6.11-20240726 2024-07-27 15:28:53 -07:00
bluetooth virtio: features, fixes, cleanups 2024-07-19 11:57:55 -07:00
bus Devicetree fixes for 6.11, part 1 2024-07-27 12:46:16 -07:00
cache
cdrom sysctl: treewide: constify the ctl_table argument of proc_handlers 2024-07-24 20:59:29 +02:00
cdx
char hwrng: cctrng - Add missing clk_disable_unprepare in cctrng_resume 2024-08-10 12:25:34 +08:00
clk Devicetree fixes for 6.11, part 1 2024-07-27 12:46:16 -07:00
clocksource of: remove internal arguments from of_property_for_each_u32() 2024-07-25 06:53:47 -05:00
comedi
connector
counter Char/Misc and other driver changes for 6.11-rc1 2024-07-19 15:55:08 -07:00
cpufreq Power management updates for 6.11-rc1 2024-07-16 15:54:03 -07:00
cpuidle
crypto crypto: ccp - Properly unregister /dev/sev on sev PLATFORM_STATUS failure 2024-08-30 18:22:30 +08:00
cxl CXL for v6.11 merge window 2024-07-28 09:33:28 -07:00
dax Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
dca Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
devfreq
dio dio: Have dio_bus_match() callback take a const * 2024-07-10 15:38:14 +02:00
dma Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
dma-buf - 875fa64577 ("mm/hugetlb_vmemmap: fix race with speculative PFN 2024-07-21 17:15:46 -07:00
dpll
edac minmax: add a few more MIN_T/MAX_T users 2024-07-28 13:41:14 -07:00
eisa
extcon
firewire Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
firmware RISC-V Patches for the 6.11 Merge Window, Part 2 2024-07-27 10:14:34 -07:00
fpga Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
fsi Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
gnss
gpio gpio fixes for v6.11-rc1 2024-07-27 12:54:06 -07:00
gpu minmax: add a few more MIN_T/MAX_T users 2024-07-28 13:41:14 -07:00
greybus Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
hid Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
hsi Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
hte
hv Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
hwmon Char/Misc and other driver changes for 6.11-rc1 2024-07-19 15:55:08 -07:00
hwspinlock
hwtracing Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
i2c Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
i3c I3C for 6.11 2024-07-27 10:53:06 -07:00
idle
iio of: remove internal arguments from of_property_for_each_u32() 2024-07-25 06:53:47 -05:00
infiniband IOMMU Updates for Linux v6.11 2024-07-19 09:59:58 -07:00
input Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
interconnect Char/Misc and other driver changes for 6.11-rc1 2024-07-19 15:55:08 -07:00
iommu IOMMU Fixes for Linux v6.11-rc1 2024-07-27 12:39:55 -07:00
ipack
irqchip of: remove internal arguments from of_property_for_each_u32() 2024-07-25 06:53:47 -05:00
isdn mISDN: Fix a use after free in hfcmulti_tx() 2024-07-25 08:05:05 -07:00
leds - Core Frameworks 2024-07-17 17:51:30 -07:00
macintosh sysctl: treewide: constify the ctl_table argument of proc_handlers 2024-07-25 12:58:36 -07:00
mailbox mailbox: mtk-cmdq: Move devm_mbox_controller_register() after devm_pm_runtime_enable() 2024-07-19 21:25:23 -05:00
mcb Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
md minmax: add a few more MIN_T/MAX_T users 2024-07-28 13:41:14 -07:00
media a couple of leaks on failure exits missing fdput() 2024-07-26 10:26:33 -07:00
memory
memstick Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
message
mfd Devicetree fixes for 6.11, part 1 2024-07-27 12:46:16 -07:00
misc Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
mmc Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
most Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
mtd This pull request contains updates (actually, just fixes) for UBI and UBIFS: 2024-07-28 11:51:51 -07:00
mux
net minmax: add a few more MIN_T/MAX_T users 2024-07-28 13:41:14 -07:00
nfc
ntb Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
nubus
nvdimm Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
nvme nvme fixes for Linux 6.11 2024-07-26 08:06:15 -06:00
nvmem Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
of IOMMU Updates for Linux v6.11 2024-07-19 09:59:58 -07:00
opp Merge branches 'pm-opp' and 'pm-tools' 2024-07-15 18:55:14 +02:00
parisc
parport sysctl: treewide: constify the ctl_table argument of proc_handlers 2024-07-25 12:58:36 -07:00
pci Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
pcmcia Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
peci Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
perf RISC-V Patches for the 6.11 Merge Window, Part 2 2024-07-27 10:14:34 -07:00
phy phy-for-6.11 2024-07-24 13:11:28 -07:00
pinctrl of: remove internal arguments from of_property_for_each_u32() 2024-07-25 06:53:47 -05:00
platform Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
pmdomain
pnp
power power supply and reset changes for the 6.11 series 2024-07-23 09:38:27 -07:00
powercap
pps Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
ps3
ptp Networking changes for 6.11. Not much excitement - a handful of large 2024-07-16 19:28:34 -07:00
pwm of: remove internal arguments from of_property_for_each_u32() 2024-07-25 06:53:47 -05:00
rapidio
ras - The AMD memory controllers data fabric version 4.5 supports 2024-07-15 18:20:24 -07:00
regulator regulator: Fixes for v6.11 2024-07-27 12:27:52 -07:00
remoteproc rpmsg updates for v6.11 2024-07-23 13:41:59 -07:00
reset Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
rpmsg Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
rtc rtc: stm32: add new st,stm32mp25-rtc compatible and check RIF configuration 2024-07-10 17:15:33 +02:00
s390 more s390 updates for 6.11 merge window 2024-07-26 10:47:53 -07:00
sbus sbus: add missing MODULE_DESCRIPTION() macros 2024-07-11 15:42:03 +02:00
scsi Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
sh
siox Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
slimbus Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
soc Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
soundwire Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
spi spi: Fixes for v6.11 2024-07-27 12:29:10 -07:00
spmi Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
ssb
staging Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
target
tc
tee Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
thermal thermal: core: Back off when polling thermal zones on errors 2024-07-24 12:40:23 +02:00
thunderbolt Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
tty Devicetree fixes for 6.11, part 1 2024-07-27 12:46:16 -07:00
ufs SCSI misc on 20240718 2024-07-19 10:56:58 -07:00
uio
usb Devicetree fixes for 6.11, part 1 2024-07-27 12:46:16 -07:00
vdpa Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
vfio Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
vhost virtio: features, fixes, cleanups 2024-07-19 11:57:55 -07:00
video - 875fa64577 ("mm/hugetlb_vmemmap: fix race with speculative PFN 2024-07-21 17:15:46 -07:00
virt ARM: 2024-07-20 12:41:03 -07:00
virtio Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
w1
watchdog linux-watchdog 6.11-rc1 tag 2024-07-25 10:18:35 -07:00
xen Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
zorro Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
Kconfig
Makefile