Whamcloud - gitweb
LU-1907 build: avoid function resolution mistakes by Coverity
authorSebastien Buisson <sebastien.buisson@bull.net>
Wed, 12 Sep 2012 12:49:17 +0000 (14:49 +0200)
committerOleg Drokin <green@whamcloud.com>
Thu, 20 Sep 2012 04:05:02 +0000 (00:05 -0400)
Remove function resolution mistakes made by Coverity version
6.0.3.
The .hs_keycmp function is incorrectly resolved by Coverity,
making the variable passed as its first 'key' parameter to
be considered of the wrong type. Data structures being of
different sizes, it ends up with this Coverity defect:
Out-of-bounds access (OVERRUN_STATIC)
Overrunning static array by passing it as an argument to a
function which indexes it at a higher byte position.

Signed-off-by: Sebastien Buisson <sebastien.buisson@bull.net>
Change-Id: Ia64d90f2faed17981cc4b4eaa960a797ab056daf
Reviewed-on: http://review.whamcloud.com/3955
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Keith Mannthey <keith@whamcloud.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ldlm/ldlm_lock.c
lustre/ldlm/ldlm_lockd.c
lustre/ldlm/ldlm_request.c
lustre/lov/lov_obd.c
lustre/lov/lov_object.c
lustre/lov/lov_pack.c
lustre/lov/lov_qos.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_open.c
lustre/obdecho/echo_client.c
lustre/ptlrpc/connection.c

index 93ccbee..665b3fc 100644 (file)
@@ -338,6 +338,9 @@ int ldlm_lock_destroy_internal(struct ldlm_lock *lock)
        if (lock->l_export && lock->l_export->exp_lock_hash) {
                /* NB: it's safe to call cfs_hash_del() even lock isn't
                 * in exp_lock_hash. */
+               /* In the function below, .hs_keycmp resolves to
+                * ldlm_export_lock_keycmp() */
+               /* coverity[overrun-buffer-val] */
                cfs_hash_del(lock->l_export->exp_lock_hash,
                             &lock->l_remote_handle, &lock->l_exp_hash);
        }
