Whamcloud - gitweb
LU-5732 hsm: sanity check for progress input 85/12285/4
authorFrank Zago <fzago@cray.com>
Sun, 12 Oct 2014 18:57:05 +0000 (13:57 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 19 Nov 2014 19:16:08 +0000 (19:16 +0000)
During an HSM archive or restore, the progress is reported by the
copytool, in userspace. That value may be bogus. For instance, this
will crash the MDS in interval_set():

he.offset = -1;
he.length = 10;
rc = llapi_hsm_action_progress(hcp, &he, length, 0);

So check that userspace is giving a sane progress extent value.

Signed-off-by: frank zago <fzago@cray.com>
Change-Id: I0eb3fa9a66400a4ff3cee2f256c08e1d84744111
Reviewed-on: http://review.whamcloud.com/12285
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Jenkins
Reviewed-by: James Nunez <james.a.nunez@intel.com>
Reviewed-by: Henri Doreau <henri.doreau@cea.fr>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_hsm_cdt_requests.c

index 3125dcc..7430747 100644 (file)
@@ -156,8 +156,13 @@ static int hsm_update_work(struct cdt_req_progress *crp,
        int                       rc, osz, nsz;
        struct interval_node    **new_vv;
        struct interval_node     *v, *node;
        int                       rc, osz, nsz;
        struct interval_node    **new_vv;
        struct interval_node     *v, *node;
+       __u64                     end;
        ENTRY;
 
        ENTRY;
 
+       end = extent->offset + extent->length;
+       if (end <= extent->offset)
+               RETURN(-EINVAL);
+
        mutex_lock(&crp->crp_lock);
        /* new node index */
 
        mutex_lock(&crp->crp_lock);
        /* new node index */
 
@@ -196,7 +201,7 @@ static int hsm_update_work(struct cdt_req_progress *crp,
 
        v = crp->crp_node[crp->crp_cnt / NODE_VECTOR_SZ];
        node = &v[crp->crp_cnt % NODE_VECTOR_SZ];
 
        v = crp->crp_node[crp->crp_cnt / NODE_VECTOR_SZ];
        node = &v[crp->crp_cnt % NODE_VECTOR_SZ];
-       interval_set(node, extent->offset, extent->offset + extent->length);
+       interval_set(node, extent->offset, end);
        /* try to insert, if entry already exist ignore the new one
         * it can happen if ct sends 2 times the same progress */
        if (interval_insert(node, &crp->crp_root) == NULL)
        /* try to insert, if entry already exist ignore the new one
         * it can happen if ct sends 2 times the same progress */
        if (interval_insert(node, &crp->crp_root) == NULL)
@@ -205,7 +210,7 @@ static int hsm_update_work(struct cdt_req_progress *crp,
        rc = 0;
 out:
        mutex_unlock(&crp->crp_lock);
        rc = 0;
 out:
        mutex_unlock(&crp->crp_lock);
-       return rc;
+       RETURN(rc);
 }
 
 /**
 }
 
 /**