com php-src: Mark zend_jit_patch memory accesses as unaligned: ext/opcache/jit/zend_jit_x86.dasc

From: Date: Wed, 22 Jul 2020 09:02:24 +0000
Subject: com php-src: Mark zend_jit_patch memory accesses as unaligned: ext/opcache/jit/zend_jit_x86.dasc
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-112310@lists.php.net to get a copy of this message
Commit: aaedbde8b4294bfceea4ef7f76c50692676adb4a Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 22 Jul 2020 11:01:35 +0200 Parents: eb04cb5f2016bf46c667caca088363278c5dfbfc Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=aaedbde8b4294bfceea4ef7f76c50692676adb4a Log: Mark zend_jit_patch memory accesses as unaligned This prevents ubsan from complaining. Changed paths: M ext/opcache/jit/zend_jit_x86.dasc Diff: diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 7b21de9626..2e14192ad5 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -3082,6 +3082,9 @@ mrm: } } +typedef ZEND_SET_ALIGNED(1, uint16_t unaligned_uint16_t); +typedef ZEND_SET_ALIGNED(1, int32_t unaligned_int32_t); + static int zend_jit_patch(const void *code, size_t size, const void *from_addr, const void *to_addr) { int ret = 0; @@ -3089,11 +3092,11 @@ static int zend_jit_patch(const void *code, size_t size, const void *from_addr, uint8_t *end = p + size - 5; while (p < end) { - if ((*(uint16_t*)p & 0xf0ff) == 0x800f && p + *(int32_t*)(p+2) == (uint8_t*)from_addr - 6) { - *(int32_t*)(p+2) = ((uint8_t*)to_addr - (p + 6)); + if ((*(unaligned_uint16_t*)p & 0xf0ff) == 0x800f && p + *(unaligned_int32_t*)(p+2) == (uint8_t*)from_addr - 6) { + *(unaligned_int32_t*)(p+2) = ((uint8_t*)to_addr - (p + 6)); ret++; - } else if (*p == 0xe9 && p + *(int32_t*)(p+1) == (uint8_t*)from_addr - 5) { - *(int32_t*)(p+1) = ((uint8_t*)to_addr - (p + 5)); + } else if (*p == 0xe9 && p + *(unaligned_int32_t*)(p+1) == (uint8_t*)from_addr - 5) { + *(unaligned_int32_t*)(p+1) = ((uint8_t*)to_addr - (p + 5)); ret++; } p += _asm_x86_inslen(p);

« previous php.cvs (#112310) next »