Whamcloud - gitweb
LU-4728 mdt: fix NULL deference of mdt_fid_lock 43/9543/2
authorLi Xi <lixi@ddn.com>
Fri, 7 Mar 2014 04:32:12 +0000 (12:32 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 14 Mar 2014 08:27:01 +0000 (08:27 +0000)
When enabling hsm_control, mti_exp field of struct mdt_thread_info
could be NULL.  ldlm_cli_enqueue_local will crash the kernel when
dereference it.

Signed-off-by: Li Xi <lixi@ddn.com>
Change-Id: I4bdb8222aec378e396e7f544834f6fcf9fdaf777
Reviewed-on: http://review.whamcloud.com/9543
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Faccini Bruno <bruno.faccini@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_handler.c

index efe4614..669d778 100644 (file)
@@ -2393,9 +2393,10 @@ static int mdt_object_local_lock(struct mdt_thread_info *info,
                          * want it slowed down due to possible cancels.
                          */
                         policy->l_inodebits.bits = MDS_INODELOCK_UPDATE;
                          * want it slowed down due to possible cancels.
                          */
                         policy->l_inodebits.bits = MDS_INODELOCK_UPDATE;
-                        rc = mdt_fid_lock(ns, &lh->mlh_pdo_lh, lh->mlh_pdo_mode,
-                                          policy, res_id, dlmflags,
-                                          &info->mti_exp->exp_handle.h_cookie);
+                       rc = mdt_fid_lock(ns, &lh->mlh_pdo_lh, lh->mlh_pdo_mode,
+                                         policy, res_id, dlmflags,
+                                         info->mti_exp == NULL ? NULL :
+                                         &info->mti_exp->exp_handle.h_cookie);
                         if (unlikely(rc))
                                 RETURN(rc);
                 }
                         if (unlikely(rc))
                                 RETURN(rc);
                 }
@@ -2414,9 +2415,10 @@ static int mdt_object_local_lock(struct mdt_thread_info *info,
          * going to be sent to client. If it is - mdt_intent_policy() path will
          * fix it up and turn FL_LOCAL flag off.
          */
          * going to be sent to client. If it is - mdt_intent_policy() path will
          * fix it up and turn FL_LOCAL flag off.
          */
-        rc = mdt_fid_lock(ns, &lh->mlh_reg_lh, lh->mlh_reg_mode, policy,
-                          res_id, LDLM_FL_LOCAL_ONLY | dlmflags,
-                          &info->mti_exp->exp_handle.h_cookie);
+       rc = mdt_fid_lock(ns, &lh->mlh_reg_lh, lh->mlh_reg_mode, policy,
+                         res_id, LDLM_FL_LOCAL_ONLY | dlmflags,
+                         info->mti_exp == NULL ? NULL :
+                         &info->mti_exp->exp_handle.h_cookie);
         if (rc)
                 mdt_object_unlock(info, o, lh, 1);
         else if (unlikely(OBD_FAIL_PRECHECK(OBD_FAIL_MDS_PDO_LOCK)) &&
         if (rc)
                 mdt_object_unlock(info, o, lh, 1);
         else if (unlikely(OBD_FAIL_PRECHECK(OBD_FAIL_MDS_PDO_LOCK)) &&