From: Emil Mikulic <emikulic@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Stack smash in hw/eepro100.c
Date: Sat, 6 Sep 2008 01:40:13 +1000 [thread overview]
Message-ID: <20080905154013.GA41045@dmr.ath.cx> (raw)
Hi there,
I've got qemu and kvm crashing when I try to scp data from a VM with
-net nic,model=i82551. I believe the problem is here:
(hw/eepro100.c, SVN r4892)
658 static void eepro100_cu_command(EEPRO100State * s, uint8_t val)
[...]
723 uint8_t buf[MAX_ETH_FRAME_SIZE + 4];
[...]
745 /* Extended TCB. */
746 assert(tcb_bytes == 0);
747 for (; tbd_count < 2; tbd_count++) {
748 uint32_t tx_buffer_address = ldl_phys(tbd_address);
749 uint16_t tx_buffer_size = lduw_phys(tbd_address + 4);
750 uint16_t tx_buffer_el = lduw_phys(tbd_address + 6);
751 tbd_address += 8;
752 logout
753 ("TBD (extended mode): buffer address 0x%08x[...]
754 tx_buffer_address, tx_buffer_size);
755 cpu_physical_memory_read(tx_buffer_address, &buf[size],
756 tx_buffer_size);
^ KABOOM
What happens is:
- tbd_count=0, size=0, tx_buffer_size=130
- tbd_count=1, size=130, tx_buffer_size=1448
130 + 1448 = 1578
sizeof(buf) = 1518
I believe cpu_physical_memory_read() is writing past the end of buf[]
and clobbering the call stack.
I don't know what the right solution is here.
For testing, I made buf[] larger and scp completed without incident
instead of crashing qemu after a few KB. e.g.:
- uint8_t buf[MAX_ETH_FRAME_SIZE + 4];
+ uint8_t buf[MAX_ETH_FRAME_SIZE + 1000];
--Emil
reply other threads:[~2008-09-05 15:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20080905154013.GA41045@dmr.ath.cx \
--to=emikulic@gmail.com \
--cc=qemu-devel@nongnu.org \
/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).