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IAlpZiAobWFwX2xvY2soJm1hcCkpCiAJCWZw cmludGYoc3RkZXJy
LCBOYW1lICI6IGZhaWxlZCB0byBnZXQgZXhjbHVzaXZlIGxvY2sgb24gIgog CQkJIm1hcGZpbGVc
biIpOwoKLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tCkludGVsIFRlY2hub2xvZ3kgUG9sYW5kIHNw LiB6IG8uby4KeiBz
aWVkemliYSB3IEdkYW5za3UKdWwuIFNsb3dhY2tpZWdvIDE3Mwo4MC0yOTgg R2RhbnNrCgpTYWQg
UmVqb25vd3kgR2RhbnNrIFBvbG5vYyB3IEdkYW5za3UsIApWSUkgV3lkemlh bCBHb3Nwb2RhcmN6
eSBLcmFqb3dlZ28gUmVqZXN0cnUgU2Fkb3dlZ28sIApudW1lciBLUlMgMTAx ODgyCgpOSVAgOTU3
LTA3LTUyLTMxNgpLYXBpdGFsIHpha2xhZG93eSAyMDAuMDAwIHpsCgpUaGlz IGUtbWFpbCBhbmQg
YW55IGF0dGFjaG1lbnRzIG1heSBjb250YWluIGNvbmZpZGVudGlhbCBtYXRl cmlhbCBmb3IKdGhl
IHNvbGUgdXNlIG9mIHRoZSBpbnRlbmRlZCByZWNpcGllbnQocykuIEFueSBy ZXZpZXcgb3IgZGlz
dHJpYnV0aW9uCmJ5IG90aGVycyBpcyBzdHJpY3RseSBwcm9oaWJpdGVkLiBJ ZiB5b3UgYXJlIG5v
dCB0aGUgaW50ZW5kZWQKcmVjaXBpZW50LCBwbGVhc2UgY29udGFjdCB0aGUg c2VuZGVyIGFuZCBk
ZWxldGUgYWxsIGNvcGllcy4K
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] FIX: Prevent using null list pointer
am 07.09.2011 04:46:12 von NeilBrown
On Thu, 01 Sep 2011 15:28:36 +0200 Lukasz Dorau
wrote:
> When not all attributes are supported (attributes incompatibility)
> function container_content_imsm returns NULL pointer.
> In this case mdadm should immediately exit with error to prevent
> using null "list" pointer.
>
> Signed-off-by: Lukasz Dorau
> ---
> Incremental.c | 5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/Incremental.c b/Incremental.c
> index 951c2a0..deace7d 100644
> --- a/Incremental.c
> +++ b/Incremental.c
> @@ -1460,6 +1460,11 @@ static int Incremental_container(struct supertype *st, char *devname,
> trustworthy = FOREIGN;
>
> list = st->ss->container_content(st, NULL);
> + if (!list) {
> + fprintf(stderr, Name ": Cannot get container content. "
> + "Array cannot be assembled.\n");
> + return 2;
> + }
> if (map_lock(&map))
> fprintf(stderr, Name ": failed to get exclusive lock on "
> "mapfile\n");
>
Thanks for the patch.
I'll like to handle NULL a bit differently though - see below.
Thanks,
NeilBrown
commit 75c2df6509391e28257d696815bddb854a8c4a94
Author: NeilBrown
Date: Wed Sep 7 12:45:24 2011 +1000
FIX: Prevent using null list pointer
When not all attributes are supported (attributes incompatibility)
function container_content_imsm returns NULL pointer.
We need to cope with a NULL list better.
Reported-by: Lukasz Dorau
Signed-off-by: NeilBrown
diff --git a/Incremental.c b/Incremental.c
index 951c2a0..09cdd9b 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -1464,7 +1464,7 @@ static int Incremental_container(struct supertype *st, char *devname,
fprintf(stderr, Name ": failed to get exclusive lock on "
"mapfile\n");
/* do not assemble arrays that might have bad blocks */
- if (list->array.state & (1<
+ if (list && list->array.state & (1<
fprintf(stderr, Name ": BBM log found in metadata. "
"Cannot activate array(s).\n");
/* free container data and exit */
diff --git a/policy.c b/policy.c
index ebb1481..2bbbac8 100644
--- a/policy.c
+++ b/policy.c
@@ -678,6 +678,8 @@ struct domainlist *domain_from_array(struct mdinfo *mdi, const char *metadata)
{
struct domainlist *domlist = NULL;
+ if (!mdi)
+ return NULL;
for (mdi = mdi->devs ; mdi ; mdi = mdi->next)
domainlist_add_dev(&domlist, makedev(mdi->disk.major,
mdi->disk.minor),
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html