summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeeksha Gupta <deegupta@codeaurora.org>2021-09-29 13:38:44 +0530
committerDeeksha Gupta <deegupta@codeaurora.org>2021-10-05 14:48:06 +0530
commita00610418b37ca256ace4e6394f56588e3121638 (patch)
treeb2a400d8ebd4e2d0360024f11781d06d8565858b
parent686def1e072d577c573182e43e50391ed1830cb5 (diff)
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
-rw-r--r--core/mac/src/include/dot11f.h4
-rw-r--r--core/mac/src/sys/legacy/src/utils/src/dot11f.c20
2 files changed, 15 insertions, 9 deletions
diff --git a/core/mac/src/include/dot11f.h b/core/mac/src/include/dot11f.h
index 8c16f417604e..1a603f547d7f 100644
--- a/core/mac/src/include/dot11f.h
+++ b/core/mac/src/include/dot11f.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2019, 2021 The Linux Foundation. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@@ -26,7 +26,7 @@
*
*
* This file was automatically generated by 'framesc'
- * Mon Mar 25 14:48:07 2019 from the following file(s):
+ * Wed Sep 29 13:23:21 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 391d1b8801eb..8325550d3460 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-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2019, 2021 The Linux Foundation. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@@ -24,7 +24,7 @@
*
*
* This file was automatically generated by 'framesc'
- * Mon Mar 25 14:48:07 2019 from the following file(s):
+ * Wed Sep 29 13:23:21 2021 from the following file(s):
*
* dot11f.frms
*
@@ -13659,25 +13659,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"));
@@ -13685,6 +13690,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;
}