* [Qemu-devel] [PATCH for 2.8 v3 1/1] cadence_uart: Check baud rate generator and divider values on migration
@ 2016-12-05 18:35 Alistair Francis
2016-12-06 1:56 ` Huawei PSIRT
2016-12-06 9:31 ` Peter Maydell
0 siblings, 2 replies; 4+ messages in thread
From: Alistair Francis @ 2016-12-05 18:35 UTC (permalink / raw)
To: qemu-devel, peter.maydell; +Cc: alistair.francis, alistair23, pjp, psirt
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 <psirt@huawei.com>
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH for 2.8 v3 1/1] cadence_uart: Check baud rate generator and divider values on migration
2016-12-05 18:35 [Qemu-devel] [PATCH for 2.8 v3 1/1] cadence_uart: Check baud rate generator and divider values on migration Alistair Francis
@ 2016-12-06 1:56 ` Huawei PSIRT
2016-12-06 9:31 ` Peter Maydell
1 sibling, 0 replies; 4+ messages in thread
From: Huawei PSIRT @ 2016-12-06 1:56 UTC (permalink / raw)
To: alistair.francis, qemu-devel, peter.maydell
Cc: alistair23, pjp, Jiangxin (hunter, SCC), Huawei PSIRT,
Wanglijun (PSIRT)
Dear Alistair francis,
As the issue is found by Jiangxin from Huawei test team, could you please
change the "Reported-by" to Jiangxin <jiangxin1@huawei.com>, thank you.
And keep Jiangxin <jiangxin1@huawei.com> in the email loop, thank you.
Best regards,
Huawei PSIRT
-----邮件原件-----
发件人: Alistair Francis [mailto:alistair.francis@xilinx.com]
发送时间: 2016年12月6日 2:35
收件人: qemu-devel@nongnu.org; peter.maydell@linaro.org
抄送: alistair.francis@xilinx.com; alistair23@gmail.com;
pjp@fedoraproject.org; psirt@huawei.com
主题: [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 <psirt@huawei.com>
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
---
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH for 2.8 v3 1/1] cadence_uart: Check baud rate generator and divider values on migration
2016-12-05 18:35 [Qemu-devel] [PATCH for 2.8 v3 1/1] cadence_uart: Check baud rate generator and divider values on migration Alistair Francis
2016-12-06 1:56 ` Huawei PSIRT
@ 2016-12-06 9:31 ` Peter Maydell
2016-12-07 17:23 ` Alistair Francis
1 sibling, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2016-12-06 9:31 UTC (permalink / raw)
To: Alistair Francis
Cc: QEMU Developers, Alistair Francis, Prasad J Pandit, Huawei PSIRT
On 5 December 2016 at 18:35, Alistair Francis
<alistair.francis@xilinx.com> wrote:
> 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 <psirt@huawei.com>
> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
> ---
> 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) {
The uart_write() code says BRGR == 1 is valid, but
this code says it isn't. Which is correct?
thanks
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH for 2.8 v3 1/1] cadence_uart: Check baud rate generator and divider values on migration
2016-12-06 9:31 ` Peter Maydell
@ 2016-12-07 17:23 ` Alistair Francis
0 siblings, 0 replies; 4+ messages in thread
From: Alistair Francis @ 2016-12-07 17:23 UTC (permalink / raw)
To: Peter Maydell
Cc: Alistair Francis, QEMU Developers, Prasad J Pandit, Huawei PSIRT
On Tue, Dec 6, 2016 at 1:31 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 5 December 2016 at 18:35, Alistair Francis
> <alistair.francis@xilinx.com> wrote:
>> 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 <psirt@huawei.com>
>> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
>> ---
>> 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) {
>
> The uart_write() code says BRGR == 1 is valid, but
> this code says it isn't. Which is correct?
1 is valid, it is bypass mode, fixing.
Thanks,
Alistair
>
> thanks
> -- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-12-07 17:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-05 18:35 [Qemu-devel] [PATCH for 2.8 v3 1/1] cadence_uart: Check baud rate generator and divider values on migration Alistair Francis
2016-12-06 1:56 ` Huawei PSIRT
2016-12-06 9:31 ` Peter Maydell
2016-12-07 17:23 ` Alistair Francis
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).