aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Earnshaw <rearnsha@arm.com>2021-04-28 17:56:38 +0100
committerRichard Earnshaw <rearnsha@arm.com>2021-04-28 17:57:57 +0100
commit59f5d16f2c5db4d9592c8ce6453afe81334bb012 (patch)
tree47b62070c12fbc35ac55ffe999332019798075d5 /gcc
parente1543e694dadf1ea70eb72325219bc0cdc914a35 (diff)
downloadgcc-59f5d16f2c5db4d9592c8ce6453afe81334bb012.zip
gcc-59f5d16f2c5db4d9592c8ce6453afe81334bb012.tar.gz
gcc-59f5d16f2c5db4d9592c8ce6453afe81334bb012.tar.bz2
arm: fix UB due to missing mode check [PR100311]
Some places in the compiler iterate over all the fixed registers to check if that register can be used in a particular mode. The idiom is to iterate over the register and then for that register, if it supports the current mode to check all that register and any additional registers needed (HARD_REGNO_NREGS). If these two checks are not fully aligned then it is possible to generate a buffer overrun when testing data objects that are sized by the number of hard regs in the machine. The VPR register is a case where these checks were not consistent and because this is the last HARD register the result was that we ended up overflowing the fixed_regs array. gcc: PR target/100311 * config/arm/arm.c (arm_hard_regno_mode_ok): Only allow VPR to be used in HImode.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/arm/arm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 6641e3f..0371d98 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -25269,7 +25269,7 @@ arm_hard_regno_mode_ok (unsigned int regno, machine_mode mode)
return false;
if (IS_VPR_REGNUM (regno))
- return true;
+ return mode == HImode;
if (TARGET_THUMB1)
/* For the Thumb we only allow values bigger than SImode in