* [Qemu-devel] [PATCH v1] i2c: pm_smbus: check smb_index before block transfer write
@ 2018-12-06 12:18 P J P
2018-12-06 12:58 ` Philippe Mathieu-Daudé
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: P J P @ 2018-12-06 12:18 UTC (permalink / raw)
To: Qemu Developers
Cc: Michael S . Tsirkin, Paolo Bonzini, Michael Hanselmann,
Peter Maydell, Igor Mammedov, 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.
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: 38ad4fae43 i2c: pm_smbus: Add block transfer capability
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(+)
Update v1: add note about issue being introduced after 3.0 release
-> https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg01115.html
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] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v1] i2c: pm_smbus: check smb_index before block transfer write
2018-12-06 12:18 [Qemu-devel] [PATCH v1] i2c: pm_smbus: check smb_index before block transfer write P J P
@ 2018-12-06 12:58 ` Philippe Mathieu-Daudé
2018-12-06 13:58 ` Michael S. Tsirkin
2018-12-06 16:46 ` Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-12-06 12:58 UTC (permalink / raw)
To: P J P, Qemu Developers
Cc: Peter Maydell, Prasad J Pandit, Michael S . Tsirkin,
Michael Hanselmann, Igor Mammedov, Paolo Bonzini
On 12/6/18 1:18 PM, P J P wrote:
> 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.
>
> 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: 38ad4fae43 i2c: pm_smbus: Add block transfer capability
> Reported-by: Michael Hanselmann <public@hansmi.ch>
> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/i2c/pm_smbus.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> Update v1: add note about issue being introduced after 3.0 release
> -> https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg01115.html
>
> 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;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v1] i2c: pm_smbus: check smb_index before block transfer write
2018-12-06 12:18 [Qemu-devel] [PATCH v1] i2c: pm_smbus: check smb_index before block transfer write P J P
2018-12-06 12:58 ` Philippe Mathieu-Daudé
@ 2018-12-06 13:58 ` Michael S. Tsirkin
2018-12-06 16:46 ` Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2018-12-06 13:58 UTC (permalink / raw)
To: P J P
Cc: Qemu Developers, Paolo Bonzini, Michael Hanselmann, Peter Maydell,
Igor Mammedov, Prasad J Pandit
On Thu, Dec 06, 2018 at 05:48:30PM +0530, P J P wrote:
> 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.
>
> 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: 38ad4fae43 i2c: pm_smbus: Add block transfer capability
> Reported-by: Michael Hanselmann <public@hansmi.ch>
> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> hw/i2c/pm_smbus.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> Update v1: add note about issue being introduced after 3.0 release
> -> https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg01115.html
>
> 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;
> + }
when I see patterns like these I always think "what about spectre".
But not a new issue and not the only place, so we can leave this
for another day.
> 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 [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v1] i2c: pm_smbus: check smb_index before block transfer write
2018-12-06 12:18 [Qemu-devel] [PATCH v1] i2c: pm_smbus: check smb_index before block transfer write P J P
2018-12-06 12:58 ` Philippe Mathieu-Daudé
2018-12-06 13:58 ` Michael S. Tsirkin
@ 2018-12-06 16:46 ` Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2018-12-06 16:46 UTC (permalink / raw)
To: P J P
Cc: QEMU Developers, Michael S. Tsirkin, Paolo Bonzini, public,
Igor Mammedov, Prasad J Pandit
On Thu, 6 Dec 2018 at 12:20, P J P <ppandit@redhat.com> wrote:
>
> 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.
>
> 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: 38ad4fae43 i2c: pm_smbus: Add block transfer capability
> 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(+)
>
> Update v1: add note about issue being introduced after 3.0 release
> -> https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg01115.html
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-12-06 16:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-06 12:18 [Qemu-devel] [PATCH v1] i2c: pm_smbus: check smb_index before block transfer write P J P
2018-12-06 12:58 ` Philippe Mathieu-Daudé
2018-12-06 13:58 ` Michael S. Tsirkin
2018-12-06 16:46 ` Peter Maydell
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).