[PATCH]: Use RAX_LP/RDX_LP on SAVE_PTR in sysdeps/x86_64/strtok.S
H.J. Lu
hjl.tools@gmail.com
Thu Jun 14 16:48:00 GMT 2012
On Wed, Jun 13, 2012 at 6:25 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Jun 13, 2012 at 2:26 PM, Roland McGrath <roland@hack.frob.com> wrote:
>> Now I see what actually matters about the test. You don't really need
>> something machine-dependent. You can make sure they're adjacent just by
>> putting them together in a struct, and making it a global variable to
>> ensure the compiler doesn't optimize away the adjacency. Or you could use
>> a more direct paranoia test by putting SAVEPTR into a struct with uintptr_t
>> magic-number fields on either side and ensuring they don't get clobbered.
>>
>> But the way that we usually test for this kind of bug is to mmap a two-page
>> region, mprotect the second page to PROT_NONE, and then use:
>> char **saveptrp = page + page_size - sizeof (*saveptrp)
>>
>> It probably makes sense to use test-string.h to do the setup for you,
>> since we already have it.
>>
>> To be really thorough, you could also do a second variant that puts SAVEPTR
>> at the beginning of a page and checks for the other direction of overrun.
>> But that's probably overkill, and test-string.h's machinery is not handy
>> for that.
>>
>
> Here is a patch to implement those. I also use
> LP_SIZE on save_ptr. OK to install?
>
> Thanks.
>
>
> --
> H.J.
> ---
> [BZ #14229]
> * string/Makefile (tests): Add tst-strtok_r and tst-strtok_r2.
> * string/tst-strtok_r.c: New file.
> * string/tst-strtok_r2.c: Likewise.
> * sysdeps/x86_64/strtok.S: Use LP_SIZE on save_ptr and use
> RAX_LP/RDX_LP on SAVE_PTR.
>
Is this patch OK?
Thanks.
--
H.J.
More information about the Libc-alpha
mailing list