From: anserper Date: Thu, 11 Jun 2009 10:03:24 +0000 (+0000) Subject: b=19115 X-Git-Tag: v1_8_0_1~9 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=fc3eb4f92ad94e21384055ff1b03fef5020da345;p=fs%2Flustre-release.git b=19115 i=Andreas Dilger i=Nathan Rutman make lov_setstripe exit on bad magic --- diff --git a/lustre/lov/lov_pack.c b/lustre/lov/lov_pack.c index 9b8dcf8..ba552e8 100644 --- a/lustre/lov/lov_pack.c +++ b/lustre/lov/lov_pack.c @@ -424,24 +424,27 @@ int lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp, rc = copy_from_user(&lumv3, lump, sizeof(struct lov_user_md_v1)); if (rc) RETURN(-EFAULT); - if ((lumv1->lmm_magic == LOV_USER_MAGIC_V3) || - (lumv1->lmm_magic == LOV_USER_MAGIC_V3_SWABBED)) { + + switch (lumv1->lmm_magic) { + case LOV_USER_MAGIC_V3_SWABBED: rc = copy_from_user(&lumv3, lump, sizeof(lumv3)); if (rc) - RETURN(-EFAULT); - } - - if ((lumv1->lmm_magic == LOV_USER_MAGIC_V1_SWABBED) || - (lumv1->lmm_magic == LOV_USER_MAGIC_V3_SWABBED)) { + break; + /* fall through to swab */ + case LOV_USER_MAGIC_V1_SWABBED: rc = lustre_swab_lov_user_md(lumv1); - if (rc) - RETURN(rc); - } else if ((lumv1->lmm_magic != LOV_USER_MAGIC_V1) && - (lumv1->lmm_magic != LOV_USER_MAGIC_V3)) { - CDEBUG(D_IOCTL, "bad userland LOV MAGIC: %#08x\n", - lumv1->lmm_magic); + break; + case LOV_USER_MAGIC_V3: + rc = copy_from_user(&lumv3, lump, sizeof(lumv3)); + /* fall through */ + case LOV_USER_MAGIC_V1: + break; + default: + CERROR("bad lsm magic %08x\n", lumv1->lmm_magic); RETURN(-EINVAL); } + if (rc) + RETURN(rc); /* in the rest of the tests, as *lumv1 and lumv3 have the same * fields, we use lumv1 to avoid code duplication */