regulator: gpio: Fix the out-of-bounds access to drvdata::gpiods
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ d6cd33ad71029a3f77ba1686caf55d4dea58d916 · < e4d19e5d71b217940e33f2ef6c6962b7b68c5606| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
regulator: gpio: Fix the out-of-bounds access to drvdata::gpiods
drvdata::gpiods is supposed to hold an array of 'gpio_desc' pointers. But the memory is allocated for only one pointer. This will lead to out-of-bounds access later in the code if 'config::ngpios' is > 1. So fix the code to allocate enough memory to hold 'config::ngpios' of GPIO descriptors.
While at it, also move the check for memory allocation failure to be below the allocation to make it more readable.
From the CVE record · Linux
The Linux kernel GPIO regulator allocates space for only one GPIO descriptor pointer. If the configuration specifies more than one GPIO, later code can access memory out of bounds. The input does not specify an attacker action or whether network access, authentication, or user interaction is required.
Anyone running the Linux kernel should check whether their kernel includes the affected GPIO regulator code; affected versions are not specified.