Skip to content

Fix out-of-bound access when resizing in receive_spill - #18861

Open
tuxoko wants to merge 1 commit into
openzfs:masterfrom
tuxoko:recv_spill_oob
Open

Fix out-of-bound access when resizing in receive_spill#18861
tuxoko wants to merge 1 commit into
openzfs:masterfrom
tuxoko:recv_spill_oob

Conversation

@tuxoko

@tuxoko tuxoko commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

receive_spill will call dbuf_spill_set_blksz, which in turn calls dbuf_new_size when resizing spill block. However, receive_spill holds a raw buf, which can be compressed and less than db_size. This causes an out-of-bound access when dbuf_new_size tries to copy the data using db_size as length.

To fix this, we just disable the copy when coming from receive_spill, since we will assign a new arc_buf later anyway.

Motivation and Context

Description

How Has This Been Tested?

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Quality assurance (non-breaking change which makes the code more robust against bugs)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist

receive_spill will call dbuf_spill_set_blksz, which in turn calls
dbuf_new_size when resizing spill block. However, receive_spill holds
a raw buf, which can be compressed and less than db_size. This causes
an out-of-bound access when dbuf_new_size tries to copy the data using
db_size as length.

To fix this, we just disable the copy when coming from receive_spill,
since we will assign a new arc_buf later anyway.

Signed-off-by: Chunwei Chen <david.chen@nutanix.com>
@tuxoko

tuxoko commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

found in #18854 (comment)

@amotin

amotin commented Jul 30, 2026

Copy link
Copy Markdown
Member

I have a subtle feeling this is a dirty workaround. IIRC dbuf layer was never really designed to mix raw and uncompressed buffers, and I wonder if the problem can actually be in db->db.db_size assigned some wrong value, that makes this copy to go out of bounds.

@behlendorf behlendorf added the Status: Design Review Needed Architecture or design is under discussion label Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Design Review Needed Architecture or design is under discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants