Whamcloud - gitweb
LU-3333 ptlrpc: Protect request buffer changing
[fs/lustre-release.git] / lustre / ptlrpc / sec_null.c
index c62ab83..1d02bc5 100644 (file)
@@ -263,11 +263,22 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec,
                 if (newbuf == NULL)
                         return -ENOMEM;
 
+               /* Must lock this, so that otherwise unprotected change of
+                * rq_reqmsg is not racing with parallel processing of
+                * imp_replay_list traversing threads. See LU-3333
+                * This is a bandaid at best, we really need to deal with this
+                * in request enlarging code before unpacking that's already
+                * there */
+               if (req->rq_import)
+                       spin_lock(&req->rq_import->imp_lock);
                 memcpy(newbuf, req->rq_reqbuf, req->rq_reqlen);
 
                 OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
                 req->rq_reqbuf = req->rq_reqmsg = newbuf;
                 req->rq_reqbuf_len = alloc_size;
+
+               if (req->rq_import)
+                       spin_unlock(&req->rq_import->imp_lock);
         }
 
         _sptlrpc_enlarge_msg_inplace(req->rq_reqmsg, segment, newsize);