Commit f2609ffd authored by Prasad J Pandit's avatar Prasad J Pandit Committed by Peter Maydell
Browse files

i2c: pm_smbus: check smb_index before block transfer write

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.

Note that this bug is exploitable by a guest to escape
from the virtual machine. However the commit which
introduced the bug was only made after the 3.0 release,
and so it is not present in any released QEMU versions.

Fixes: 38ad4fae

 i2c: pm_smbus: Add block transfer capability
Reported-by: default avatarMichael Hanselmann <>
Signed-off-by: default avatarPrasad J Pandit <>
Reviewed-by: default avatarIgor Mammedov <>
Reviewed-by: default avatarLi Qiang <>
Reviewed-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarPhilippe Mathieu-Daudé <>
Reviewed-by: default avatarMichael S. Tsirkin <>
Signed-off-by: default avatarPeter Maydell <>
parent 80422b00
......@@ -240,6 +240,9 @@ static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val,
uint8_t read = s->smb_addr & 0x01;
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;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment