Since commit d037970c, in multi-vCPU instances root filesystem initialization can complete before PCI bus discovery; this means that any filesystem mount points specified in the manifest options can be already processed by the time a virtio-9p device is probed and a corresponding volume is added; this in turn means that the volume_add() function called by v9p_dev_attach() can trigger a direct call to v9p_fs_init().
The v9p_fs_init() function uses the general field of the virtio_9p struct, which in the current code is initialized after calling the volume_add() function; this causes v9p_fs_init() to access an uninitialized pointer, leading to an unhandled page fault. The same issue applies to the backed field of the struct.
This change fixes the above issue by moving the initialization of the struct fields before the call to volume_add(). In addition, the unused dev field is being removed, and setting the DRIVER_OK flag in the device status field is being moved before the call to volume_add() (according to the virtio specs, a driver must not send any buffer available notifications to the device before setting DRIVER_OK).
Since commit d037970c, in multi-vCPU instances root filesystem initialization can complete before PCI bus discovery; this means that any filesystem mount points specified in the manifest options can be already processed by the time a virtio-9p device is probed and a corresponding volume is added; this in turn means that the
volume_add()
function called byv9p_dev_attach()
can trigger a direct call tov9p_fs_init()
. Thev9p_fs_init()
function uses thegeneral
field of thevirtio_9p
struct, which in the current code is initialized after calling thevolume_add()
function; this causesv9p_fs_init()
to access an uninitialized pointer, leading to an unhandled page fault. The same issue applies to thebacked
field of the struct. This change fixes the above issue by moving the initialization of the struct fields before the call tovolume_add()
. In addition, the unuseddev
field is being removed, and setting the DRIVER_OK flag in the device status field is being moved before the call tovolume_add()
(according to the virtio specs, a driver must not send any buffer available notifications to the device before setting DRIVER_OK).