Skip to content

mem: reject blocks from other memory partitions - #55

Open
Old-Ding wants to merge 1 commit into
weston-embedded:developfrom
Old-Ding:fix/osmemput-partition-ownership
Open

mem: reject blocks from other memory partitions#55
Old-Ding wants to merge 1 commit into
weston-embedded:developfrom
Old-Ding:fix/osmemput-partition-ownership

Conversation

@Old-Ding

Copy link
Copy Markdown

Summary

  • Reject blocks that are outside the target memory partition or are not aligned to its block size before adding them to the free list.
  • Reuse OS_ERR_MEM_INVALID_P_BLK for invalid ownership and alignment.
  • Keep the existing full-partition check and normal block return path unchanged.

Fixes #52.

Validation

  • Built Source/os_mem.c with GCC 16.1.0 in the 32-bit POSIX/GNU CPU configuration using the official uC/CPU and uC/LIB headers (-fsyntax-only -Wall -Wextra -Werror).
  • Ran a standalone host regression against the modified source with a 64-bit POSIX/GNU CPU configuration:
    • a block obtained from partition A is rejected when returned to partition B, and B's free-list head/count remain unchanged;
    • a non-block-start address from A is rejected;
    • the original block can still be returned to A successfully.
  • git diff --check and git show --check passed.

The repository has no in-tree test framework, so the host regression harness is validation-only and is not included in the change.

Validate that a returned block is aligned to the target partition and falls within its configured block range before linking it into the free list. This prevents a block allocated from one partition from corrupting another partition.
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.

OSMemPut allows cross-partition free leading to free list corruption (Type: robustness enhancement)

1 participant