Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c18ed242 authored by Deeksha Gupta's avatar Deeksha Gupta Committed by Gerrit - the friendly Code Review server
Browse files

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().

Change-Id: I3ead03ec948282a410ddba5b01f82ca31d3d9199
CRs-Fixed: 3042282
parent c299b70f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@
 *
 *
 * This file was automatically generated by 'framesc'
 * Mon Jul 19 14:21:41 2021 from the following file(s):
 * Wed Sep 29 13:23:21 2021 from the following file(s):
 *
 * dot11f.frms
 *
+12 −6
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@
 *
 *
 * This file was automatically generated by 'framesc'
 * Mon Jul 19 14:21:41 2021 from the following file(s):
 * Wed Sep 29 13:23:21 2021 from the following file(s):
 *
 * dot11f.frms
 *
@@ -15186,7 +15186,6 @@ 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"));
@@ -15194,6 +15193,7 @@ static uint32_t unpack_tlv_core(tpAniSirGlobal pCtx,
					FRAMES_DBG_BREAK();
					goto MandatoryCheck;
				}
				framesntohs(pCtx, &len, pBufRemaining, pTlv->fMsb);
				pBufRemaining += 2;
				nBufRemaining -= 2;
			} else {
@@ -15202,9 +15202,14 @@ static uint32_t unpack_tlv_core(tpAniSirGlobal pCtx,
				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"));
@@ -15212,6 +15217,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;
		}