qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] i2c: pm_smbus: check smb_index before block transfer write
@ 2018-12-06  8:48 P J P
  2018-12-06  9:02 ` li qiang
                   ` (5 more replies)
  0 siblings, 6 replies; 21+ messages in thread
From: P J P @ 2018-12-06  8:48 UTC (permalink / raw)
  To: Qemu Developers
  Cc: Michael S . Tsirkin, Paolo Bonzini, Michael Hanselmann,
	Prasad J Pandit

From: Prasad J Pandit <pjp@fedoraproject.org>

While performing block transfer write in smb_ioport_writeb(),
'smb_index' is incremented and used to index smb_data[] array.
Check 'smb_index' value to avoid OOB access.

Reported-by: Michael Hanselmann <public@hansmi.ch>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 hw/i2c/pm_smbus.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c
index 685a2378ed..03062740cc 100644
--- a/hw/i2c/pm_smbus.c
+++ b/hw/i2c/pm_smbus.c
@@ -240,6 +240,9 @@ static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val,
             uint8_t read = s->smb_addr & 0x01;
 
             s->smb_index++;
+            if (s->smb_index >= PM_SMBUS_MAX_MSG_SIZE) {
+                s->smb_index = 0;
+            }
             if (!read && s->smb_index == s->smb_data0) {
                 uint8_t prot = (s->smb_ctl >> 2) & 0x07;
                 uint8_t cmd = s->smb_cmd;
-- 
2.19.2

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

end of thread, other threads:[~2018-12-06 20:16 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-06  8:48 [Qemu-devel] [PATCH] i2c: pm_smbus: check smb_index before block transfer write P J P
2018-12-06  9:02 ` li qiang
2018-12-06 10:14   ` li qiang
2018-12-06 10:16   ` Peter Maydell
2018-12-06 10:34     ` li qiang
2018-12-06 10:46       ` Peter Maydell
2018-12-06 10:59         ` Li Qiang
2018-12-06 11:05           ` Peter Maydell
2018-12-06 11:12             ` Li Qiang
2018-12-06 11:13               ` Peter Maydell
2018-12-06  9:48 ` Igor Mammedov
2018-12-06 10:14   ` Peter Maydell
2018-12-06  9:58 ` Igor Mammedov
2018-12-06 11:08   ` P J P
2018-12-06 11:19     ` Peter Maydell
2018-12-06 11:22       ` Peter Maydell
2018-12-06 12:04         ` P J P
2018-12-06 12:22           ` P J P
2018-12-06 11:33 ` li qiang
2018-12-06 11:35 ` Michael Hanselmann
2018-12-06 20:16 ` Michael Hanselmann

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).