Re: [PATCH] block: m25p80: Fix heap-buffer-overflow in flash_erase function

2024-06-19 Thread Zheyu Ma
Hi Philippe, On Tue, Jun 18, 2024 at 10:34 PM Philippe Mathieu-Daudé wrote: > On 18/6/24 21:11, Zheyu Ma wrote: > > Thanks for your useful advice! > > > > So how about report the issue and return: > > We might report the issue to the user, but there should > be a way the hardware report the issu

Re: [PATCH] block: m25p80: Fix heap-buffer-overflow in flash_erase function

2024-06-18 Thread Philippe Mathieu-Daudé
On 18/6/24 21:11, Zheyu Ma wrote: Thanks for your useful advice! So how about report the issue and return: We might report the issue to the user, but there should be a way the hardware report the issue to the guest software running. Usually signaled as error condition, irq, ... We need to figu

Re: [PATCH] block: m25p80: Fix heap-buffer-overflow in flash_erase function

2024-06-18 Thread Zheyu Ma
Thanks for your useful advice! So how about report the issue and return: diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 8dec134832..2121b43708 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -617,6 +617,12 @@ static void flash_erase(Flash *s, int offset, FlashCMD cmd)

Re: [PATCH] block: m25p80: Fix heap-buffer-overflow in flash_erase function

2024-06-18 Thread Philippe Mathieu-Daudé
Hi Zheyu, On 18/6/24 17:23, Zheyu Ma wrote: This patch fixes a heap-buffer-overflow issue in the flash_erase function of the m25p80 flash memory emulation. The overflow occurs when the combination of offset and length exceeds the allocated memory for the storage. The patch adds a check to ensure

[PATCH] block: m25p80: Fix heap-buffer-overflow in flash_erase function

2024-06-18 Thread Zheyu Ma
This patch fixes a heap-buffer-overflow issue in the flash_erase function of the m25p80 flash memory emulation. The overflow occurs when the combination of offset and length exceeds the allocated memory for the storage. The patch adds a check to ensure that the erase length does not exceed the stor