Skip to content
Snippets Groups Projects
Commit 98de392b authored by chengjia4574's avatar chengjia4574 Committed by Yuan Lin
Browse files

msm: arm: krait: Patch for krait array access out of bound


Current array-bound-check does not cover all cases.
An attacker can use this loophole to redirect $PC to attacker-controlled functions.

The fix is to move the existing array-bound-check to a later location to cover all cases.

Bug: 25773204
Change-Id: I947c872bf3c39dfdd13f029b2fbbb81874a8bca6
Signed-off-by: default avatarYuan Lin <yualin@google.com>
parent 0334cdac
Branches
Tags
No related merge requests found
...@@ -207,8 +207,6 @@ static unsigned int get_krait_evtinfo(unsigned int krait_evt_type, ...@@ -207,8 +207,6 @@ static unsigned int get_krait_evtinfo(unsigned int krait_evt_type,
code = (krait_evt_type & 0x00FF0) >> 4; code = (krait_evt_type & 0x00FF0) >> 4;
group = krait_evt_type & 0x0000F; group = krait_evt_type & 0x0000F;
if ((group > 3) || (reg > KRAIT_MAX_L1_REG))
return -EINVAL;
if (prefix != KRAIT_EVT_PREFIX && prefix != KRAIT_VENUMEVT_PREFIX) if (prefix != KRAIT_EVT_PREFIX && prefix != KRAIT_VENUMEVT_PREFIX)
return -EINVAL; return -EINVAL;
...@@ -220,6 +218,9 @@ static unsigned int get_krait_evtinfo(unsigned int krait_evt_type, ...@@ -220,6 +218,9 @@ static unsigned int get_krait_evtinfo(unsigned int krait_evt_type,
reg += VENUM_BASE_OFFSET; reg += VENUM_BASE_OFFSET;
} }
if ((group > 3) || (reg > KRAIT_MAX_L1_REG))
return -EINVAL;
evtinfo->group_setval = 0x80000000 | (code << (group * 8)); evtinfo->group_setval = 0x80000000 | (code << (group * 8));
evtinfo->groupcode = reg; evtinfo->groupcode = reg;
evtinfo->armv7_evt_type = evt_type_base[reg] | group; evtinfo->armv7_evt_type = evt_type_base[reg] | group;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment