Skip to content

FIX: Issues found while fuzz testing library#2

Merged
sigdevel merged 3 commits intomasterfrom
dev
Mar 4, 2026
Merged

FIX: Issues found while fuzz testing library#2
sigdevel merged 3 commits intomasterfrom
dev

Conversation

@Daniil-KOT
Copy link
Copy Markdown
Collaborator

There are several more issues found by fuzz testing lwext4:

  1. FPE in ext4_block_set_lb_size()
  2. Out-of-Bounds Write in ext4_bmap_bit_set()
  3. Double-Free in ext4_bcache_drop_buf()

Daniil Dulov added 3 commits March 4, 2026 18:37
Maximum block size is considered to be 64 KiB, standard block size is 4 KiB,
minimum block size is 1 KiB, however the value of block size is not checked
while mounting images which can lead to the division by zero in
ext4_block_set_lb_size(). The issue is caused due to ext4_mount() passes an
invalid logical block size (size == 0) to ext4_block_set_lb_size() without
checking its value.

To fix the issue check if logical block size value is between 1 KiB
and 64 KiB.
There are multiple out-of-bounds write issues while setting up the bitmap
of the ext4 block (ext4_block data field). These issues are caused due to
ext4 block bitmap has the size of block_size when image is mounted, however
block groups number or the number of inodes per group may have the value
greater than block_size. Then these values are used as boundaries while
setting block bitmap bits, however these values are not checked to be less
than block_size.

To fix the issue check these values before setting block bitmap bits.
There is a possible double-free issue in ext4_bcache_drop_buf() which may
occur while iterating over directory entries (e.g. ext4_dir_entry_next())
and when block cache is full, in this case ext4_bcache_drop_buf() is called.

The issue itself is caused due to any referenced buffer is not actually
removed from lru RB-tree, however it is still freed. Buffers are being
dropped in ext4_block_cache_shake() until one of two conditions is met:

1. lru RB-tree is empty

2. block cache count is greater than the number of referenced blocks

Both conditions are impossible in the observed case since referenced buffers
are not removed and ref count is not decremented. Thus, the first iteration
frees the buffer without removing it from lru RB-tree, the second iteration
picks the exact same buffer by calling ext4_buf_lowest_lru() which is then
attempted to be freed for the second time.

To fix the issue try to remove buffer from lru RB-tree even if it is still
referenced.
@sigdevel
Copy link
Copy Markdown
Collaborator

sigdevel commented Mar 4, 2026

Approved

@sigdevel sigdevel merged commit def9e1b into master Mar 4, 2026
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.

2 participants