index bb51369..5b56761 100644 (file)
@@ -1182,6 +1182,9 @@ int ldlm_handle_enqueue0(struct ldlm_namespace *ns,
 
         if (unlikely(flags & LDLM_FL_REPLAY)) {
                 /* Find an existing lock in the per-export lock hash */
+               /* In the function below, .hs_keycmp resolves to
+                * ldlm_export_lock_keycmp() */
+               /* coverity[overrun-buffer-val] */
                 lock = cfs_hash_lookup(req->rq_export->exp_lock_hash,
                                        (void *)&dlm_req->lock_handle[0]);
                 if (lock != NULL) {
@@ -2316,6 +2319,9 @@ int ldlm_revoke_lock_cb(cfs_hash_t *hs, cfs_hash_bd_t *bd,
         if (lock->l_export && lock->l_export->exp_lock_hash) {
                /* NB: it's safe to call cfs_hash_del() even lock isn't
                 * in exp_lock_hash. */
+               /* In the function below, .hs_keycmp resolves to
+                * ldlm_export_lock_keycmp() */
+               /* coverity[overrun-buffer-val] */
                cfs_hash_del(lock->l_export->exp_lock_hash,
                             &lock->l_remote_handle, &lock->l_exp_hash);
        }
index 48138b0..d899f5f 100644 (file)
@@ -533,6 +533,9 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
         lock_res_and_lock(lock);
         /* Key change rehash lock in per-export hash with new key */
         if (exp->exp_lock_hash) {
+               /* In the function below, .hs_keycmp resolves to
+                * ldlm_export_lock_keycmp() */
+               /* coverity[overrun-buffer-val] */
                 cfs_hash_rehash_key(exp->exp_lock_hash,
                                     &lock->l_remote_handle,
                                     &reply->lock_handle,
@@ -2039,6 +2042,9 @@ static int replay_lock_interpret(const struct lu_env *env,
         /* Key change rehash lock in per-export hash with new key */
         exp = req->rq_export;
         if (exp && exp->exp_lock_hash) {
+               /* In the function below, .hs_keycmp resolves to
+                * ldlm_export_lock_keycmp() */
+               /* coverity[overrun-buffer-val] */
                 cfs_hash_rehash_key(exp->exp_lock_hash,
                                     &lock->l_remote_handle,
                                     &reply->lock_handle,
index 48a5d7a..9879658 100644 (file)
@@ -898,6 +898,9 @@ static int lov_cleanup(struct obd_device *obd)
                 pool = cfs_list_entry(pos, struct pool_desc, pool_list);
                 /* free pool structs */
                 CDEBUG(D_INFO, "delete pool %p\n", pool);
+               /* In the function below, .hs_keycmp resolves to
+                * pool_hashkey_keycmp() */
+               /* coverity[overrun-buffer-val] */
                 lov_pool_del(obd, pool->pool_name);
         }
         cfs_hash_putref(lov->lov_pools_hash_body);
index 9b52f34..bef4eef 100644 (file)
@@ -215,6 +215,9 @@ static int lov_init_raid0(const struct lu_env *env,
                         subdev = lovsub2cl_dev(dev->ld_target[ost_idx]);
                         subconf->u.coc_oinfo = oinfo;
                         LASSERTF(subdev != NULL, "not init ost %d\n", ost_idx);
+                       /* In the function below, .hs_keycmp resolves to
+                        * lu_obj_hop_keycmp() */
+                       /* coverity[overrun-buffer-val] */
                         stripe = lov_sub_find(env, subdev, ofid, subconf);
                         if (!IS_ERR(stripe))
                                 result = lov_init_sub(env, lov, stripe, r0, i);
index 8553395..9840c2a 100644 (file)
@@ -465,6 +465,9 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size,
         if (lmm_magic == LOV_USER_MAGIC_V3) {
                 struct pool_desc *pool;
 
+               /* In the function below, .hs_keycmp resolves to
+                * pool_hashkey_keycmp() */
+               /* coverity[overrun-buffer-val] */
                 pool = lov_find_pool(lov, lumv3->lmm_pool_name);
                 if (pool != NULL) {
                         if (lumv3->lmm_stripe_offset !=
index 2b22ea4..cc11cd7 100644 (file)
@@ -540,6 +540,9 @@ int qos_remedy_create(struct lov_request_set *set, struct lov_request *req)
        ENTRY;
 
        /* First check whether we can create the objects on the pool */
+       /* In the function below, .hs_keycmp resolves to
+        * pool_hashkey_keycmp() */
+       /* coverity[overrun-buffer-val] */
        pool = lov_find_pool(lov, lsm->lsm_pool_name);
        if (pool != NULL) {
                cfs_down_read(&pool_tgt_rw_sem(pool));
@@ -696,6 +699,9 @@ static int alloc_specific(struct lov_obd *lov, struct lov_stripe_md *lsm,
         struct ost_pool *osts;
         ENTRY;
 
+       /* In the function below, .hs_keycmp resolves to
+        * pool_hashkey_keycmp() */
+       /* coverity[overrun-buffer-val] */
         pool = lov_find_pool(lov, lsm->lsm_pool_name);
         if (pool == NULL) {
                 osts = &(lov->lov_packed);
@@ -968,6 +974,9 @@ static int alloc_idx_array(struct obd_export *exp, struct lov_stripe_md *lsm,
 
         if (newea ||
             lsm->lsm_oinfo[0]->loi_ost_idx >= lov->desc.ld_tgt_count)
+               /* In the function below, .hs_keycmp resolves to
+                * pool_hashkey_keycmp() */
+               /* coverity[overrun-buffer-val] */
                 rc = alloc_qos(exp, tmp_arr, &stripe_cnt,
                                lsm->lsm_pool_name, flags);
         else
index 65c6c10..4fb98ae 100644 (file)
@@ -3439,6 +3439,9 @@ static void mdt_intent_fixup_resent(struct mdt_thread_info *info,
         dlmreq = req_capsule_client_get(info->mti_pill, &RMF_DLM_REQ);
         remote_hdl = dlmreq->lock_handle[0];
 
+       /* In the function below, .hs_keycmp resolves to
+        * ldlm_export_lock_keycmp() */
+       /* coverity[overrun-buffer-val] */
         lock = cfs_hash_lookup(exp->exp_lock_hash, &remote_hdl);
         if (lock) {
                 if (lock != new_lock) {
index 6b09688..f78f20e 100644 (file)
@@ -1357,6 +1357,9 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc)
                 *child_fid = *info->mti_rr.rr_fid2;
                 LASSERTF(fid_is_sane(child_fid), "fid="DFID"\n",
                          PFID(child_fid));
+               /* In the function below, .hs_keycmp resolves to
+                * lu_obj_hop_keycmp() */
+               /* coverity[overrun-buffer-val] */
                child = mdt_object_new(info->mti_env, mdt, child_fid);
        } else {
                /*
index 63b921d..fc73c1e 100644 (file)
@@ -1079,6 +1079,9 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d,
         fid  = &info->eti_fid;
         lsm2fid(lsm, fid);
 
+       /* In the function below, .hs_keycmp resolves to
+        * lu_obj_hop_keycmp() */
+       /* coverity[overrun-buffer-val] */
         obj = cl_object_find(env, echo_dev2cl(d), fid, &conf->eoc_cl);
         if (IS_ERR(obj))
                 GOTO(out, eco = (void*)obj);
@@ -2036,6 +2039,9 @@ static int echo_md_handler(struct echo_device *ed, int command,
                 fid->f_seq = data->ioc_obdo1.o_seq;
                 fid->f_oid = (__u32)data->ioc_obdo1.o_id;
                 fid->f_ver = 0;
+               /* In the function below, .hs_keycmp resolves to
+                * lu_obj_hop_keycmp() */
+               /* coverity[overrun-buffer-val] */
                 rc = echo_create_md_object(env, ed, parent, fid, name, namelen,
                                            id, mode, count, stripe_count,
                                            stripe_index);
index c8f749b..f87e4ab 100644 (file)
@@ -76,6 +76,9 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self,
          * connection.  The object which exists in the has will be
          * returned and may be compared against out object.
          */
+       /* In the function below, .hs_keycmp resolves to
+        * conn_keycmp() */
+       /* coverity[overrun-buffer-val] */
         conn2 = cfs_hash_findadd_unique(conn_hash, &peer, &conn->c_hash);
         if (conn != conn2) {
                 OBD_FREE_PTR(conn);