IB/qib: Fix local access validation for user MRs
authorMike Marciniszyn <mike.marciniszyn@intel.com>
Fri, 28 Sep 2012 17:33:52 +0000 (17:33 +0000)
committerRoland Dreier <roland@purestorage.com>
Mon, 1 Oct 2012 16:59:26 +0000 (09:59 -0700)
Commit 8aac4cc3a9d7 ("IB/qib: RCU locking for MR validation") introduced
a bug that broke user post sends.  The proper validation of the MR
was lost in the patch.

This patch corrects that validation.

Reviewed-by: Dean Luick <dean.luick@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/hw/qib/qib_keys.c

index e9486c74c2262b5997aca9599971d625e9399677..81c7b73695d26c4898735b7e58abcd49bca398d6 100644 (file)
@@ -186,8 +186,9 @@ int qib_lkey_ok(struct qib_lkey_table *rkt, struct qib_pd *pd,
                goto bail;
 
        off = sge->addr - mr->user_base;
-       if (unlikely(sge->addr < mr->iova || off + sge->length > mr->length ||
-                    (mr->access_flags & acc) == 0))
+       if (unlikely(sge->addr < mr->user_base ||
+                    off + sge->length > mr->length ||
+                    (mr->access_flags & acc) != acc))
                goto bail;
        if (unlikely(!atomic_inc_not_zero(&mr->refcount)))
                goto bail;