> virtiovf_resume_write() reads migf->buf and migf->buf_header and checks
> filp->f_pos against vhca_buf->start_pos before taking state_mutex and
> migf->lock. Because virtiovf_pci_resume_device_data() opens the file via
> stream_open(), FMODE_ATOMIC_POS is cleared and concurrent writes through
> duplicated file descriptors are not serialized by f_pos_lock. A racing
> writer in VIRTIOVF_LOAD_STATE_PREP_HEADER_DATA can free and reallocate
> migf->buf_header under migf->lock while another writer still holds the
> stale pointer captured before the lock.
> 
> Move the buffer pointer reads and start_pos check under migf->lock after
> checking VIRTIOVF_MIGF_STATE_ERROR.
> 
> Found with an LLM-assisted code review tool and verified by inspection on
> v7.4-rc4 (b6a9fa34ce4). Build-tested only due to lack of virtio VF
> live-migration hardware.
> 
> Fixes: 0bbc82e4ec79 ("vfio/virtio: Add support for the basic live migration 
> functionality")
> Cc: [email protected]
> Signed-off-by: Qican Ma <[email protected]>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to