cve-2024-57889
Vulnerability from cvelistv5
Published
2025-01-15 13:05
Modified
2025-01-20 06:28
Severity ?
EPSS score ?
Summary
In the Linux kernel, the following vulnerability has been resolved:
pinctrl: mcp23s08: Fix sleeping in atomic context due to regmap locking
If a device uses MCP23xxx IO expander to receive IRQs, the following
bug can happen:
BUG: sleeping function called from invalid context
at kernel/locking/mutex.c:283
in_atomic(): 1, irqs_disabled(): 1, non_block: 0, ...
preempt_count: 1, expected: 0
...
Call Trace:
...
__might_resched+0x104/0x10e
__might_sleep+0x3e/0x62
mutex_lock+0x20/0x4c
regmap_lock_mutex+0x10/0x18
regmap_update_bits_base+0x2c/0x66
mcp23s08_irq_set_type+0x1ae/0x1d6
__irq_set_trigger+0x56/0x172
__setup_irq+0x1e6/0x646
request_threaded_irq+0xb6/0x160
...
We observed the problem while experimenting with a touchscreen driver which
used MCP23017 IO expander (I2C).
The regmap in the pinctrl-mcp23s08 driver uses a mutex for protection from
concurrent accesses, which is the default for regmaps without .fast_io,
.disable_locking, etc.
mcp23s08_irq_set_type() calls regmap_update_bits_base(), and the latter
locks the mutex.
However, __setup_irq() locks desc->lock spinlock before calling these
functions. As a result, the system tries to lock the mutex whole holding
the spinlock.
It seems, the internal regmap locks are not needed in this driver at all.
mcp->lock seems to protect the regmap from concurrent accesses already,
except, probably, in mcp_pinconf_get/set.
mcp23s08_irq_set_type() and mcp23s08_irq_mask/unmask() are called under
chip_bus_lock(), which calls mcp23s08_irq_bus_lock(). The latter takes
mcp->lock and enables regmap caching, so that the potentially slow I2C
accesses are deferred until chip_bus_unlock().
The accesses to the regmap from mcp23s08_probe_one() do not need additional
locking.
In all remaining places where the regmap is accessed, except
mcp_pinconf_get/set(), the driver already takes mcp->lock.
This patch adds locking in mcp_pinconf_get/set() and disables internal
locking in the regmap config. Among other things, it fixes the sleeping
in atomic context described above.
References
Impacted products
Vendor | Product | Version | |||||||
---|---|---|---|---|---|---|---|---|---|
▼ | Linux | Linux |
Version: 8f38910ba4f662222157ce07a0d5becc4328c46a Version: 8f38910ba4f662222157ce07a0d5becc4328c46a Version: 8f38910ba4f662222157ce07a0d5becc4328c46a Version: 8f38910ba4f662222157ce07a0d5becc4328c46a Version: 8f38910ba4f662222157ce07a0d5becc4328c46a Version: 8f38910ba4f662222157ce07a0d5becc4328c46a Version: 8f38910ba4f662222157ce07a0d5becc4328c46a |
||||||
|
{ "containers": { "cna": { "affected": [ { "defaultStatus": "unaffected", "product": "Linux", "programFiles": [ "drivers/pinctrl/pinctrl-mcp23s08.c" ], "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git", "vendor": "Linux", "versions": [ { "lessThan": "788d9e9a41b81893d6bb8faa05f045c975278318", "status": "affected", "version": "8f38910ba4f662222157ce07a0d5becc4328c46a", "versionType": "git" }, { "lessThan": "c55d186376a87b468c9ee30f2195e0f3857f61a0", "status": "affected", "version": "8f38910ba4f662222157ce07a0d5becc4328c46a", "versionType": "git" }, { "lessThan": "9372e160d8211a7e17f2abff8370794f182df785", "status": "affected", "version": "8f38910ba4f662222157ce07a0d5becc4328c46a", "versionType": "git" }, { "lessThan": "0310cbad163a908d09d99c26827859365cd71fcb", "status": "affected", "version": "8f38910ba4f662222157ce07a0d5becc4328c46a", "versionType": "git" }, { "lessThan": "8c6fd5803b988a5e78c9b9e42c70a936d7cfc6ec", "status": "affected", "version": "8f38910ba4f662222157ce07a0d5becc4328c46a", "versionType": "git" }, { "lessThan": "830f838589522404cd7c2f0f540602f25034af61", "status": "affected", "version": "8f38910ba4f662222157ce07a0d5becc4328c46a", "versionType": "git" }, { "lessThan": "a37eecb705f33726f1fb7cd2a67e514a15dfe693", "status": "affected", "version": "8f38910ba4f662222157ce07a0d5becc4328c46a", "versionType": "git" } ] }, { "defaultStatus": "affected", "product": "Linux", "programFiles": [ "drivers/pinctrl/pinctrl-mcp23s08.c" ], "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git", "vendor": "Linux", "versions": [ { "status": "affected", "version": "4.13" }, { "lessThan": "4.13", "status": "unaffected", "version": "0", "versionType": "semver" }, { "lessThanOrEqual": "5.4.*", "status": "unaffected", "version": "5.4.289", "versionType": "semver" }, { "lessThanOrEqual": "5.10.*", "status": "unaffected", "version": "5.10.233", "versionType": "semver" }, { "lessThanOrEqual": "5.15.*", "status": "unaffected", "version": "5.15.176", "versionType": "semver" }, { "lessThanOrEqual": "6.1.*", "status": "unaffected", "version": "6.1.124", "versionType": "semver" }, { "lessThanOrEqual": "6.6.*", "status": "unaffected", "version": "6.6.70", "versionType": "semver" }, { "lessThanOrEqual": "6.12.*", "status": "unaffected", "version": "6.12.9", "versionType": "semver" }, { "lessThanOrEqual": "*", "status": "unaffected", "version": "6.13", "versionType": "original_commit_for_fix" } ] } ], "descriptions": [ { "lang": "en", "value": "In the Linux kernel, the following vulnerability has been resolved:\n\npinctrl: mcp23s08: Fix sleeping in atomic context due to regmap locking\n\nIf a device uses MCP23xxx IO expander to receive IRQs, the following\nbug can happen:\n\n BUG: sleeping function called from invalid context\n at kernel/locking/mutex.c:283\n in_atomic(): 1, irqs_disabled(): 1, non_block: 0, ...\n preempt_count: 1, expected: 0\n ...\n Call Trace:\n ...\n __might_resched+0x104/0x10e\n __might_sleep+0x3e/0x62\n mutex_lock+0x20/0x4c\n regmap_lock_mutex+0x10/0x18\n regmap_update_bits_base+0x2c/0x66\n mcp23s08_irq_set_type+0x1ae/0x1d6\n __irq_set_trigger+0x56/0x172\n __setup_irq+0x1e6/0x646\n request_threaded_irq+0xb6/0x160\n ...\n\nWe observed the problem while experimenting with a touchscreen driver which\nused MCP23017 IO expander (I2C).\n\nThe regmap in the pinctrl-mcp23s08 driver uses a mutex for protection from\nconcurrent accesses, which is the default for regmaps without .fast_io,\n.disable_locking, etc.\n\nmcp23s08_irq_set_type() calls regmap_update_bits_base(), and the latter\nlocks the mutex.\n\nHowever, __setup_irq() locks desc-\u003elock spinlock before calling these\nfunctions. As a result, the system tries to lock the mutex whole holding\nthe spinlock.\n\nIt seems, the internal regmap locks are not needed in this driver at all.\nmcp-\u003elock seems to protect the regmap from concurrent accesses already,\nexcept, probably, in mcp_pinconf_get/set.\n\nmcp23s08_irq_set_type() and mcp23s08_irq_mask/unmask() are called under\nchip_bus_lock(), which calls mcp23s08_irq_bus_lock(). The latter takes\nmcp-\u003elock and enables regmap caching, so that the potentially slow I2C\naccesses are deferred until chip_bus_unlock().\n\nThe accesses to the regmap from mcp23s08_probe_one() do not need additional\nlocking.\n\nIn all remaining places where the regmap is accessed, except\nmcp_pinconf_get/set(), the driver already takes mcp-\u003elock.\n\nThis patch adds locking in mcp_pinconf_get/set() and disables internal\nlocking in the regmap config. Among other things, it fixes the sleeping\nin atomic context described above." } ], "providerMetadata": { "dateUpdated": "2025-01-20T06:28:57.611Z", "orgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "shortName": "Linux" }, "references": [ { "url": "https://git.kernel.org/stable/c/788d9e9a41b81893d6bb8faa05f045c975278318" }, { "url": "https://git.kernel.org/stable/c/c55d186376a87b468c9ee30f2195e0f3857f61a0" }, { "url": "https://git.kernel.org/stable/c/9372e160d8211a7e17f2abff8370794f182df785" }, { "url": "https://git.kernel.org/stable/c/0310cbad163a908d09d99c26827859365cd71fcb" }, { "url": "https://git.kernel.org/stable/c/8c6fd5803b988a5e78c9b9e42c70a936d7cfc6ec" }, { "url": "https://git.kernel.org/stable/c/830f838589522404cd7c2f0f540602f25034af61" }, { "url": "https://git.kernel.org/stable/c/a37eecb705f33726f1fb7cd2a67e514a15dfe693" } ], "title": "pinctrl: mcp23s08: Fix sleeping in atomic context due to regmap locking", "x_generator": { "engine": "bippy-5f407fcff5a0" } } }, "cveMetadata": { "assignerOrgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "assignerShortName": "Linux", "cveId": "CVE-2024-57889", "datePublished": "2025-01-15T13:05:41.769Z", "dateReserved": "2025-01-11T14:45:42.027Z", "dateUpdated": "2025-01-20T06:28:57.611Z", "state": "PUBLISHED" }, "dataType": "CVE_RECORD", "dataVersion": "5.1", "vulnerability-lookup:meta": { "nvd": "{\"cve\":{\"id\":\"CVE-2024-57889\",\"sourceIdentifier\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\",\"published\":\"2025-01-15T13:15:13.347\",\"lastModified\":\"2025-01-15T13:15:13.347\",\"vulnStatus\":\"Received\",\"cveTags\":[],\"descriptions\":[{\"lang\":\"en\",\"value\":\"In the Linux kernel, the following vulnerability has been resolved:\\n\\npinctrl: mcp23s08: Fix sleeping in atomic context due to regmap locking\\n\\nIf a device uses MCP23xxx IO expander to receive IRQs, the following\\nbug can happen:\\n\\n BUG: sleeping function called from invalid context\\n at kernel/locking/mutex.c:283\\n in_atomic(): 1, irqs_disabled(): 1, non_block: 0, ...\\n preempt_count: 1, expected: 0\\n ...\\n Call Trace:\\n ...\\n __might_resched+0x104/0x10e\\n __might_sleep+0x3e/0x62\\n mutex_lock+0x20/0x4c\\n regmap_lock_mutex+0x10/0x18\\n regmap_update_bits_base+0x2c/0x66\\n mcp23s08_irq_set_type+0x1ae/0x1d6\\n __irq_set_trigger+0x56/0x172\\n __setup_irq+0x1e6/0x646\\n request_threaded_irq+0xb6/0x160\\n ...\\n\\nWe observed the problem while experimenting with a touchscreen driver which\\nused MCP23017 IO expander (I2C).\\n\\nThe regmap in the pinctrl-mcp23s08 driver uses a mutex for protection from\\nconcurrent accesses, which is the default for regmaps without .fast_io,\\n.disable_locking, etc.\\n\\nmcp23s08_irq_set_type() calls regmap_update_bits_base(), and the latter\\nlocks the mutex.\\n\\nHowever, __setup_irq() locks desc-\u003elock spinlock before calling these\\nfunctions. As a result, the system tries to lock the mutex whole holding\\nthe spinlock.\\n\\nIt seems, the internal regmap locks are not needed in this driver at all.\\nmcp-\u003elock seems to protect the regmap from concurrent accesses already,\\nexcept, probably, in mcp_pinconf_get/set.\\n\\nmcp23s08_irq_set_type() and mcp23s08_irq_mask/unmask() are called under\\nchip_bus_lock(), which calls mcp23s08_irq_bus_lock(). The latter takes\\nmcp-\u003elock and enables regmap caching, so that the potentially slow I2C\\naccesses are deferred until chip_bus_unlock().\\n\\nThe accesses to the regmap from mcp23s08_probe_one() do not need additional\\nlocking.\\n\\nIn all remaining places where the regmap is accessed, except\\nmcp_pinconf_get/set(), the driver already takes mcp-\u003elock.\\n\\nThis patch adds locking in mcp_pinconf_get/set() and disables internal\\nlocking in the regmap config. Among other things, it fixes the sleeping\\nin atomic context described above.\"},{\"lang\":\"es\",\"value\":\"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: pinctrl: mcp23s08: Se corrige la suspensi\u00f3n en un contexto at\u00f3mico debido al bloqueo de regmap Si un dispositivo usa el expansor de E/S MCP23xxx para recibir IRQ, puede ocurrir el siguiente error: ERROR: funci\u00f3n de suspensi\u00f3n llamada desde un contexto no v\u00e1lido en kernel/locking/mutex.c:283 in_atomic(): 1, irqs_disabled(): 1, non_block: 0, ... preempt_count: 1, expected: 0 ... Seguimiento de llamadas: ... __might_resched+0x104/0x10e __might_sleep+0x3e/0x62 mutex_lock+0x20/0x4c regmap_lock_mutex+0x10/0x18 regmap_update_bits_base+0x2c/0x66 Observamos el problema mientras experiment\u00e1bamos con un controlador de pantalla t\u00e1ctil que usaba el expansor de E/S MCP23017 (I2C). El mapa de reglas en el controlador pinctrl-mcp23s08 usa un mutex para protecci\u00f3n contra accesos concurrentes, que es el valor predeterminado para los mapas de reglas sin .fast_io, .disable_locking, etc. mcp23s08_irq_set_type() llama a regmap_update_bits_base(), y este \u00faltimo bloquea el mutex. Sin embargo, __setup_irq() bloquea el spinlock desc-\u0026gt;lock antes de llamar a estas funciones. Como resultado, el sistema intenta bloquear el mutex que contiene el spinlock. Parece que los bloqueos internos del mapa de reglas no son necesarios en este controlador en absoluto. mcp-\u0026gt;lock parece proteger el mapa de reglas de accesos concurrentes, excepto, probablemente, en mcp_pinconf_get/set. mcp23s08_irq_set_type() y mcp23s08_irq_mask/unmask() se llaman bajo chip_bus_lock(), que llama a mcp23s08_irq_bus_lock(). Este \u00faltimo toma mcp-\u0026gt;lock y habilita el almacenamiento en cach\u00e9 del mapa de reglas, de modo que los accesos I2C potencialmente lentos se posponen hasta chip_bus_unlock(). Los accesos al mapa de reglas desde mcp23s08_probe_one() no necesitan bloqueo adicional. En todos los lugares restantes donde se accede al mapa de reglas, excepto mcp_pinconf_get/set(), el controlador ya toma mcp-\u0026gt;lock. Este parche agrega bloqueo en mcp_pinconf_get/set() y deshabilita el bloqueo interno en la configuraci\u00f3n de regmap. Entre otras cosas, corrige el problema de suspensi\u00f3n en el contexto at\u00f3mico descrito anteriormente.\"}],\"metrics\":{},\"references\":[{\"url\":\"https://git.kernel.org/stable/c/0310cbad163a908d09d99c26827859365cd71fcb\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/788d9e9a41b81893d6bb8faa05f045c975278318\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/830f838589522404cd7c2f0f540602f25034af61\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/8c6fd5803b988a5e78c9b9e42c70a936d7cfc6ec\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/9372e160d8211a7e17f2abff8370794f182df785\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/a37eecb705f33726f1fb7cd2a67e514a15dfe693\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/c55d186376a87b468c9ee30f2195e0f3857f61a0\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"}]}}" } }
Loading…
Loading…
Sightings
Author | Source | Type | Date |
---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
- Confirmed: The vulnerability is confirmed from an analyst perspective.
- Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
- Patched: This vulnerability was successfully patched by the user reporting the sighting.
- Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
- Not confirmed: The user expresses doubt about the veracity of the vulnerability.
- Not patched: This vulnerability was not successfully patched by the user reporting the sighting.