[Bug target/94158] Expanded strlen causes out-of-bounds read on AMD64 target

2020-03-12 Thread par...@cyber-itl.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94158 --- Comment #7 from Parker Thompson --- (In reply to Jakub Jelinek from comment #6) > GCC assumes pointers returned by malloc are at least MALLOC_ABI_ALIGNMENT > bytes aligned. That is because: > "The pointer returned if the allocation succeeds

[Bug target/94158] Expanded strlen causes out-of-bounds read on AMD64 target

2020-03-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94158 --- Comment #6 from Jakub Jelinek --- GCC assumes pointers returned by malloc are at least MALLOC_ABI_ALIGNMENT bytes aligned. That is because: "The pointer returned if the allocation succeeds is suitably aligned so that it may be assigned to a

[Bug target/94158] Expanded strlen causes out-of-bounds read on AMD64 target

2020-03-12 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94158 --- Comment #5 from Andrew Pinski --- (In reply to Andrew Pinski from comment #4) > (In reply to Parker Thompson from comment #3) > > As for alloc alignment, glibc strdup() does not use aligned_alloc, just > > malloc. Which by my read of the spe

[Bug target/94158] Expanded strlen causes out-of-bounds read on AMD64 target

2020-03-12 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94158 Andrew Pinski changed: What|Removed |Added Status|WAITING |RESOLVED Resolution|---

[Bug target/94158] Expanded strlen causes out-of-bounds read on AMD64 target

2020-03-12 Thread par...@cyber-itl.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94158 --- Comment #3 from Parker Thompson --- (In reply to Andrew Pinski from comment #2) > Also aligned_alloc normally does not allow alignment of 1. > > So GCC is doing the correct thing. The replacement of strdup here is just to illustrate the iss

[Bug target/94158] Expanded strlen causes out-of-bounds read on AMD64 target

2020-03-12 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94158 Andrew Pinski changed: What|Removed |Added Status|UNCONFIRMED |WAITING Ever confirmed|0

[Bug target/94158] Expanded strlen causes out-of-bounds read on AMD64 target

2020-03-12 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94158 --- Comment #1 from Andrew Pinski --- A pointer returned from strdup has to be valid to be able pass to free. Your testcase makes that invalid.