OSDN Git Service

IB/uverbs: Prevent reregistration of DM_MR to regular MR
authorAriel Levkovich <lariel@mellanox.com>
Thu, 26 Apr 2018 12:42:54 +0000 (15:42 +0300)
committerDoug Ledford <dledford@redhat.com>
Fri, 27 Apr 2018 18:22:24 +0000 (14:22 -0400)
This patch adds a check in the ib_uverbs_rereg_mr flow to make
sure there's no attempt to rereg a device memory MR to regular MR.
In such case the command will fail with -EINVAL status.

fixes: be934cca9e98 ("IB/uverbs: Add device memory registration ioctl support")
Signed-off-by: Ariel Levkovich <lariel@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/uverbs_cmd.c

index 13cb5e4..1837924 100644 (file)
@@ -765,6 +765,11 @@ ssize_t ib_uverbs_rereg_mr(struct ib_uverbs_file *file,
 
        mr = uobj->object;
 
+       if (mr->dm) {
+               ret = -EINVAL;
+               goto put_uobjs;
+       }
+
        if (cmd.flags & IB_MR_REREG_ACCESS) {
                ret = ib_check_mr_access(cmd.access_flags);
                if (ret)