In the Linux kernel, the following vulnerability has been resolved:
coresight: cti: Fix hang in ctidisablehw()
ctienablehw() and ctidisablehw() are called from an atomic context so shouldn't use runtime PM because it can result in a sleep when communicating with firmware.
Since commit 3c6656337852 ("Revert "firmware: arm_scmi: Add clock management to the SCMI power domain""), this causes a hang on Juno when running the Perf Coresight tests or running this command:
perf record -e cs_etm//u -- ls
This was also missed until the revert commit because pmruntimeput() was called with the wrong device until commit 692c9a499b28 ("coresight: cti: Correct the parameter for pmruntimeput")
With lock and scheduler debugging enabled the following is output:
coresight ctisys0: ctienablehw -- dev:ctisys0 parent: 20020000.cti BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:1151 inatomic(): 1, irqsdisabled(): 128, nonblock: 0, pid: 330, name: perf-exec preemptcount: 2, expected: 0 RCU nest depth: 0, expected: 0 INFO: lockdep is turned off. irq event stamp: 0 hardirqs last enabled at (0): [<0000000000000000>] 0x0 hardirqs last disabled at (0): [<ffff80000822b394>] copyprocess+0xa0c/0x1948 softirqs last enabled at (0): [<ffff80000822b394>] copyprocess+0xa0c/0x1948 softirqs last disabled at (0): [<0000000000000000>] 0x0 CPU: 3 PID: 330 Comm: perf-exec Not tainted 6.0.0-00053-g042116d99298 #7 Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Sep 13 2022 Call trace: dumpbacktrace+0x134/0x140 showstack+0x20/0x58 dumpstacklvl+0x8c/0xb8 dumpstack+0x18/0x34 _mightresched+0x180/0x228 _mightsleep+0x50/0x88 _pmruntimeresume+0xac/0xb0 ctienable+0x44/0x120 coresightcontrolassocectdev+0xc0/0x150 coresightenablepath+0xb4/0x288 etmeventstart+0x138/0x170 etmeventadd+0x48/0x70 eventschedin.isra.122+0xb4/0x280 mergeschedin+0x1fc/0x3d0 visitgroupsmerge.constprop.137+0x16c/0x4b0 ctxschedin+0x114/0x1f0 perfeventschedin+0x60/0x90 ctxresched+0x68/0xb0 perfeventexec+0x138/0x508 beginnewexec+0x52c/0xd40 loadelfbinary+0x6b8/0x17d0 bprmexecve+0x360/0x7f8 doexecveatcommon.isra.47+0x218/0x238 _arm64sysexecve+0x48/0x60 invokesyscall+0x4c/0x110 el0svccommon.constprop.4+0xfc/0x120 doel0svc+0x34/0xc0 el0svc+0x40/0x98 el0t64synchandler+0x98/0xc0 el0t64_sync+0x170/0x174
Fix the issue by removing the runtime PM calls completely. They are not needed here because it must have already been done when building the path for a trace.
[ Fix build warnings ]
[
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@e33ce54cef5d429430e3b1ae5c8ee4f4103c4fdc",
"target": {
"file": "drivers/hwtracing/coresight/coresight-cti-core.c",
"function": "cti_enable_hw"
},
"id": "CVE-2022-50491-01243019",
"signature_type": "Function",
"digest": {
"function_hash": "258822512516994561033440342376283515255",
"length": 696.0
},
"deprecated": false,
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@4c365a0c21aaf2b8fcc88de8dc298803288f61ac",
"target": {
"file": "drivers/hwtracing/coresight/coresight-cti-core.c"
},
"id": "CVE-2022-50491-0e7dcd99",
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"136082628046774151651751032329227002743",
"4121973922804849949572041217022049940",
"200641738851577350415027807200213457369",
"81038506446212046130913997246305847534",
"169463800294515338379695851197479286403",
"98544524750309906207942827326915445913",
"567047323916597725078213282498788082",
"160562240523768507523077388953422394144",
"41766393851770903092674013848275985824",
"111518799630494447893238269504369409664",
"249734821680347670790674760620454370775",
"319770805428527370637204354429187613909",
"28384441718991952122201345141995780848",
"259825381442701589552202260058280488070",
"171985055361099708570055886606835302248",
"223375355287638071741182522441410057577",
"137807356443644126060524967277676424844",
"203410219813058234433341586029554541151",
"181603935819813443325997189813357209761"
]
},
"deprecated": false,
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@e33ce54cef5d429430e3b1ae5c8ee4f4103c4fdc",
"target": {
"file": "drivers/hwtracing/coresight/coresight-cti-core.c"
},
"id": "CVE-2022-50491-195b2e02",
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"136082628046774151651751032329227002743",
"4121973922804849949572041217022049940",
"200641738851577350415027807200213457369",
"81038506446212046130913997246305847534",
"169463800294515338379695851197479286403",
"98544524750309906207942827326915445913",
"567047323916597725078213282498788082",
"160562240523768507523077388953422394144",
"41766393851770903092674013848275985824",
"111518799630494447893238269504369409664",
"249734821680347670790674760620454370775",
"319770805428527370637204354429187613909",
"90778835845509757448463566248193547190",
"133588114978290120021602527485126125296",
"140718523273827748234722310248237822005",
"54347606774705902048255606855645121801",
"137807356443644126060524967277676424844",
"203410219813058234433341586029554541151",
"181603935819813443325997189813357209761"
]
},
"deprecated": false,
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@4c365a0c21aaf2b8fcc88de8dc298803288f61ac",
"target": {
"file": "drivers/hwtracing/coresight/coresight-cti-core.c",
"function": "cti_enable_hw"
},
"id": "CVE-2022-50491-1defa05f",
"signature_type": "Function",
"digest": {
"function_hash": "93909056586532599197059612307327894959",
"length": 697.0
},
"deprecated": false,
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@4c365a0c21aaf2b8fcc88de8dc298803288f61ac",
"target": {
"file": "drivers/hwtracing/coresight/coresight-cti-core.c",
"function": "cti_disable_hw"
},
"id": "CVE-2022-50491-2101ba0a",
"signature_type": "Function",
"digest": {
"function_hash": "73207494949374488817812426627069416565",
"length": 623.0
},
"deprecated": false,
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@c51cfba50df8b9e16bfe0e6d4f2f252a4a10063d",
"target": {
"file": "drivers/hwtracing/coresight/coresight-cti-core.c",
"function": "cti_disable_hw"
},
"id": "CVE-2022-50491-29a19d93",
"signature_type": "Function",
"digest": {
"function_hash": "73207494949374488817812426627069416565",
"length": 623.0
},
"deprecated": false,
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@c51cfba50df8b9e16bfe0e6d4f2f252a4a10063d",
"target": {
"file": "drivers/hwtracing/coresight/coresight-cti-core.c",
"function": "cti_enable_hw"
},
"id": "CVE-2022-50491-6b07ef6d",
"signature_type": "Function",
"digest": {
"function_hash": "93909056586532599197059612307327894959",
"length": 697.0
},
"deprecated": false,
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6746eae4bbaddcc16b40efb33dab79210828b3ce",
"target": {
"file": "drivers/hwtracing/coresight/coresight-cti-core.c",
"function": "cti_disable_hw"
},
"id": "CVE-2022-50491-8f3cce76",
"signature_type": "Function",
"digest": {
"function_hash": "73207494949374488817812426627069416565",
"length": 623.0
},
"deprecated": false,
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@e33ce54cef5d429430e3b1ae5c8ee4f4103c4fdc",
"target": {
"file": "drivers/hwtracing/coresight/coresight-cti-core.c",
"function": "cti_disable_hw"
},
"id": "CVE-2022-50491-a7339dcc",
"signature_type": "Function",
"digest": {
"function_hash": "264125227783637357475655729410354158328",
"length": 606.0
},
"deprecated": false,
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6746eae4bbaddcc16b40efb33dab79210828b3ce",
"target": {
"file": "drivers/hwtracing/coresight/coresight-cti-core.c",
"function": "cti_enable_hw"
},
"id": "CVE-2022-50491-c65d3e0d",
"signature_type": "Function",
"digest": {
"function_hash": "93909056586532599197059612307327894959",
"length": 697.0
},
"deprecated": false,
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@c51cfba50df8b9e16bfe0e6d4f2f252a4a10063d",
"target": {
"file": "drivers/hwtracing/coresight/coresight-cti-core.c"
},
"id": "CVE-2022-50491-ca8967b5",
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"136082628046774151651751032329227002743",
"4121973922804849949572041217022049940",
"200641738851577350415027807200213457369",
"81038506446212046130913997246305847534",
"169463800294515338379695851197479286403",
"98544524750309906207942827326915445913",
"567047323916597725078213282498788082",
"160562240523768507523077388953422394144",
"41766393851770903092674013848275985824",
"111518799630494447893238269504369409664",
"249734821680347670790674760620454370775",
"319770805428527370637204354429187613909",
"28384441718991952122201345141995780848",
"259825381442701589552202260058280488070",
"171985055361099708570055886606835302248",
"223375355287638071741182522441410057577",
"137807356443644126060524967277676424844",
"203410219813058234433341586029554541151",
"181603935819813443325997189813357209761"
]
},
"deprecated": false,
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6746eae4bbaddcc16b40efb33dab79210828b3ce",
"target": {
"file": "drivers/hwtracing/coresight/coresight-cti-core.c"
},
"id": "CVE-2022-50491-fc4572b7",
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"136082628046774151651751032329227002743",
"4121973922804849949572041217022049940",
"200641738851577350415027807200213457369",
"81038506446212046130913997246305847534",
"169463800294515338379695851197479286403",
"98544524750309906207942827326915445913",
"567047323916597725078213282498788082",
"160562240523768507523077388953422394144",
"41766393851770903092674013848275985824",
"111518799630494447893238269504369409664",
"249734821680347670790674760620454370775",
"319770805428527370637204354429187613909",
"28384441718991952122201345141995780848",
"259825381442701589552202260058280488070",
"171985055361099708570055886606835302248",
"223375355287638071741182522441410057577",
"137807356443644126060524967277676424844",
"203410219813058234433341586029554541151",
"181603935819813443325997189813357209761"
]
},
"deprecated": false,
"signature_version": "v1"
}
]