* [PATCH 1/1] mdadm/ddf: Abort when raid disk is smaller in getinfo_super_ddf
@ 2023-10-11 13:03 Xiao Ni
2023-10-11 13:25 ` Xiao Ni
0 siblings, 1 reply; 4+ messages in thread
From: Xiao Ni @ 2023-10-11 13:03 UTC (permalink / raw)
To: jes; +Cc: mariusz.tkaczyk, linux-raid
The metadata is corrupted when the raid_disk<0. So abort directly.
This also can avoid a building error:
super-ddf.c:1988:58: error: array subscript -1 is below array bounds of ‘struct phys_disk_entry[0]’
Suggested-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Ackedy-by: Xiao Ni <xni@redhat.com>
---
super-ddf.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/super-ddf.c b/super-ddf.c
index 7213284e0a59..7b98333ecd51 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -1984,12 +1984,14 @@ static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info, char *m
info->disk.number = be32_to_cpu(ddf->dlist->disk.refnum);
info->disk.raid_disk = find_phys(ddf, ddf->dlist->disk.refnum);
+ if (info->disk.raid_disk < 0)
+ return;
+
info->data_offset = be64_to_cpu(ddf->phys->
entries[info->disk.raid_disk].
config_size);
info->component_size = ddf->dlist->size - info->data_offset;
- if (info->disk.raid_disk >= 0)
- pde = ddf->phys->entries + info->disk.raid_disk;
+ pde = ddf->phys->entries + info->disk.raid_disk;
if (pde &&
!(be16_to_cpu(pde->state) & DDF_Failed) &&
!(be16_to_cpu(pde->state) & DDF_Missing))
--
2.32.0 (Apple Git-132)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] mdadm/ddf: Abort when raid disk is smaller in getinfo_super_ddf
2023-10-11 13:03 [PATCH 1/1] mdadm/ddf: Abort when raid disk is smaller in getinfo_super_ddf Xiao Ni
@ 2023-10-11 13:25 ` Xiao Ni
2023-10-13 8:48 ` Mariusz Tkaczyk
0 siblings, 1 reply; 4+ messages in thread
From: Xiao Ni @ 2023-10-11 13:25 UTC (permalink / raw)
To: jes; +Cc: mariusz.tkaczyk, linux-raid
Sorry, the title should be [PATCH 1/1] mdadm/ddf: Abort when raid disk
is smaller than 0 in getinfo_super_ddf
If you want me to send v2, I can do it.
Best Regards
Xiao
On Wed, Oct 11, 2023 at 9:06 PM Xiao Ni <xni@redhat.com> wrote:
>
> The metadata is corrupted when the raid_disk<0. So abort directly.
> This also can avoid a building error:
> super-ddf.c:1988:58: error: array subscript -1 is below array bounds of ‘struct phys_disk_entry[0]’
>
> Suggested-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
> Ackedy-by: Xiao Ni <xni@redhat.com>
> ---
> super-ddf.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/super-ddf.c b/super-ddf.c
> index 7213284e0a59..7b98333ecd51 100644
> --- a/super-ddf.c
> +++ b/super-ddf.c
> @@ -1984,12 +1984,14 @@ static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info, char *m
> info->disk.number = be32_to_cpu(ddf->dlist->disk.refnum);
> info->disk.raid_disk = find_phys(ddf, ddf->dlist->disk.refnum);
>
> + if (info->disk.raid_disk < 0)
> + return;
> +
> info->data_offset = be64_to_cpu(ddf->phys->
> entries[info->disk.raid_disk].
> config_size);
> info->component_size = ddf->dlist->size - info->data_offset;
> - if (info->disk.raid_disk >= 0)
> - pde = ddf->phys->entries + info->disk.raid_disk;
> + pde = ddf->phys->entries + info->disk.raid_disk;
> if (pde &&
> !(be16_to_cpu(pde->state) & DDF_Failed) &&
> !(be16_to_cpu(pde->state) & DDF_Missing))
> --
> 2.32.0 (Apple Git-132)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] mdadm/ddf: Abort when raid disk is smaller in getinfo_super_ddf
2023-10-11 13:25 ` Xiao Ni
@ 2023-10-13 8:48 ` Mariusz Tkaczyk
2023-10-26 21:47 ` Jes Sorensen
0 siblings, 1 reply; 4+ messages in thread
From: Mariusz Tkaczyk @ 2023-10-13 8:48 UTC (permalink / raw)
To: Xiao Ni; +Cc: jes, linux-raid
On Wed, 11 Oct 2023 21:25:37 +0800
Xiao Ni <xni@redhat.com> wrote:
> Sorry, the title should be [PATCH 1/1] mdadm/ddf: Abort when raid disk
> is smaller than 0 in getinfo_super_ddf
>
> If you want me to send v2, I can do it.
>
> Best Regards
> Xiao
>
>
> On Wed, Oct 11, 2023 at 9:06 PM Xiao Ni <xni@redhat.com> wrote:
> >
> > The metadata is corrupted when the raid_disk<0. So abort directly.
> > This also can avoid a building error:
> > super-ddf.c:1988:58: error: array subscript -1 is below array bounds of
> > ‘struct phys_disk_entry[0]’
> >
> > Suggested-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
> > Ackedy-by: Xiao Ni <xni@redhat.com>
> > ---
> > super-ddf.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/super-ddf.c b/super-ddf.c
> > index 7213284e0a59..7b98333ecd51 100644
> > --- a/super-ddf.c
> > +++ b/super-ddf.c
> > @@ -1984,12 +1984,14 @@ static void getinfo_super_ddf(struct supertype *st,
> > struct mdinfo *info, char *m info->disk.number =
> > be32_to_cpu(ddf->dlist->disk.refnum); info->disk.raid_disk = find_phys(ddf,
> > ddf->dlist->disk.refnum);
> >
> > + if (info->disk.raid_disk < 0)
> > + return;
> > +
> > info->data_offset = be64_to_cpu(ddf->phys->
> > entries[info->disk.raid_disk].
> > config_size);
> > info->component_size = ddf->dlist->size - info->data_offset;
> > - if (info->disk.raid_disk >= 0)
> > - pde = ddf->phys->entries + info->disk.raid_disk;
> > + pde = ddf->phys->entries + info->disk.raid_disk;
> > if (pde &&
> > !(be16_to_cpu(pde->state) & DDF_Failed) &&
> > !(be16_to_cpu(pde->state) & DDF_Missing))
> > --
> > 2.32.0 (Apple Git-132)
> >
>
Hi Xiao,
I don't see a need to send v2. Moving to awaiting upstream:
Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Thanks,
Mariusz
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] mdadm/ddf: Abort when raid disk is smaller in getinfo_super_ddf
2023-10-13 8:48 ` Mariusz Tkaczyk
@ 2023-10-26 21:47 ` Jes Sorensen
0 siblings, 0 replies; 4+ messages in thread
From: Jes Sorensen @ 2023-10-26 21:47 UTC (permalink / raw)
To: Mariusz Tkaczyk, Xiao Ni; +Cc: linux-raid
On 10/13/23 04:48, Mariusz Tkaczyk wrote:
> On Wed, 11 Oct 2023 21:25:37 +0800
> Xiao Ni <xni@redhat.com> wrote:
>
>> Sorry, the title should be [PATCH 1/1] mdadm/ddf: Abort when raid disk
>> is smaller than 0 in getinfo_super_ddf
>>
>> If you want me to send v2, I can do it.
>>
>> Best Regards
>> Xiao
>>
>>
>> On Wed, Oct 11, 2023 at 9:06 PM Xiao Ni <xni@redhat.com> wrote:
>>>
>>> The metadata is corrupted when the raid_disk<0. So abort directly.
>>> This also can avoid a building error:
>>> super-ddf.c:1988:58: error: array subscript -1 is below array bounds of
>>> ‘struct phys_disk_entry[0]’
>>>
>>> Suggested-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
>>> Ackedy-by: Xiao Ni <xni@redhat.com>
>>> ---
>>> super-ddf.c | 6 ++++--
>>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/super-ddf.c b/super-ddf.c
>>> index 7213284e0a59..7b98333ecd51 100644
>>> --- a/super-ddf.c
>>> +++ b/super-ddf.c
>>> @@ -1984,12 +1984,14 @@ static void getinfo_super_ddf(struct supertype *st,
>>> struct mdinfo *info, char *m info->disk.number =
>>> be32_to_cpu(ddf->dlist->disk.refnum); info->disk.raid_disk = find_phys(ddf,
>>> ddf->dlist->disk.refnum);
>>>
>>> + if (info->disk.raid_disk < 0)
>>> + return;
>>> +
>>> info->data_offset = be64_to_cpu(ddf->phys->
>>> entries[info->disk.raid_disk].
>>> config_size);
>>> info->component_size = ddf->dlist->size - info->data_offset;
>>> - if (info->disk.raid_disk >= 0)
>>> - pde = ddf->phys->entries + info->disk.raid_disk;
>>> + pde = ddf->phys->entries + info->disk.raid_disk;
>>> if (pde &&
>>> !(be16_to_cpu(pde->state) & DDF_Failed) &&
>>> !(be16_to_cpu(pde->state) & DDF_Missing))
>>> --
>>> 2.32.0 (Apple Git-132)
>>>
>>
>
> Hi Xiao,
> I don't see a need to send v2. Moving to awaiting upstream:
>
> Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Applied!
Thanks,
Jes
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-26 21:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-11 13:03 [PATCH 1/1] mdadm/ddf: Abort when raid disk is smaller in getinfo_super_ddf Xiao Ni
2023-10-11 13:25 ` Xiao Ni
2023-10-13 8:48 ` Mariusz Tkaczyk
2023-10-26 21:47 ` Jes Sorensen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.