At the moment, fwcfg reads the file once at startup and passes these data to the guest. Therefore, we should always read the whole file. Otherwise we should error out. Additionally, GCC12 complains that the comparison whether fwcfg_file->size is lower than 0 is always false due to the limited range of data type.
Details
Details
- Reviewers
emaste jhb markj - Group Reviewers
bhyve - Commits
- rG26d9f973d869: bhyve: error out if fwcfg user file isn't read completely
Diff Detail
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
usr.sbin/bhyve/qemu_fwcfg.c | ||
---|---|---|
602–604 | Why is a partial read of the file not an error? |
usr.sbin/bhyve/qemu_fwcfg.c | ||
---|---|---|
602–604 | to expand the previous question.. should we ensure that all bytes are read or error out? and why not use the same pattern that you used in pci_passthru.c using mmap()? |
usr.sbin/bhyve/qemu_fwcfg.c | ||
---|---|---|
602–604 | You're right. Partial reads don't make sense. What's the advantage of using mmap + memcpy instead of just read? |
usr.sbin/bhyve/qemu_fwcfg.c | ||
---|---|---|
596–597 | I don't think this is correct since a signed type is being returned into an unsigned variable. granted - if there is a read error, the check below will still do the right thing unless the file size happens to be 4G. | |
602–604 |
I'm not aware of an advantage in using one or over the other in this scenario. |