All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] hw/net/can: sja1000 fix buff2frame_bas and buff2frame_pel when dlc is out of std CAN 8 bytes
@ 2021-07-29 12:33 Pavel Pisa
  2021-07-29 12:48 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Pisa @ 2021-07-29 12:33 UTC (permalink / raw)
  To: qemu-devel, Paolo Bonzini, Jason Wang, Qiang Ning,
	Philippe Mathieu-Daudé
  Cc: Pavel Pisa, qemu-stable, Vikram Garhwal, Jan Charvat, Jin-Yang

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 | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c
index 42d2f99dfb..34eea684ce 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.20.1



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

* Re: [PATCH v2] hw/net/can: sja1000 fix buff2frame_bas and buff2frame_pel when dlc is out of std CAN 8 bytes
  2021-07-29 12:33 [PATCH v2] hw/net/can: sja1000 fix buff2frame_bas and buff2frame_pel when dlc is out of std CAN 8 bytes Pavel Pisa
@ 2021-07-29 12:48 ` Philippe Mathieu-Daudé
  2021-08-02  4:03   ` Jason Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-07-29 12:48 UTC (permalink / raw)
  To: Pavel Pisa, qemu-devel, Paolo Bonzini, Jason Wang, Qiang Ning
  Cc: qemu-stable, Vikram Garhwal, Jan Charvat, Jin-Yang

"hw/net/can: sja1000 fix buff2frame* when dlc is out of std CAN 8 bytes"

On 7/29/21 2:33 PM, Pavel Pisa wrote:
> 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).

Cc: qemu-stable@nongnu.org

> Reported-by: Qiang Ning <ningqiang1@huawei.com>
> Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>

Reviewed-by: Philippe Mathieu-Daudé <philmd@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 42d2f99dfb..34eea684ce 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];
>      }
> 



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

* Re: [PATCH v2] hw/net/can: sja1000 fix buff2frame_bas and buff2frame_pel when dlc is out of std CAN 8 bytes
  2021-07-29 12:48 ` Philippe Mathieu-Daudé
@ 2021-08-02  4:03   ` Jason Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Wang @ 2021-08-02  4:03 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé,
	Pavel Pisa, qemu-devel, Paolo Bonzini, Qiang Ning
  Cc: qemu-stable, Vikram Garhwal, Jan Charvat, Jin-Yang


在 2021/7/29 下午8:48, Philippe Mathieu-Daudé 写道:
> "hw/net/can: sja1000 fix buff2frame* when dlc is out of std CAN 8 bytes"
>
> On 7/29/21 2:33 PM, Pavel Pisa wrote:
>> 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).
> Cc: qemu-stable@nongnu.org
>
>> Reported-by: Qiang Ning <ningqiang1@huawei.com>
>> Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


Applied.

Thanks


>
>> ---
>>   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 42d2f99dfb..34eea684ce 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];
>>       }
>>



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

end of thread, other threads:[~2021-08-02  4:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29 12:33 [PATCH v2] hw/net/can: sja1000 fix buff2frame_bas and buff2frame_pel when dlc is out of std CAN 8 bytes Pavel Pisa
2021-07-29 12:48 ` Philippe Mathieu-Daudé
2021-08-02  4:03   ` Jason Wang

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.