Re: [Qemu-devel] [PATCH] lsi53c895a: check script ram address value

2018-11-21 Thread P J P
Hello Petr, Paolo, +-- On Tue, 6 Nov 2018, Paolo Bonzini wrote --+ | On 06/11/2018 13:03, Peter Maydell wrote: | > When can this masking have any effect? These functions are | > the read and write ops for lsi_ram_ops, which we register with | > memory_region_init_io(&s->ram_io, OBJECT(s), &l

Re: [Qemu-devel] [PATCH] lsi53c895a: check script ram address value

2018-11-06 Thread li qiang
在 2018/11/6 20:28, Paolo Bonzini 写道: > On 06/11/2018 13:27, li qiang wrote: >> The addr is 0~0x1fff, but when addr is at the near the end ,for example >> 0x1fffe, the add>>2 can be 2047 >> >> and as script_ram is a uint32_t and so s->script_ram[addr >> 2] can read >> out of the script_ram. > How s

Re: [Qemu-devel] [PATCH] lsi53c895a: check script ram address value

2018-11-06 Thread Peter Maydell
On 6 November 2018 at 12:27, li qiang wrote: > The addr is 0~0x1fff, but when addr is at the near the end ,for example > 0x1fffe, the add>>2 can be 2047 > > and as script_ram is a uint32_t and so s->script_ram[addr >> 2] can read > out of the script_ram. But script_ram is declared as uint32_t s

Re: [Qemu-devel] [PATCH] lsi53c895a: check script ram address value

2018-11-06 Thread Peter Maydell
On 6 November 2018 at 12:38, li qiang wrote: > > 在 2018/11/6 20:28, Paolo Bonzini 写道: >> On 06/11/2018 13:27, li qiang wrote: >>> The addr is 0~0x1fff, but when addr is at the near the end ,for example >>> 0x1fffe, the add>>2 can be 2047 >>> >>> and as script_ram is a uint32_t and so s->script_ram

Re: [Qemu-devel] [PATCH] lsi53c895a: check script ram address value

2018-11-06 Thread Paolo Bonzini
On 06/11/2018 13:27, li qiang wrote: > The addr is 0~0x1fff, but when addr is at the near the end ,for example > 0x1fffe, the add>>2 can be 2047 > > and as script_ram is a uint32_t and so s->script_ram[addr >> 2] can read > out of the script_ram. How so? s->script_ram has size 2048, it's okay

Re: [Qemu-devel] [PATCH] lsi53c895a: check script ram address value

2018-11-06 Thread Paolo Bonzini
On 06/11/2018 13:03, Peter Maydell wrote: > When can this masking have any effect? These functions are > the read and write ops for lsi_ram_ops, which we register with > memory_region_init_io(&s->ram_io, OBJECT(s), &lsi_ram_ops, s, > "lsi-ram", 0x2000); > which specifi

Re: [Qemu-devel] [PATCH] lsi53c895a: check script ram address value

2018-11-06 Thread li qiang
在 2018/11/6 20:03, Peter Maydell 写道: > On 6 November 2018 at 11:53, P J P wrote: >> From: Prasad J Pandit >> >> While accessing script ram[2048] via 'lsi_ram_read/write' routines, >> 'addr' could exceed the ram range. Mask high order bits to avoid >> OOB access. >> >> Reported-by: Mark Kanda >>

Re: [Qemu-devel] [PATCH] lsi53c895a: check script ram address value

2018-11-06 Thread Peter Maydell
On 6 November 2018 at 11:53, P J P wrote: > From: Prasad J Pandit > > While accessing script ram[2048] via 'lsi_ram_read/write' routines, > 'addr' could exceed the ram range. Mask high order bits to avoid > OOB access. > > Reported-by: Mark Kanda > Signed-off-by: Prasad J Pandit > --- > hw/scs

[Qemu-devel] [PATCH] lsi53c895a: check script ram address value

2018-11-06 Thread P J P
From: Prasad J Pandit While accessing script ram[2048] via 'lsi_ram_read/write' routines, 'addr' could exceed the ram range. Mask high order bits to avoid OOB access. Reported-by: Mark Kanda Signed-off-by: Prasad J Pandit --- hw/scsi/lsi53c895a.c | 2 ++ 1 file changed, 2 insertions(+) diff