This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH]: Use RAX_LP/RDX_LP on SAVE_PTR in sysdeps/x86_64/strtok.S


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.


Thanks,
Roland


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]