Skip to content

mempool alignment might cause a memory block allocated twice #15279

@wgy0831

Description

@wgy0831

the alignment in mempool is #define _ALIGN4(n) ((((n)+3)/4)*4), it means the alignment might expand the size of the block. If max_sz is not the power of four such as 36, the size of second level is ((((36/4)+3)/4)*4) = 12. Function block_break breaks the big block into 4 small blocks and append the last 3 blocks into the free_list.The last block might overflow the big block because function block_fits can not avoid this overflow. The last small block and the next big block would contain a same memory.

  1. max_sz = 36, n_max = 3
  2. alloc a small block (size 12)
  3. alloc a big block (size 36)
  4. alloc 3 small block(size 12)

Metadata

Metadata

Assignees

Labels

area: KernelbugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions