Re: [Qemu-devel] [PATCH] sd: Fix out-of-bounds assertions

2019-04-11 Thread Markus Armbruster
Daniel P. Berrangé writes: > On Thu, Apr 11, 2019 at 02:20:27PM +0200, Markus Armbruster wrote: >> Daniel P. Berrangé writes: >> >> > On Tue, Apr 09, 2019 at 11:37:44AM +0200, Philippe Mathieu-Daudé wrote: >> [...] >> >> I remember this post from Daniel where he suggests sticking to GLib >> >>

Re: [Qemu-devel] [PATCH] sd: Fix out-of-bounds assertions

2019-04-11 Thread Daniel P . Berrangé
On Thu, Apr 11, 2019 at 02:20:27PM +0200, Markus Armbruster wrote: > Daniel P. Berrangé writes: > > > On Tue, Apr 09, 2019 at 11:37:44AM +0200, Philippe Mathieu-Daudé wrote: > [...] > >> I remember this post from Daniel where he suggests sticking to GLib > >> G_N_ELEMENTS() (which looks similar t

Re: [Qemu-devel] [PATCH] sd: Fix out-of-bounds assertions

2019-04-11 Thread Markus Armbruster
Daniel P. Berrangé writes: > On Tue, Apr 09, 2019 at 11:37:44AM +0200, Philippe Mathieu-Daudé wrote: [...] >> I remember this post from Daniel where he suggests sticking to GLib >> G_N_ELEMENTS() (which looks similar to your suggestion): >> https://lists.gnu.org/archive/html/qemu-devel/2018-11/ms

Re: [Qemu-devel] [PATCH] sd: Fix out-of-bounds assertions

2019-04-11 Thread Daniel P . Berrangé
On Tue, Apr 09, 2019 at 11:37:44AM +0200, Philippe Mathieu-Daudé wrote: > On 4/9/19 10:59 AM, Aleksandar Markovic wrote: > >> > >> Lidong Chen writes: > >> > >>> Due to an off-by-one error, the assert statements allow an > >>> out-of-bounds array access. > >>> > >>> Signed-off-by: Lidong Chen > >

Re: [Qemu-devel] [PATCH] sd: Fix out-of-bounds assertions

2019-04-10 Thread Lidong Chen
Hi, Thank you all for the reviews and comments! Since the fixes in sd.c have gone through the review, I can fix the issue in util/main-loop.c (mentioned in the reviews of Peter and Liam) in a separate patch. Thanks, Lidong On 4/9/2019 3:39 AM, Liam Merwick wrote: On 09/04/2019 06:51, Marku

Re: [Qemu-devel] [PATCH] sd: Fix out-of-bounds assertions

2019-04-09 Thread Liam Merwick
On 09/04/2019 06:51, Markus Armbruster wrote: Lidong Chen writes: Due to an off-by-one error, the assert statements allow an out-of-bounds array access. Signed-off-by: Lidong Chen Reviewed-by: Liam Merwick --- hw/sd/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) di

Re: [Qemu-devel] [PATCH] sd: Fix out-of-bounds assertions

2019-04-09 Thread Peter Maydell
On Tue, 9 Apr 2019 at 06:51, Markus Armbruster wrote: > $ git-grep '<= ARRAY_SIZE' Almost all of these are OK because they're the pattern of checking a loop upper bound before doing a loop. > hw/intc/arm_gicv3_cpuif.c:assert(aprmax <= ARRAY_SIZE(cs->ich_apr[0])); > hw/intc/arm_gicv3_cpuif.c:

Re: [Qemu-devel] [PATCH] sd: Fix out-of-bounds assertions

2019-04-09 Thread Aleksandar Markovic
Markus wrote: > This is the second fix for this bug pattern in a fortnight. Where's > one, there are more: > > $ git-grep '<= ARRAY_SIZE' > hw/intc/arm_gicv3_cpuif.c:assert(aprmax <= ARRAY_SIZE(cs->ich_apr[0])); > hw/intc/arm_gicv3_cpuif.c:assert(aprmax <= ARRAY_SIZE(cs->ich_apr[0])); >

Re: [Qemu-devel] [PATCH] sd: Fix out-of-bounds assertions

2019-04-09 Thread Philippe Mathieu-Daudé
> Thank you for bringing this to our attention, Markus. And thanks to Lidong > too. > > Aleksandar > > P. S. Shouldn't perhaps our macro ARRAY_SIZE() be renamed to > NUMBER_OF_ELEMENTS()? I remember this post from Daniel where he suggests sticking to GLib G_N_ELEMENT

Re: [Qemu-devel] [PATCH] sd: Fix out-of-bounds assertions

2019-04-09 Thread Aleksandar Markovic
t; util/module.c:assert(n_dirs <= ARRAY_SIZE(dirs)); > > Lidong Chen, would you like to have a look at these? > > Cc'ing maintainers to help with further investigation. > Thank you for bringing this to our attention, Markus. And thanks to Lidong too. Aleksandar P. S. Shou

Re: [Qemu-devel] [PATCH] sd: Fix out-of-bounds assertions

2019-04-08 Thread Markus Armbruster
Lidong Chen writes: > Due to an off-by-one error, the assert statements allow an > out-of-bounds array access. > > Signed-off-by: Lidong Chen > --- > hw/sd/sd.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/hw/sd/sd.c b/hw/sd/sd.c > index aaab15f..818f86c 100644 >

Re: [Qemu-devel] [PATCH] sd: Fix out-of-bounds assertions

2019-04-08 Thread Li Qiang
Lidong Chen 于2019年4月9日周二 上午3:51写道: > Due to an off-by-one error, the assert statements allow an > out-of-bounds array access. > > Signed-off-by: Lidong Chen > Reviewed-by: Li Qiang > --- > hw/sd/sd.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/hw/sd/sd.c b/h

Re: [Qemu-devel] [PATCH] sd: Fix out-of-bounds assertions

2019-04-08 Thread Lidong Chen
Hi Philippe, On 4/8/2019 2:27 PM, Philippe Mathieu-Daudé wrote: Hi Lidong On 4/8/19 9:04 PM, Lidong Chen wrote: Due to an off-by-one error, the assert statements allow an out-of-bounds array access. ... which can't happen. Thus harmless for 4.0. I suppose this is a static analysis warning an

Re: [Qemu-devel] [PATCH] sd: Fix out-of-bounds assertions

2019-04-08 Thread Philippe Mathieu-Daudé
Hi Lidong On 4/8/19 9:04 PM, Lidong Chen wrote: > Due to an off-by-one error, the assert statements allow an > out-of-bounds array access. ... which can't happen. Thus harmless for 4.0. I suppose this is a static analysis warning and you didn't triggered it while tracing. Thanks for cleaning th

Re: [Qemu-devel] [PATCH] sd: Fix out-of-bounds assertions

2019-04-08 Thread Marc-André Lureau
On Mon, Apr 8, 2019 at 9:51 PM Lidong Chen wrote: > > Due to an off-by-one error, the assert statements allow an > out-of-bounds array access. > > Signed-off-by: Lidong Chen Reviewed-by: Marc-André Lureau > --- > hw/sd/sd.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff

[Qemu-devel] [PATCH] sd: Fix out-of-bounds assertions

2019-04-08 Thread Lidong Chen
Due to an off-by-one error, the assert statements allow an out-of-bounds array access. Signed-off-by: Lidong Chen --- hw/sd/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index aaab15f..818f86c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -144