Skip to content

ASAN: Fix over-alignment in the allocator frontend - #3930

Open
wfdewith wants to merge 1 commit into
AFLplusplus:mainfrom
wfdewith:asan-alignment
Open

wfdewith wants to merge 1 commit into
AFLplusplus:mainfrom
wfdewith:asan-alignment

Conversation

@wfdewith

@wfdewith wfdewith commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Description

The alignment round-up used rz + align - (rz % align) which is wrong when rz is already a multiple of align as it ends up as rz + align. On 32-bit targets align may be size_of::<GuestAddr>() == 4, which is smaller than the 8-byte shadow alignment. The over-alignment then leaves data at 4 mod 8.

Use rz + ((align - (rz % align)) % align) so the pointer is only advanced when it is not already aligned.

Checklist

  • I have run ./scripts/precommit.sh and addressed all comments

The alignment round-up used rz + align - (rz % align) which is wrong
when rz is already a multiple of align as it ends up as rz + align.  On
32-bit targets align may be size_of::<GuestAddr>() == 4, which is
smaller than the 8-byte shadow alignment. The over-alignment then leaves
data at 4 mod 8.

Use rz + ((align - (rz % align)) % align) so the pointer is only
advanced when it is not already aligned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant