Page MenuHomeFreeBSD

Fix off-by-one error in BERI virtio driver
ClosedPublic

Authored by gonzo on Jan 16 2019, 2:59 AM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 16 2024, 4:17 PM
Unknown Object (File)
Dec 23 2023, 2:57 AM
Unknown Object (File)
Dec 13 2023, 12:20 AM
Unknown Object (File)
Nov 30 2023, 8:49 AM
Unknown Object (File)
Jun 25 2023, 5:58 AM
Unknown Object (File)
Jun 6 2023, 4:26 AM
Unknown Object (File)
Apr 6 2023, 7:55 PM
Unknown Object (File)
Apr 5 2023, 6:46 AM
Subscribers

Details

Summary

The hardcoded ident is exactly 20 bytes long but sprintf adds terminating zero, so there is one byte written out of array bounds.As a fix use strncpy it appends \0 only if space allows and its behavior matches virtio spec:

When VIRTIO_BLK_T_GET_ID is issued, the device identifier, up to 20 bytes, is
written to the buffer. The identifier should be interpreted as an ascii string.
It is terminated with \0, unless it is exactly 20 bytes long.

See PR 202298

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 21977
Build 21213: arc lint + arc unit

Event Timeline

gonzo retitled this revision from Fix off-by-one error in BERI virtio driver The hardcoded ident is exactly 20 bytes long but sprintf adds terminating zero, so there is one byte written out of array bounds. As a fix use strncpy it appends \0 only if space allows and its behavior... to Fix off-by-one error in BERI virtio driver.Jan 16 2019, 3:03 AM
gonzo edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Jan 21 2019, 11:26 AM
This revision was automatically updated to reflect the committed changes.