Skip to content

hw/net/can/ctucan: fix Coverity and other issues

Pavel Pisa qemu-devel 1 version Applied

Status from this message: Applied.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v3 Latest4 patches 1 replyApplied

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/4hw/net/can/ctucan: Don't allow guest to write off end of tx_bufferhw/net/can/ctucan_core.c+4 -20 replies
2/4hw/net/can/ctucan: Avoid unused value in ctucan_send_ready_buffers()hw/net/can/ctucan_core.c+3 -120 replies
3/4hw/net/can/ctucan_core: Handle big-endian hostshw/net/can/ctucan_core.h+1 -20 replies
4/4hw/net/can/ctucan_core: Use stl_le_p to write to tx_buffershw/net/can/ctucan_core.c+2 -40 replies

Reviews trailers per patch

3 of 4 patches have a Reviewed-by or Acked-by.

PatchPavel PisaPhilippe Mathieu-Daudé
1/4T-b
2/4A-b T-b
3/4A-b T-b R-b
4/4T-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH for-5.2 v3 0/4] hw/net/can/ctucan: fix Coverity and other issues

Credit for finding and fixes goes to Peter Maydell

This patchset fixes a couple of issues spotted by Coverity:
* incorrect address checks meant the guest could write off the end of the tx_buffer arrays
* we had an unused value in ctucan_send_ready_buffers()
and also some I noticed while reading the code:
* we don't adjust the device's non-portable use of bitfields on bigendian hosts
* we should use stl_le_p() rather than casting uint_t* to uint32_t*

Tested with "make check" only.

Changes v1->v2: don't assert() the can't-happen case in patch 1, to allow for future adjustment of #defines that correspond to h/w synthesis parameters.

Changes v2->v3: minnor corrections of range checking, support for unaligned and partial word writes into Tx buffers. Tested on x86_64 guest on x86_64 host and bige-edian MIPS guest on x86_64 host Pavel Pisa.

Peter Maydell (4):
hw/net/can/ctucan: Don't allow guest to write off end of tx_buffer hw/net/can/ctucan: Avoid unused value in ctucan_send_ready_buffers() hw/net/can/ctucan_core: Handle big-endian hosts hw/net/can/ctucan_core: Use stl_le_p to write to tx_buffers

 hw/net/can/ctucan_core.c | 23 +++++++----------------
 hw/net/can/ctucan_core.h |  3 +--
 2 files changed, 8 insertions(+), 18 deletions(-)
Signature · 1 line
2.20.1