In the Linux kernel, the following vulnerability has been resolved:
powerpc/pci: Fix getphbnumber() locking
The recent change to getphbnumber() causes a DEBUGATOMICSLEEP warning on some systems:
BUG: sleeping function called from invalid context at kernel/locking/mutex.c:580 inatomic(): 1, irqsdisabled(): 0, nonblock: 0, pid: 1, name: swapper preemptcount: 1, expected: 0 RCU nest depth: 0, expected: 0 1 lock held by swapper/1: #0: c157efb0 (hosespinlock){+.+.}-{2:2}, at: pcibiosalloccontroller+0x64/0x220 Preemption disabled at: [<00000000>] 0x0 CPU: 0 PID: 1 Comm: swapper Not tainted 5.19.0-yocto-standard+ #1 Call Trace: [d101dc90] [c073b264] dumpstacklvl+0x50/0x8c (unreliable) [d101dcb0] [c0093b70] _mightresched+0x258/0x2a8 [d101dcd0] [c0d3e634] _mutexlock+0x6c/0x6ec [d101dd50] [c0a84174] ofaliasgetid+0x50/0xf4 [d101dd80] [c002ec78] pcibiosalloccontroller+0x1b8/0x220 [d101ddd0] [c140c9dc] pmacpciinit+0x198/0x784 [d101de50] [c140852c] discoverphbs+0x30/0x4c [d101de60] [c0007fd4] dooneinitcall+0x94/0x344 [d101ded0] [c1403b40] kernelinitfreeable+0x1a8/0x22c [d101df10] [c00086e0] kernelinit+0x34/0x160 [d101df30] [c001b334] retfromkernel_thread+0x5c/0x64
This is because pcibiosalloccontroller() holds hosespinlock but ofaliasgetid() takes of_mutex which can sleep.
The hosespinlock protects the phbbitmap, and also the hoselist, but it doesn't need to be held while getphb_number() calls the OF routines, because those are only looking up information in the device tree.
So fix it by having getphbnumber() take the hosespinlock itself, only where required, and then dropping the lock before returning. pcibiosalloccontroller() then needs to take the lock again before the listadd() but that's safe, the order of the list is not important.
{
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/50xxx/CVE-2022-50045.json",
"cna_assigner": "Linux"
}"https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2022-50045.json"
[
{
"id": "CVE-2022-50045-0c4f6f1e",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ccb0a42d3f40c436295e0fef57ab613ae5b925a4",
"target": {
"file": "arch/powerpc/kernel/pci-common.c",
"function": "pcibios_alloc_controller"
},
"digest": {
"function_hash": "67792320579894103260033674581890225520",
"length": 520.0
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Function"
},
{
"id": "CVE-2022-50045-0e182cf8",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@8d48562a2729742f767b0fdd994d6b2a56a49c63",
"target": {
"file": "arch/powerpc/kernel/pci-common.c",
"function": "get_phb_number"
},
"digest": {
"function_hash": "162424569072467145296470257380731447275",
"length": 636.0
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Function"
},
{
"id": "CVE-2022-50045-21fa8dfb",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@5db5ce0f1963c6c8275719a80cb65e9c98d32726",
"target": {
"file": "arch/powerpc/kernel/pci-common.c",
"function": "get_phb_number"
},
"digest": {
"function_hash": "162424569072467145296470257380731447275",
"length": 636.0
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Function"
},
{
"id": "CVE-2022-50045-2565e193",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1d9e75c3d8cdf7c96a94cb77450d4ee070279e6a",
"target": {
"file": "arch/powerpc/kernel/pci-common.c",
"function": "get_phb_number"
},
"digest": {
"function_hash": "162424569072467145296470257380731447275",
"length": 636.0
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Function"
},
{
"id": "CVE-2022-50045-30a7fcfd",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@5db5ce0f1963c6c8275719a80cb65e9c98d32726",
"target": {
"file": "arch/powerpc/kernel/pci-common.c",
"function": "pcibios_alloc_controller"
},
"digest": {
"function_hash": "263496690264047003974337561623440882672",
"length": 511.0
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Function"
},
{
"id": "CVE-2022-50045-32955fb8",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a868f771ee41c97a25a04b8c632a7f06689b307b",
"target": {
"file": "arch/powerpc/kernel/pci-common.c",
"function": "get_phb_number"
},
"digest": {
"function_hash": "162424569072467145296470257380731447275",
"length": 636.0
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Function"
},
{
"id": "CVE-2022-50045-3a86cc93",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@5db5ce0f1963c6c8275719a80cb65e9c98d32726",
"target": {
"file": "arch/powerpc/kernel/pci-common.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"260599393278120486941643414685073344437",
"278509155141766513748682555762149764868",
"173673927142000570926387897515537454630",
"295739480479248076199249739357860017974",
"13187884083782321119842551372777245805",
"130195646611922471280984400315959854951",
"201429362350201367538625118697555566003",
"157677282480195784772314639380073549750",
"111674657279454623207090938247296323160",
"293330474242916034314299915362944586297",
"20296834413363465773222086825327270872",
"166154655194745882267783329991822117353",
"89720441476690972182202246322412091235",
"139326754274050974970801313961488399281",
"298855535351001243214630268329371698476",
"47482287320516605200807137502849835997",
"66012544319502800277572777662472998436",
"8108975087590928271660952567558490671"
]
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Line"
},
{
"id": "CVE-2022-50045-3cfe50e3",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@8d48562a2729742f767b0fdd994d6b2a56a49c63",
"target": {
"file": "arch/powerpc/kernel/pci-common.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"335496159705809665466681278462945514137",
"264803478910879471647805251409562079581",
"323097436719903382745683299970596048853",
"295739480479248076199249739357860017974",
"13187884083782321119842551372777245805",
"130195646611922471280984400315959854951",
"201429362350201367538625118697555566003",
"157677282480195784772314639380073549750",
"111674657279454623207090938247296323160",
"293330474242916034314299915362944586297",
"20296834413363465773222086825327270872",
"166154655194745882267783329991822117353",
"89720441476690972182202246322412091235",
"139326754274050974970801313961488399281",
"298855535351001243214630268329371698476",
"47482287320516605200807137502849835997",
"66012544319502800277572777662472998436",
"8108975087590928271660952567558490671"
]
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Line"
},
{
"id": "CVE-2022-50045-403f415b",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a868f771ee41c97a25a04b8c632a7f06689b307b",
"target": {
"file": "arch/powerpc/kernel/pci-common.c",
"function": "pcibios_alloc_controller"
},
"digest": {
"function_hash": "67792320579894103260033674581890225520",
"length": 520.0
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Function"
},
{
"id": "CVE-2022-50045-55d97848",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@90f195c01a2e8d8da6281791617e21109719c981",
"target": {
"file": "arch/powerpc/kernel/pci-common.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"335496159705809665466681278462945514137",
"264803478910879471647805251409562079581",
"323097436719903382745683299970596048853",
"295739480479248076199249739357860017974",
"13187884083782321119842551372777245805",
"130195646611922471280984400315959854951",
"201429362350201367538625118697555566003",
"157677282480195784772314639380073549750",
"111674657279454623207090938247296323160",
"293330474242916034314299915362944586297",
"20296834413363465773222086825327270872",
"166154655194745882267783329991822117353",
"89720441476690972182202246322412091235",
"139326754274050974970801313961488399281",
"298855535351001243214630268329371698476",
"47482287320516605200807137502849835997",
"66012544319502800277572777662472998436",
"8108975087590928271660952567558490671"
]
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Line"
},
{
"id": "CVE-2022-50045-5649a682",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6f75057c21eab12c6ccb7f06f859641a6edfab99",
"target": {
"file": "arch/powerpc/kernel/pci-common.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"260599393278120486941643414685073344437",
"278509155141766513748682555762149764868",
"173673927142000570926387897515537454630",
"295739480479248076199249739357860017974",
"13187884083782321119842551372777245805",
"130195646611922471280984400315959854951",
"201429362350201367538625118697555566003",
"157677282480195784772314639380073549750",
"111674657279454623207090938247296323160",
"293330474242916034314299915362944586297",
"20296834413363465773222086825327270872",
"166154655194745882267783329991822117353",
"89720441476690972182202246322412091235",
"139326754274050974970801313961488399281",
"298855535351001243214630268329371698476",
"47482287320516605200807137502849835997",
"66012544319502800277572777662472998436",
"8108975087590928271660952567558490671"
]
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Line"
},
{
"id": "CVE-2022-50045-5d63b0f8",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ccb0a42d3f40c436295e0fef57ab613ae5b925a4",
"target": {
"file": "arch/powerpc/kernel/pci-common.c",
"function": "get_phb_number"
},
"digest": {
"function_hash": "162424569072467145296470257380731447275",
"length": 636.0
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Function"
},
{
"id": "CVE-2022-50045-71d1a2b8",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@90f195c01a2e8d8da6281791617e21109719c981",
"target": {
"file": "arch/powerpc/kernel/pci-common.c",
"function": "pcibios_alloc_controller"
},
"digest": {
"function_hash": "67792320579894103260033674581890225520",
"length": 520.0
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Function"
},
{
"id": "CVE-2022-50045-7d8182b8",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1d9e75c3d8cdf7c96a94cb77450d4ee070279e6a",
"target": {
"file": "arch/powerpc/kernel/pci-common.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"335496159705809665466681278462945514137",
"264803478910879471647805251409562079581",
"323097436719903382745683299970596048853",
"295739480479248076199249739357860017974",
"13187884083782321119842551372777245805",
"130195646611922471280984400315959854951",
"201429362350201367538625118697555566003",
"157677282480195784772314639380073549750",
"111674657279454623207090938247296323160",
"293330474242916034314299915362944586297",
"20296834413363465773222086825327270872",
"166154655194745882267783329991822117353",
"89720441476690972182202246322412091235",
"139326754274050974970801313961488399281",
"298855535351001243214630268329371698476",
"47482287320516605200807137502849835997",
"66012544319502800277572777662472998436",
"8108975087590928271660952567558490671"
]
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Line"
},
{
"id": "CVE-2022-50045-819c2812",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1d9e75c3d8cdf7c96a94cb77450d4ee070279e6a",
"target": {
"file": "arch/powerpc/kernel/pci-common.c",
"function": "pcibios_alloc_controller"
},
"digest": {
"function_hash": "67792320579894103260033674581890225520",
"length": 520.0
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Function"
},
{
"id": "CVE-2022-50045-87dbd3b1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@90f195c01a2e8d8da6281791617e21109719c981",
"target": {
"file": "arch/powerpc/kernel/pci-common.c",
"function": "get_phb_number"
},
"digest": {
"function_hash": "162424569072467145296470257380731447275",
"length": 636.0
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Function"
},
{
"id": "CVE-2022-50045-8d1980a7",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a868f771ee41c97a25a04b8c632a7f06689b307b",
"target": {
"file": "arch/powerpc/kernel/pci-common.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"335496159705809665466681278462945514137",
"264803478910879471647805251409562079581",
"323097436719903382745683299970596048853",
"295739480479248076199249739357860017974",
"13187884083782321119842551372777245805",
"130195646611922471280984400315959854951",
"201429362350201367538625118697555566003",
"157677282480195784772314639380073549750",
"111674657279454623207090938247296323160",
"293330474242916034314299915362944586297",
"20296834413363465773222086825327270872",
"166154655194745882267783329991822117353",
"89720441476690972182202246322412091235",
"139326754274050974970801313961488399281",
"298855535351001243214630268329371698476",
"47482287320516605200807137502849835997",
"66012544319502800277572777662472998436",
"8108975087590928271660952567558490671"
]
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Line"
},
{
"id": "CVE-2022-50045-b12ed392",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ccb0a42d3f40c436295e0fef57ab613ae5b925a4",
"target": {
"file": "arch/powerpc/kernel/pci-common.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"335496159705809665466681278462945514137",
"264803478910879471647805251409562079581",
"323097436719903382745683299970596048853",
"295739480479248076199249739357860017974",
"13187884083782321119842551372777245805",
"130195646611922471280984400315959854951",
"201429362350201367538625118697555566003",
"157677282480195784772314639380073549750",
"111674657279454623207090938247296323160",
"293330474242916034314299915362944586297",
"20296834413363465773222086825327270872",
"166154655194745882267783329991822117353",
"89720441476690972182202246322412091235",
"139326754274050974970801313961488399281",
"298855535351001243214630268329371698476",
"47482287320516605200807137502849835997",
"66012544319502800277572777662472998436",
"8108975087590928271660952567558490671"
]
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Line"
},
{
"id": "CVE-2022-50045-c74f0f56",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6f75057c21eab12c6ccb7f06f859641a6edfab99",
"target": {
"file": "arch/powerpc/kernel/pci-common.c",
"function": "pcibios_alloc_controller"
},
"digest": {
"function_hash": "263496690264047003974337561623440882672",
"length": 511.0
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Function"
},
{
"id": "CVE-2022-50045-f11c243f",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@8d48562a2729742f767b0fdd994d6b2a56a49c63",
"target": {
"file": "arch/powerpc/kernel/pci-common.c",
"function": "pcibios_alloc_controller"
},
"digest": {
"function_hash": "67792320579894103260033674581890225520",
"length": 520.0
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Function"
},
{
"id": "CVE-2022-50045-f861fa04",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6f75057c21eab12c6ccb7f06f859641a6edfab99",
"target": {
"file": "arch/powerpc/kernel/pci-common.c",
"function": "get_phb_number"
},
"digest": {
"function_hash": "162424569072467145296470257380731447275",
"length": 636.0
},
"signature_version": "v1",
"deprecated": false,
"signature_type": "Function"
}
]