diff options
author | 2018-07-04 02:06:15 +0000 | |
---|---|---|
committer | 2018-07-04 02:06:15 +0000 | |
commit | 0b2508fdcb0236d752a66eacc3a6dd66358db0e7 (patch) | |
tree | 43fe5387ca1d1324721c4322caf54ddc80a1d866 | |
parent | Clean up some extern definitions and includes in hibernate MD code (diff) | |
download | wireguard-openbsd-0b2508fdcb0236d752a66eacc3a6dd66358db0e7.tar.xz wireguard-openbsd-0b2508fdcb0236d752a66eacc3a6dd66358db0e7.zip |
Fix a wrong memcmp in k7/k8 powernow code.
ok brynet
-rw-r--r-- | sys/arch/i386/i386/powernow-k7.c | 10 | ||||
-rw-r--r-- | sys/arch/i386/i386/powernow-k8.c | 12 |
2 files changed, 15 insertions, 7 deletions
diff --git a/sys/arch/i386/i386/powernow-k7.c b/sys/arch/i386/i386/powernow-k7.c index 4263ae573a0..a53d6cf8c26 100644 --- a/sys/arch/i386/i386/powernow-k7.c +++ b/sys/arch/i386/i386/powernow-k7.c @@ -1,4 +1,4 @@ -/* $OpenBSD: powernow-k7.c,v 1.41 2018/03/31 13:45:03 bluhm Exp $ */ +/* $OpenBSD: powernow-k7.c,v 1.42 2018/07/04 02:06:15 mlarkin Exp $ */ /* * Copyright (c) 2004 Martin Végiard. @@ -253,11 +253,13 @@ k7pnow_states(struct k7pnow_cpu_state *cstate, uint32_t cpusig, /* * Look in the 0xe0000 - 0x100000 physical address - * range for the pst tables; 16 byte blocks + * range for the pst tables; 16 byte blocks. End 10 bytes + * before the end of the range to avoid memcmp across a + * page boundary into unmapped memory. */ for (p = (u_int8_t *)ISA_HOLE_VADDR(BIOS_START); - p < (u_int8_t *)ISA_HOLE_VADDR(BIOS_START + BIOS_LEN); p+= - BIOS_STEP) { + p < (u_int8_t *)ISA_HOLE_VADDR(BIOS_START + BIOS_LEN) - 10; + p += BIOS_STEP) { if (memcmp(p, "AMDK7PNOW!", 10) == 0) { psb = (struct psb_s *)p; if (psb->version != PN7_PSB_VERSION) diff --git a/sys/arch/i386/i386/powernow-k8.c b/sys/arch/i386/i386/powernow-k8.c index dcf40d07e4a..17185ced8eb 100644 --- a/sys/arch/i386/i386/powernow-k8.c +++ b/sys/arch/i386/i386/powernow-k8.c @@ -1,4 +1,4 @@ -/* $OpenBSD: powernow-k8.c,v 1.33 2018/03/31 13:45:03 bluhm Exp $ */ +/* $OpenBSD: powernow-k8.c,v 1.34 2018/07/04 02:06:15 mlarkin Exp $ */ /* * Copyright (c) 2004 Martin Végiard. @@ -320,9 +320,15 @@ k8pnow_states(struct k8pnow_cpu_state *cstate, uint32_t cpusig, uint8_t *p; int i; + /* + * Look in the 0xe0000 - 0x100000 physical address + * range for the pst tables; 16 byte blocks. End 10 bytes + * before the end of the range to avoid memcmp across a + * page boundary into unmapped memory. + */ for (p = (u_int8_t *)ISA_HOLE_VADDR(BIOS_START); - p < (u_int8_t *)ISA_HOLE_VADDR(BIOS_START + BIOS_LEN); p += - BIOS_STEP) { + p < (u_int8_t *)ISA_HOLE_VADDR(BIOS_START + BIOS_LEN) - 10; + p += BIOS_STEP) { if (memcmp(p, "AMDK7PNOW!", 10) == 0) { psb = (struct psb_s *)p; if (psb->version != PN8_PSB_VERSION) |