All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hw/net/can: sja1000 fix buff2frame_bas for dlc out of std CAN 8 bytes
@ 2021-07-26 16:24 Pavel Pisa
  2021-07-29  9:19 ` Pavel Pisa
  0 siblings, 1 reply; 4+ messages in thread
From: Pavel Pisa @ 2021-07-26 16:24 UTC (permalink / raw)
  To: qemu-devel, Paolo Bonzini, Jason Wang
  Cc: Vikram Garhwal, Qiang Ning, Jiri Novak, Oliver Hartkopp,
	Jin-Yang, Ondrej Ille, Jan Charvat, Jan Kiszka, Pavel Pisa

Problem reported by openEuler fuzz-sig group.

The buff2frame_bas function (hw\net\can\can_sja1000.c)
infoleak(qemu5.x~qemu6.x) or stack-overflow(qemu 4.x).

Reported-by: Qiang Ning <ningqiang1@huawei.com>
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
---
 hw/net/can/can_sja1000.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c
index 42d2f99dfb..64e81bff58 100644
--- a/hw/net/can/can_sja1000.c
+++ b/hw/net/can/can_sja1000.c
@@ -311,6 +311,10 @@ static void buff2frame_bas(const uint8_t *buff, qemu_can_frame *frame)
     }
     frame->can_dlc = buff[1] & 0x0f;
 
+    if (frame->can_dlc > 8) {
+        frame->can_dlc = 8;
+    }
+
     for (i = 0; i < frame->can_dlc; i++) {
         frame->data[i] = buff[2 + i];
     }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-29 12:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-26 16:24 [PATCH] hw/net/can: sja1000 fix buff2frame_bas for dlc out of std CAN 8 bytes Pavel Pisa
2021-07-29  9:19 ` Pavel Pisa
2021-07-29 10:03   ` [PATCH-for-6.1] " Philippe Mathieu-Daudé
2021-07-29 11:52     ` Pavel Pisa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.