[PATCH v1] x86: memcmp-avx2-movbe.S and memcmp-evex-movbe.S fix overflow bug.

Siddhesh Poyarekar siddhesh@gotplt.org
Wed Jun 9 07:07:17 GMT 2021


On 6/9/21 12:31 PM, Siddhesh Poyarekar wrote:
> On 6/9/21 12:24 PM, Noah Goldstein wrote:
>> Do we want to support s + maxlen + sizeof(CHAR) overflowing? If not we 
>> can
>> speed up the AVX2/EVEX implementation of strnlen/wcsnlen/memchr/wmemchr.
> 
> We don't want to specify any behaviour that is undefined by the standard 
> so it's perfectly OK for the algorithm to assume that s + (maxlen - 1) * 
> sizeof(CHAR) (off by one in my previous comment, sorry :)) points to a 
> valid address if that makes the function go faster.

s/valid address/valid reference in the object referred to by s/

In fact, like implementations for strlen, it is OK to assume that reads 
beyond the object bounds are also OK as long as they're within the last 
page that s is in.  Likewise for reads before object bounds as long as 
they're within the first page that s is in.

Siddhesh


More information about the Libc-alpha mailing list