]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
brcm80211: potential NULL dereference in brcmf_cfg80211_vndr_cmds_dcmd_handler()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 24 Apr 2019 09:52:18 +0000 (12:52 +0300)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commitde9da8ef850c940f4cbc5e84dda7355538577c2a
treebee8482e03e2f3bf96c8cb3cc9c86dd92b747420
parent138e14a49e4733a6d8a19c99fe41d37f49aaef45
brcm80211: potential NULL dereference in brcmf_cfg80211_vndr_cmds_dcmd_handler()

BugLink: https://bugs.launchpad.net/bugs/1838700
[ Upstream commit e025da3d7aa4770bb1d1b3b0aa7cc4da1744852d ]

If "ret_len" is negative then it could lead to a NULL dereference.

The "ret_len" value comes from nl80211_vendor_cmd(), if it's negative
then we don't allocate the "dcmd_buf" buffer.  Then we pass "ret_len" to
brcmf_fil_cmd_data_set() where it is cast to a very high u32 value.
Most of the functions in that call tree check whether the buffer we pass
is NULL but there are at least a couple places which don't such as
brcmf_dbg_hex_dump() and brcmf_msgbuf_query_dcmd().  We memcpy() to and
from the buffer so it would result in a NULL dereference.

The fix is to change the types so that "ret_len" can't be negative.  (If
we memcpy() zero bytes to NULL, that's a no-op and doesn't cause an
issue).

Fixes: 1bacb0487d0e ("brcmfmac: replace cfg80211 testmode with vendor command")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c