hwasan: hwasan-use-short-granules=1 does not generate short granules for local variables
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
This is somewhat a placeholder while I debug the issue. Filing a bug for now in case the issue is known already and/or there is a known workaround.
Compiling with these flags on riscv64:
```
-fsanitize=hwaddress
-mllvm -hwasan-instrument-with-calls=1
-mllvm -hwasan-use-short-granules=1
-mllvm -hwasan-all-globals=1
```
I notice that all stack variables get instrumented (via calls to `__hwasan_tag_memory`), however the size passed to `__hwasan_tag_memory` is always aligned up to a multiple of 16bytes. Short granules are working properly for globals.
From browsing the short granule implementation, it seems like it should apply to stack variables. This seems to imply the size of the variable is aligned up before that instrumentation code is reached. Notably, the real (unaligned) sizes of the stack variables are still used in calls to e.g. `memset` to zeroize them.
Contributor guide
Research direction
Reproduce the issue on riscv64 with the listed HWASan and LLVM flags, comparing instrumentation for local variables with globals. Trace why the size passed to __hwasan_tag_memory is aligned for stack variables while memset still uses the unaligned size; done when local variables receive the expected short-granule instrumentation.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100