In the Linux kernel, the following vulnerability has been resolved:
usb: isp1760: Fix out-of-bounds array access
Running the driver through kasan gives an interesting splat:
BUG: KASAN: global-out-of-bounds in isp1760register+0x180/0x70c Read of size 20 at addr f1db2e64 by task swapper/0/1 (...) isp1760register from isp1760platprobe+0x1d8/0x220 (...)
This happens because the loop reading the regmap fields for the different ISP1760 variants look like this:
for (i = 0; i < HCFIELDMAX; i++) { ... }
Meaning it expects the arrays to be at least HCFIELDMAX - 1 long.
However the arrays isp1760hcregfields[], isp1763hcregfields[], isp1763hcvolatileranges[] and isp1763dcvolatileranges[] are dynamically sized during compilation.
Fix this by putting an empty assignment to the [HCFIELDMAX] and [DCFIELDMAX] array member at the end of each array. This will make the array one member longer than it needs to be, but avoids the risk of overwriting whatever is inside [HCFIELDMAX - 1] and is simple and intuitive to read. Also add comments explaining what is going on.
{ "vanir_signatures": [ { "signature_type": "Line", "target": { "file": "drivers/usb/isp1760/isp1760-core.c" }, "id": "CVE-2022-49551-0d71e4d6", "digest": { "threshold": 0.9, "line_hashes": [ "255735176414825416473623747472640879826", "184440605500813194508563708911013317414", "304401964947811544346590546875482271992", "79060638761703230406995065011063252860", "336891754829634562248098147260694523730", "316009955397626912751739126242738645566", "244126093069692888676299127120766022584", "165007604765271968592738681647853738570", "87816989412266569662381167602093196263", "150470355187384237860423185994855797921", "49462636665472294404702011825204606397", "312324537227312191583582178374186919815", "326348292616932237541769421236650290016", "215234347249280852549793653837887819846", "273380850073729882166219049939212787174", "4176958621120789921175213908142384996" ] }, "deprecated": false, "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@463bddd3ff1acf4036ddb80c34a715eb99debf46", "signature_version": "v1" }, { "signature_type": "Line", "target": { "file": "drivers/usb/isp1760/isp1760-core.c" }, "id": "CVE-2022-49551-2c654362", "digest": { "threshold": 0.9, "line_hashes": [ "255735176414825416473623747472640879826", "184440605500813194508563708911013317414", "304401964947811544346590546875482271992", "79060638761703230406995065011063252860", "336891754829634562248098147260694523730", "316009955397626912751739126242738645566", "244126093069692888676299127120766022584", "165007604765271968592738681647853738570", "87816989412266569662381167602093196263", "150470355187384237860423185994855797921", "49462636665472294404702011825204606397", "312324537227312191583582178374186919815", "326348292616932237541769421236650290016", "215234347249280852549793653837887819846", "273380850073729882166219049939212787174", "4176958621120789921175213908142384996" ] }, "deprecated": false, "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@26ae2c942b5702f2e43d36b2a4389cfb7d616b6a", "signature_version": "v1" }, { "signature_type": "Line", "target": { "file": "drivers/usb/isp1760/isp1760-core.c" }, "id": "CVE-2022-49551-61c4ec46", "digest": { "threshold": 0.9, "line_hashes": [ "255735176414825416473623747472640879826", "184440605500813194508563708911013317414", "304401964947811544346590546875482271992", "79060638761703230406995065011063252860", "336891754829634562248098147260694523730", "316009955397626912751739126242738645566", "244126093069692888676299127120766022584", "165007604765271968592738681647853738570", "87816989412266569662381167602093196263", "150470355187384237860423185994855797921", "49462636665472294404702011825204606397", "312324537227312191583582178374186919815", "326348292616932237541769421236650290016", "215234347249280852549793653837887819846", "273380850073729882166219049939212787174", "4176958621120789921175213908142384996" ] }, "deprecated": false, "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@bf2558bbdce3ab1d6bcba09f354914e4515d0a2b", "signature_version": "v1" }, { "signature_type": "Line", "target": { "file": "drivers/usb/isp1760/isp1760-core.c" }, "id": "CVE-2022-49551-e45a690b", "digest": { "threshold": 0.9, "line_hashes": [ "255735176414825416473623747472640879826", "184440605500813194508563708911013317414", "304401964947811544346590546875482271992", "79060638761703230406995065011063252860", "336891754829634562248098147260694523730", "316009955397626912751739126242738645566", "244126093069692888676299127120766022584", "165007604765271968592738681647853738570", "87816989412266569662381167602093196263", "150470355187384237860423185994855797921", "49462636665472294404702011825204606397", "312324537227312191583582178374186919815", "326348292616932237541769421236650290016", "215234347249280852549793653837887819846", "273380850073729882166219049939212787174", "4176958621120789921175213908142384996" ] }, "deprecated": false, "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@47d39cb57e8669e507d17d9e0d067d2b3e3a87ae", "signature_version": "v1" } ] }