In the Linux kernel, the following vulnerability has been resolved:
wifi: brcmfmac: Check the count value of channel spec to prevent out-of-bounds reads
This patch fixes slab-out-of-bounds reads in brcmfmac that occur in brcmfconstructchaninfo() and brcmfenablebw402g() when the count value of channel specifications provided by the device is greater than the length of 'list->element[]', decided by the size of the 'list' allocated with kzalloc(). The patch adds checks that make the functions free the buffer and return -EINVAL if that is the case. Note that the negative return is handled by the caller, brcmfsetupwiphybands() or brcmfcfg80211_attach().
Found by a modified version of syzkaller.
BUG: KASAN: slab-out-of-bounds in brcmfsetupwiphybands+0x1238/0x1430 Read of size 4 at addr ffff888115f24600 by task kworker/0:2/1896
CPU: 0 PID: 1896 Comm: kworker/0:2 Tainted: G W O 5.14.0+ #132 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 Workqueue: usbhubwq hubevent Call Trace: dumpstacklvl+0x57/0x7d printaddressdescription.constprop.0.cold+0x93/0x334 kasanreport.cold+0x83/0xdf brcmfsetupwiphybands+0x1238/0x1430 brcmfcfg80211attach+0x2118/0x3fd0 brcmfattach+0x389/0xd40 brcmfusbprobe+0x12de/0x1690 usbprobeinterface+0x25f/0x710 reallyprobe+0x1be/0xa90 _driverprobedevice+0x2ab/0x460 driverprobedevice+0x49/0x120 _deviceattachdriver+0x18a/0x250 busforeachdrv+0x123/0x1a0 _deviceattach+0x207/0x330 busprobedevice+0x1a2/0x260 deviceadd+0xa61/0x1ce0 usbsetconfiguration+0x984/0x1770 usbgenericdriverprobe+0x69/0x90 usbprobedevice+0x9c/0x220 reallyprobe+0x1be/0xa90 _driverprobedevice+0x2ab/0x460 driverprobedevice+0x49/0x120 _deviceattachdriver+0x18a/0x250 busforeachdrv+0x123/0x1a0 _deviceattach+0x207/0x330 busprobedevice+0x1a2/0x260 deviceadd+0xa61/0x1ce0 usbnewdevice.cold+0x463/0xf66 hubevent+0x10d5/0x3330 processonework+0x873/0x13e0 workerthread+0x8b/0xd10 kthread+0x379/0x450 retfromfork+0x1f/0x30
Allocated by task 1896: kasansavestack+0x1b/0x40 _kasankmalloc+0x7c/0x90 kmemcachealloctrace+0x19e/0x330 brcmfsetupwiphybands+0x290/0x1430 brcmfcfg80211attach+0x2118/0x3fd0 brcmfattach+0x389/0xd40 brcmfusbprobe+0x12de/0x1690 usbprobeinterface+0x25f/0x710 reallyprobe+0x1be/0xa90 _driverprobedevice+0x2ab/0x460 driverprobedevice+0x49/0x120 _deviceattachdriver+0x18a/0x250 busforeachdrv+0x123/0x1a0 _deviceattach+0x207/0x330 busprobedevice+0x1a2/0x260 deviceadd+0xa61/0x1ce0 usbsetconfiguration+0x984/0x1770 usbgenericdriverprobe+0x69/0x90 usbprobedevice+0x9c/0x220 reallyprobe+0x1be/0xa90 _driverprobedevice+0x2ab/0x460 driverprobedevice+0x49/0x120 _deviceattachdriver+0x18a/0x250 busforeachdrv+0x123/0x1a0 _deviceattach+0x207/0x330 busprobedevice+0x1a2/0x260 deviceadd+0xa61/0x1ce0 usbnewdevice.cold+0x463/0xf66 hubevent+0x10d5/0x3330 processonework+0x873/0x13e0 workerthread+0x8b/0xd10 kthread+0x379/0x450 retfrom_fork+0x1f/0x30
The buggy address belongs to the object at ffff888115f24000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 1536 bytes inside of 2048-byte region [ffff888115f24000, ffff888115f24800)
Memory state around the buggy address: ffff888115f24500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff888115f24580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff888115f24600: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ^ ffff888115f24680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888115f24700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
---truncated---
[
{
"signature_type": "Function",
"digest": {
"function_hash": "103482352480813207934049304317249016412",
"length": 2716.0
},
"target": {
"file": "drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c",
"function": "brcmf_construct_chaninfo"
},
"signature_version": "v1",
"id": "CVE-2022-49740-0600106b",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@e4991910f15013db72f6ec0db7038ea67a57052e"
},
{
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"323767814122973210053493030089562645788",
"308233960279837044098091007035131673811",
"154006367893933675395526199484516985067",
"140066156438497817865290567714955268829",
"30025376132928251439086130159429353622",
"199147401288771899632134945021967266494",
"252129546822912253430571564282049168981",
"306682981064262052300304107361506717003",
"150767566085000132956047368922660066958",
"55313054598876860658307625958470478946",
"96275905996505674855961887517961209975"
]
},
"target": {
"file": "drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c"
},
"signature_version": "v1",
"id": "CVE-2022-49740-0f707e50",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f06de1bb6d61f0c18b0213bbc6298960037f9d42"
},
{
"signature_type": "Function",
"digest": {
"function_hash": "1018574860591700608678465176935841861",
"length": 1710.0
},
"target": {
"file": "drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c",
"function": "brcmf_enable_bw40_2g"
},
"signature_version": "v1",
"id": "CVE-2022-49740-117f9f55",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f06de1bb6d61f0c18b0213bbc6298960037f9d42"
},
{
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"323767814122973210053493030089562645788",
"308233960279837044098091007035131673811",
"154006367893933675395526199484516985067",
"140066156438497817865290567714955268829",
"30025376132928251439086130159429353622",
"199147401288771899632134945021967266494",
"252129546822912253430571564282049168981",
"306682981064262052300304107361506717003",
"150767566085000132956047368922660066958",
"55313054598876860658307625958470478946",
"96275905996505674855961887517961209975"
]
},
"target": {
"file": "drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c"
},
"signature_version": "v1",
"id": "CVE-2022-49740-169ff355",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@9cf5e99c1ae1a85286a76c9a970202750538394c"
},
{
"signature_type": "Function",
"digest": {
"function_hash": "1018574860591700608678465176935841861",
"length": 1710.0
},
"target": {
"file": "drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c",
"function": "brcmf_enable_bw40_2g"
},
"signature_version": "v1",
"id": "CVE-2022-49740-37c88b93",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b2e412879595821ff1b5545cbed5f108fba7f5b6"
},
{
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"323767814122973210053493030089562645788",
"308233960279837044098091007035131673811",
"154006367893933675395526199484516985067",
"140066156438497817865290567714955268829",
"30025376132928251439086130159429353622",
"199147401288771899632134945021967266494",
"252129546822912253430571564282049168981",
"306682981064262052300304107361506717003",
"150767566085000132956047368922660066958",
"55313054598876860658307625958470478946",
"96275905996505674855961887517961209975"
]
},
"target": {
"file": "drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c"
},
"signature_version": "v1",
"id": "CVE-2022-49740-4eaca732",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b2e412879595821ff1b5545cbed5f108fba7f5b6"
},
{
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"7606687593520412861058562426045652524",
"4666911690314589867339902134076200330",
"70295549398359781657516796859156700682",
"140066156438497817865290567714955268829",
"30025376132928251439086130159429353622",
"199147401288771899632134945021967266494",
"252129546822912253430571564282049168981",
"306682981064262052300304107361506717003",
"150767566085000132956047368922660066958",
"55313054598876860658307625958470478946",
"96275905996505674855961887517961209975"
]
},
"target": {
"file": "drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c"
},
"signature_version": "v1",
"id": "CVE-2022-49740-59a7a756",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@4920ab131b2dbae7464b72bdcac465d070254209"
},
{
"signature_type": "Function",
"digest": {
"function_hash": "281012164520233165167450843122472253439",
"length": 2702.0
},
"target": {
"file": "drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c",
"function": "brcmf_construct_chaninfo"
},
"signature_version": "v1",
"id": "CVE-2022-49740-63a7d228",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@9cf5e99c1ae1a85286a76c9a970202750538394c"
},
{
"signature_type": "Function",
"digest": {
"function_hash": "1018574860591700608678465176935841861",
"length": 1710.0
},
"target": {
"file": "drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c",
"function": "brcmf_enable_bw40_2g"
},
"signature_version": "v1",
"id": "CVE-2022-49740-78df395b",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@4920ab131b2dbae7464b72bdcac465d070254209"
},
{
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"323767814122973210053493030089562645788",
"308233960279837044098091007035131673811",
"154006367893933675395526199484516985067",
"140066156438497817865290567714955268829",
"30025376132928251439086130159429353622",
"199147401288771899632134945021967266494",
"252129546822912253430571564282049168981",
"306682981064262052300304107361506717003",
"150767566085000132956047368922660066958",
"55313054598876860658307625958470478946",
"96275905996505674855961887517961209975"
]
},
"target": {
"file": "drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c"
},
"signature_version": "v1",
"id": "CVE-2022-49740-8f83ca7c",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@e4991910f15013db72f6ec0db7038ea67a57052e"
},
{
"signature_type": "Function",
"digest": {
"function_hash": "103482352480813207934049304317249016412",
"length": 2716.0
},
"target": {
"file": "drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c",
"function": "brcmf_construct_chaninfo"
},
"signature_version": "v1",
"id": "CVE-2022-49740-bb11e5ef",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@4920ab131b2dbae7464b72bdcac465d070254209"
},
{
"signature_type": "Function",
"digest": {
"function_hash": "103482352480813207934049304317249016412",
"length": 2716.0
},
"target": {
"file": "drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c",
"function": "brcmf_construct_chaninfo"
},
"signature_version": "v1",
"id": "CVE-2022-49740-bda1fdfa",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b2e412879595821ff1b5545cbed5f108fba7f5b6"
},
{
"signature_type": "Function",
"digest": {
"function_hash": "1018574860591700608678465176935841861",
"length": 1710.0
},
"target": {
"file": "drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c",
"function": "brcmf_enable_bw40_2g"
},
"signature_version": "v1",
"id": "CVE-2022-49740-c3505c28",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@e4991910f15013db72f6ec0db7038ea67a57052e"
},
{
"signature_type": "Function",
"digest": {
"function_hash": "1018574860591700608678465176935841861",
"length": 1710.0
},
"target": {
"file": "drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c",
"function": "brcmf_enable_bw40_2g"
},
"signature_version": "v1",
"id": "CVE-2022-49740-e4dc38ae",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@9cf5e99c1ae1a85286a76c9a970202750538394c"
},
{
"signature_type": "Function",
"digest": {
"function_hash": "103482352480813207934049304317249016412",
"length": 2716.0
},
"target": {
"file": "drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c",
"function": "brcmf_construct_chaninfo"
},
"signature_version": "v1",
"id": "CVE-2022-49740-fab90111",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f06de1bb6d61f0c18b0213bbc6298960037f9d42"
}
]