qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for 2.8 v3 1/1] cadence_uart: Check baud rate ge


From: Huawei PSIRT
Subject: Re: [Qemu-devel] [PATCH for 2.8 v3 1/1] cadence_uart: Check baud rate generator and divider values on migration
Date: Tue, 6 Dec 2016 09:56:14 +0800

Dear Alistair francis,

As the issue is found by Jiangxin from Huawei test team, could you please
change the "Reported-by" to Jiangxin <address@hidden>, thank you.
And keep Jiangxin <address@hidden> in the email loop, thank you.

Best regards,
Huawei PSIRT

-----邮件原件-----
发件人: Alistair Francis [mailto:address@hidden 
发送时间: 2016年12月6日 2:35
收件人: address@hidden; address@hidden
抄送: address@hidden; address@hidden;
address@hidden; address@hidden
主题: [PATCH for 2.8 v3 1/1] cadence_uart: Check baud rate generator and
divider values on migration

The Cadence UART device emulator calculates speed by dividing the baud rate
by a 'baud rate generator' & 'baud rate divider' value.
The device specification defines these register values to be non-zero and
within certain limits. Checks were recently added when writing to these
registers but not when restoring from migration.

This patch adds checks when restoring from migration to avoid divide by zero
errors.

Reported-by: Huawei PSIRT <address@hidden>
Signed-off-by: Alistair Francis <address@hidden>
---
It would be nice to squeeze this into 2.8 if possible.

V3:
 - Fix broken migration logic
 - Manually double checked and it passes migration.
V2:
 - Abort the migration if the data is invalid

 hw/char/cadence_uart.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index 0215d65..
ce9063b 100644
--- a/hw/char/cadence_uart.c
+++ b/hw/char/cadence_uart.c
@@ -502,6 +502,13 @@ static int cadence_uart_post_load(void *opaque, int
version_id)  {
     CadenceUARTState *s = opaque;
 
+    /* Ensure these two aren't invalid numbers */
+    if (s->r[R_BRGR] <= 1 || s->r[R_BRGR] & ~0xFFFF ||
+        s->r[R_BDIV] <= 3 || s->r[R_BDIV] & ~0xFF) {
+        /* Value is invalid, abort */
+        return 1;
+    }
+
     uart_parameters_setup(s);
     uart_update_status(s);
     return 0;
--
2.7.4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]