diff options
author | Vinay Gannevaram <quic_vganneva@quicinc.com> | 2021-11-03 12:33:51 +0530 |
---|---|---|
committer | Isaac Chiou <isaacchiou@google.com> | 2022-03-08 02:44:34 +0000 |
commit | 871cba5e5dc659a81796ad031dfda0becf6907d1 (patch) | |
tree | 49062400ed8acc38ca741f7f83846abd717eff40 | |
parent | 0a25482c67e9747de3436fffcc46fca61e5b374e (diff) | |
download | qcacld-871cba5e5dc659a81796ad031dfda0becf6907d1.tar.gz |
qcacld-3.0: Fix possible OOB in unpack_tlv_core
Currently in unpack_tlv_core(), nBufRemaining is validated
after calling framesntohs API. Since, framesntohs() copies
pIn address to pOut address with length = 2 bytes as below.
DOT11F_MEMCPY(pCtx, (uint16_t *)pOut, pIn, 2);
which could cause OOB issue if pIn contains less than 2 bytes.
Fix is to validate the nBufRemaining size before calling
framesntohs().
Bug: 218338071
Change-Id: I3ead03ec948282a410ddba5b01f82ca31d3d9199
CRs-Fixed: 3042282
Signed-off-by: Vinay Gannevaram <quic_vganneva@quicinc.com>
-rw-r--r-- | core/mac/src/include/dot11f.h | 4 | ||||
-rw-r--r-- | core/mac/src/sys/legacy/src/utils/src/dot11f.c | 20 |
2 files changed, 15 insertions, 9 deletions
diff --git a/core/mac/src/include/dot11f.h b/core/mac/src/include/dot11f.h index b430b82983..c8ca474422 100644 --- a/core/mac/src/include/dot11f.h +++ b/core/mac/src/include/dot11f.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2018, 2021 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -35,7 +35,7 @@ * * * This file was automatically generated by 'framesc' - * Tue Sep 18 11:47:29 2018 from the following file(s): + * Wed Nov 3 12:29:44 2021 from the following file(s): * * dot11f.frms * diff --git a/core/mac/src/sys/legacy/src/utils/src/dot11f.c b/core/mac/src/sys/legacy/src/utils/src/dot11f.c index 0ed0385e12..335a80e81f 100644 --- a/core/mac/src/sys/legacy/src/utils/src/dot11f.c +++ b/core/mac/src/sys/legacy/src/utils/src/dot11f.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2018, 2021 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -33,7 +33,7 @@ * * * This file was automatically generated by 'framesc' - * Tue Sep 18 11:47:29 2018 from the following file(s): + * Wed Nov 3 12:29:44 2021 from the following file(s): * * dot11f.frms * @@ -13573,25 +13573,30 @@ static uint32_t unpack_tlv_core(tpAniSirGlobal pCtx, } /* & length, */ if (pTlv->sLen == 2) { - framesntohs(pCtx, &len, pBufRemaining, pTlv->fMsb); if (2 > nBufRemaining) { FRAMES_LOG0(pCtx, FRLOGE, FRFL("This frame reports " "fewer two byte(s) remaining.\n")); status |= DOT11F_INCOMPLETE_TLV; FRAMES_DBG_BREAK(); goto MandatoryCheck; - } - pBufRemaining += 2; - nBufRemaining -= 2; + } + framesntohs(pCtx, &len, pBufRemaining, pTlv->fMsb); + pBufRemaining += 2; + nBufRemaining -= 2; } else { len = *pBufRemaining; pBufRemaining += 1; nBufRemaining -= 1; } } else { + if (TLVs[0].sType > nBufRemaining) { + FRAMES_LOG0(pCtx, FRLOGE, FRFL("This frame reports " + "fewer LVs[0].sType byte(s) remaining.\n")); + status |= DOT11F_INCOMPLETE_TLV; + goto MandatoryCheck; + } pBufRemaining += TLVs[0].sType; nBufRemaining -= TLVs[0].sType; - framesntohs(pCtx, &len, pBufRemaining, (TLVs[0].sType == 2)); if (2 > nBufRemaining) { FRAMES_LOG0(pCtx, FRLOGE, FRFL("This frame reports " "fewer two byte(s) remaining.\n")); @@ -13599,6 +13604,7 @@ static uint32_t unpack_tlv_core(tpAniSirGlobal pCtx, FRAMES_DBG_BREAK(); goto MandatoryCheck; } + framesntohs(pCtx, &len, pBufRemaining, (TLVs[0].sType == 2)); pBufRemaining += 2; nBufRemaining -= 2; } |