From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org, peter.maydell@linaro.org
Cc: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"Qiang Ning" <ningqiang1@huawei.com>,
qemu-stable@nongnu.org, "Pavel Pisa" <pisa@cmp.felk.cvut.cz>
Subject: [PULL 2/5] hw/net/can: sja1000 fix buff2frame_bas and buff2frame_pel when dlc is out of std CAN 8 bytes
Date: Mon, 2 Aug 2021 12:33:41 +0800 [thread overview]
Message-ID: <20210802043344.44301-3-jasowang@redhat.com> (raw)
In-Reply-To: <20210802043344.44301-1-jasowang@redhat.com>
From: Pavel Pisa <pisa@cmp.felk.cvut.cz>
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>
Cc: qemu-stable@nongnu.org
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/net/can/can_sja1000.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c
index 42d2f99..34eea68 100644
--- a/hw/net/can/can_sja1000.c
+++ b/hw/net/can/can_sja1000.c
@@ -275,6 +275,10 @@ static void buff2frame_pel(const uint8_t *buff, qemu_can_frame *frame)
}
frame->can_dlc = buff[0] & 0x0f;
+ if (frame->can_dlc > 8) {
+ frame->can_dlc = 8;
+ }
+
if (buff[0] & 0x80) { /* Extended */
frame->can_id |= QEMU_CAN_EFF_FLAG;
frame->can_id |= buff[1] << 21; /* ID.28~ID.21 */
@@ -311,6 +315,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.7.4
next prev parent reply other threads:[~2021-08-02 4:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-02 4:33 [PULL 0/5] Net patches Jason Wang
2021-08-02 4:33 ` [PULL 1/5] hw/net/vmxnet3: Do not abort QEMU if guest specified bad queue numbers Jason Wang
2021-08-02 4:33 ` Jason Wang [this message]
2021-08-02 4:33 ` [PULL 3/5] hw/net: e1000: Correct the initial value of VET register Jason Wang
2021-08-02 4:33 ` [PULL 4/5] hw/net: e1000e: " Jason Wang
2021-08-02 4:33 ` [PULL 5/5] hw/net: e1000e: Don't zero out the VLAN tag in the legacy RX descriptor Jason Wang
2021-08-02 10:40 ` [PULL 0/5] Net patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210802043344.44301-3-jasowang@redhat.com \
--to=jasowang@redhat.com \
--cc=ningqiang1@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=pisa@cmp.felk.cvut.cz \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).