From: Alexander Graf Date: Wed, 3 Jun 2015 22:52:44 +0000 (+0200) Subject: target-s390x: Only access allocated storage keys X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=9814fed0afa73f5c37f04e02ec17c915a5d59303;p=qemu.git target-s390x: Only access allocated storage keys We allocate ram_size / PAGE_SIZE storage keys, so we need to make sure that we only access that many. Unfortunately the code can overrun this array by one, potentially overwriting unrelated memory. Fix it by limiting storage keys to their scope. Signed-off-by: Alexander Graf Reviewed-by: Aurelien Jarno --- diff --git a/target-s390x/mmu_helper.c b/target-s390x/mmu_helper.c index e8dcd0c18f..815ff42dde 100644 --- a/target-s390x/mmu_helper.c +++ b/target-s390x/mmu_helper.c @@ -358,7 +358,7 @@ int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc, /* Convert real address -> absolute address */ *raddr = mmu_real2abs(env, *raddr); - if (*raddr <= ram_size) { + if (*raddr < ram_size) { sk = &env->storage_keys[*raddr / TARGET_PAGE_SIZE]; if (*flags & PAGE_READ) { *sk |= SK_R;