Try to trigger an MTE fault on double/invalid free by touching the first
byte of the allocation with the provided pointer.
Details
- Reviewers
pcc fmayer - Commits
- rG1dd54691b20d: [scudo] Detect double free when running with MTE.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
compiler-rt/lib/scudo/standalone/combined.h | ||
---|---|---|
565 | For zero-sized allocations I'd expect the correct allocation tag to be stored in the first byte of the granule. It may be simpler to say that we skip this for zero-sized allocations because it is not expected to succeed even for valid allocations. |
compiler-rt/lib/scudo/standalone/combined.h | ||
---|---|---|
565 | Not always - ex. zero size, 32 byte aligned allocation in a 32-byte size class will end up with header at offset 16 in the block, payload at offset 32, and no space to store the tag. We could bump the allocated size a little to handle this case, but I don't know if it is worth it. It will also make the deallocation logic more costly. I've benchmarked the current change and could not see any overhead. |
compiler-rt/lib/scudo/standalone/combined.h | ||
---|---|---|
565 | Oh right, I forgot about that case. So can we add this example to the comment? |
compiler-rt/lib/scudo/standalone/combined.h | ||
---|---|---|
568 | nit: afaict llvm uses const char, so I think this should be volatile char for consistency. |
For zero-sized allocations I'd expect the correct allocation tag to be stored in the first byte of the granule. It may be simpler to say that we skip this for zero-sized allocations because it is not expected to succeed even for valid allocations.