Skip to content

platform/x86: p2sb: Allow p2sb_bar() calls during PCI device probe

Steve Best requested to merge sfbest/centos-stream-9:j30600 into main

JIRA: https://issues.redhat.com/browse/RHEL-30600
CVE: CVE-2024-26650

Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=60153899

Tested: Did sanity boot testing using Intel (intel-eaglestream-emr-01 and
intel-birchstream-gnr-ap-01) systems.

commit 5913320eb0b3ec88158cfcb0fa5e996bf4ef681b
Author: Shin'ichiro Kawasaki shinichiro.kawasaki@wdc.com
Date: Mon Jan 8 15:20:58 2024 +0900

platform/x86: p2sb: Allow p2sb_bar() calls during PCI device probe  

p2sb_bar() unhides P2SB device to get resources from the device. It  
guards the operation by locking pci_rescan_remove_lock so that parallel  
rescans do not find the P2SB device. However, this lock causes deadlock  
when PCI bus rescan is triggered by /sys/bus/pci/rescan. The rescan  
locks pci_rescan_remove_lock and probes PCI devices. When PCI devices  
call p2sb_bar() during probe, it locks pci_rescan_remove_lock again.  
Hence the deadlock.  

To avoid the deadlock, do not lock pci_rescan_remove_lock in p2sb_bar().  
Instead, do the lock at fs_initcall. Introduce p2sb_cache_resources()  
for fs_initcall which gets and caches the P2SB resources. At p2sb_bar(),  
refer the cache and return to the caller.  

Before operating the device at P2SB DEVFN for resource cache, check  
that its device class is PCI_CLASS_MEMORY_OTHER 0x0580 that PCH  
specifications define. This avoids unexpected operation to other devices  
at the same DEVFN.  

Link: https://lore.kernel.org/linux-pci/6xb24fjmptxxn5js2fjrrddjae6twex5bjaftwqsuawuqqqydx@7cl3uik5ef6j/  
Fixes: 9745fb07474f ("platform/x86/intel: Add Primary to Sideband (P2SB) bridge support")  
Cc: stable@vger.kernel.org  
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>  
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>  
Link: https://lore.kernel.org/r/20240108062059.3583028-2-shinichiro.kawasaki@wdc.com  
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>  
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>  
Tested-by Klara Modin <klarasmodin@gmail.com>  
Reviewed-by: Hans de Goede <hdegoede@redhat.com>  
Signed-off-by: Hans de Goede <hdegoede@redhat.com>  

Signed-off-by: Steve Best sbest@redhat.com

Merge request reports