qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: "Zheyu Ma" <zheyuma97@gmail.com>,
	"Cédric Le Goater" <clg@kaod.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Andrew Jeffery" <andrew@codeconstruct.com.au>,
	"Joel Stanley" <joel@jms.id.au>
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH v4] hw/gpio/aspeed: Add reg_table_count to AspeedGPIOClass
Date: Thu, 20 Jun 2024 17:31:56 +0200	[thread overview]
Message-ID: <86fe9f27-6289-4918-a30e-c9577495a21c@linaro.org> (raw)
In-Reply-To: <6a817f44-27fe-432a-8118-bbcec790535f@linaro.org>

On 20/6/24 16:20, Philippe Mathieu-Daudé wrote:
> On 20/6/24 16:02, Zheyu Ma wrote:
>> ASan detected a global-buffer-overflow error in the aspeed_gpio_read()
>> function. This issue occurred when reading beyond the bounds of the
>> reg_table.
>>
>> To enhance the safety and maintainability of the Aspeed GPIO code, 
>> this commit
>> introduces a reg_table_count member to the AspeedGPIOClass structure. 
>> This
>> change ensures that the size of the GPIO register table is explicitly 
>> tracked
>> and initialized, reducing the risk of errors if new register tables are
>> introduced in the future.
>>
>> Reproducer:
>> cat << EOF | qemu-system-aarch64 -display none \
>> -machine accel=qtest, -m 512M -machine ast1030-evb -qtest stdio
>> readq 0x7e780272
>> EOF
>>
>> ASAN log indicating the issue:
>> ==2602930==ERROR: AddressSanitizer: global-buffer-overflow on address 
>> 0x55a5da29e128 at pc 0x55a5d700dc62 bp 0x7fff096c4e90 sp 0x7fff096c4e88
>> READ of size 2 at 0x55a5da29e128 thread T0
>>      #0 0x55a5d700dc61 in aspeed_gpio_read hw/gpio/aspeed_gpio.c:564:14
>>      #1 0x55a5d933f3ab in memory_region_read_accessor 
>> system/memory.c:445:11
>>      #2 0x55a5d92fba40 in access_with_adjusted_size 
>> system/memory.c:573:18
>>      #3 0x55a5d92f842c in memory_region_dispatch_read1 
>> system/memory.c:1426:16
>>      #4 0x55a5d92f7b68 in memory_region_dispatch_read 
>> system/memory.c:1459:9
>>      #5 0x55a5d9376ad1 in flatview_read_continue_step 
>> system/physmem.c:2836:18
>>      #6 0x55a5d9376399 in flatview_read_continue system/physmem.c:2877:19
>>      #7 0x55a5d93775b8 in flatview_read system/physmem.c:2907:12
>>

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2355

>> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
>> ---
>> Changes in v4:
>> - Change the variable name to 'reg_table_count'
>> - Change the 'reg_table_count' type to unsigned
> 
> Thanks,
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> 
>> Changes in v3:
>> - Add the reproducer
>> ---
>>   hw/gpio/aspeed_gpio.c         | 17 +++++++++++++++++
>>   include/hw/gpio/aspeed_gpio.h |  1 +
>>   2 files changed, 18 insertions(+)
> 



  reply	other threads:[~2024-06-20 15:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-20 14:02 [PATCH v4] hw/gpio/aspeed: Add reg_table_count to AspeedGPIOClass Zheyu Ma
2024-06-20 14:20 ` Philippe Mathieu-Daudé
2024-06-20 15:31   ` Philippe Mathieu-Daudé [this message]
2024-06-21  0:16 ` Andrew Jeffery
2024-06-21  5:25 ` Cédric Le Goater

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=86fe9f27-6289-4918-a30e-c9577495a21c@linaro.org \
    --to=philmd@linaro.org \
    --cc=andrew@codeconstruct.com.au \
    --cc=clg@kaod.org \
    --cc=joel@jms.id.au \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=zheyuma97@gmail.com \
    /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).