Repository navigation
Conversation
Check the header at the caller's pointer before applying the AllocAbs alignment fallback. Managed allocators may return an AROS_WORSTALIGN-aligned block even when MEMCHUNK_TOTAL is larger, so rounding first can move a valid lookup into the pre-wall. Return the adjusted size together with the raw address. This keeps AllocAbs displacement in the released range and lets headerless allocations really be freed as-is. Scan live walls on a missing header so a neighbouring overwrite is reported at the same failure point.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
AllocAbsround-down fallback.ULONGprobe when the caller supplies an arbitraryAllocAbsaddress.AllocAbsdisplacement is included in the released range and a headerless block is genuinely freed as-is.MungWall_Check()is an Exec-private helper; changing its size argument to an in/out pointer does not change the public Exec ABI.Why
MungWall_Check()previously rounded every pointer down toMEMCHUNK_TOTALbefore looking for the header. On m68k,AROS_WORSTALIGNis 4 whilesizeof(struct MemChunk)and thereforeMEMCHUNK_TOTALare 8. A managed allocator can return a valid pointer ending in...4; rounding it to an 8-byte boundary moves the lookup four bytes into the pre-wall.This was reproduced on a Pi 3 MungWall boot with a 68-byte
AllocVec()result: the old diagnostic reported the rounded pointer and 72 bytes, while the complete header (includingMUNGWALL_HEADER_ID, the 68-byte allocation size and the correct owner) was four bytes above the address being checked. The rounded address was then handed to TLSF as though wall data were an allocator block.The round-down is still required for
AllocAbs, whose requested address may be inside the block returned by the allocator. It is now used only when the exact lookup does not find a header.The old headerless path also returned the original address but its callers unconditionally added
MUNGWALL_TOTAL_SIZE. Moving size normalization intoMungWall_Check()keeps the address and size decisions paired.Validation
git diff --checkmungwall.c,freemem.candmemory.ccompile with-Werrorusing the generated AROS flags and toolchains for:linux-x86_64(64-bit little-endian)amiga-m68k/68000 (32-bit big-endian)Runtime validation of this revision on m68k hardware, 32-bit little-endian targets and 64-bit big-endian targets has not been performed.