virtio_ring: reject a split ring size that is not a power of two again
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest2 patches 2 repliesIn review
- v12 patches 2 repliesSuperseded
Changes in v2 from the cover letter
- Patch 1: log with dev_err() rather than dev_warn(), and say in the message why the length is bad (Francesco)
- Patch 2: commit message updated for the new message text
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | virtio_ring: reject a split ring size that is not a power of two againdrivers/ | +7 | 2 replies | |
| 2/2 | tools/virtio: vringh_test: check that a split ring must be a power of twotools/ | +11 | 0 replies |
Reviews trailers per patch
1 of 2 patches has a Reviewed-by or Acked-by.
| Patch | Francesco Valla | Eugenio Pérez |
|---|---|---|
| 1/2 | R-b T-b | A-b |
| 2/2 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v2 0/2] virtio_ring: reject a split ring size that is not a power of two again
The split ring indexes its rings with num - 1 as a mask, so its size must be a power of two. vring_new_virtqueue() lost that check in v4.6, with commit 2a2d1382fe9d ("virtio: Add improved queue allocation API"), and remoteproc passes it a ring size taken from firmware. A firmware that asks for, e.g. 100 entries gets a ring on which the driver and the device disagree on where the buffers are, so the device can read the wrong ones. The only thing remoteproc checks is that ring size and alignment are not zero. The other caller, mlxbf-tmfifo, uses a hardcoded size of 1024, so it is not affected unless that value is changed.
Patch 1 puts the check back; patch 2 adds a vringh_test case for it.
Tested in userspace with tools/virtio only, not on remoteproc hardware.
Changes in v2:
- Patch 1: log with dev_err() rather than dev_warn(), and say in the message why the length is bad (Francesco)
- Patch 2: commit message updated for the new message text
v1: https://lore.kernel.org/r/[email protected]
Stjepan Poljak (2):
virtio_ring: reject a split ring size that is not a power of two again tools/virtio: vringh_test: check that a split ring must be a power of
two
drivers/virtio/virtio_ring.c | 7 +++++++ tools/virtio/vringh_test.c | 11 +++++++++++ 2 files changed, 18 insertions(+)
base-commit: 1a577f9402c1780cc1e663f48d5dd54c02051b09
Signature · 1 line
2.53.0