From: Roland Dreier Date: Mon, 3 Oct 2005 16:18:02 +0000 (-0700) Subject: [IB] uverbs: reject invalid memory registration permission flags X-Git-Tag: v2.6.15-rc1~731^2~21^2~35 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=f575394f1de9b4afa4b474f1882c7e2d3b8e51d7;p=linux-2.6-omap-h63xx.git [IB] uverbs: reject invalid memory registration permission flags Reject userspace memory registrations with invalid permission flags: "local write" is required if "remote write" or "remote atomic" is also requested. Pointed out by Jack Morgenstein Signed-off-by: Roland Dreier --- diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index a0ceb1cbed5..2e959acf2ff 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -396,6 +396,14 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file, if ((cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK)) return -EINVAL; + /* + * Local write permission is required if remote write or + * remote atomic permission is also requested. + */ + if (cmd.access_flags & (IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_REMOTE_WRITE) && + !(cmd.access_flags & IB_ACCESS_LOCAL_WRITE)) + return -EINVAL; + obj = kmalloc(sizeof *obj, GFP_KERNEL); if (!obj) return -ENOMEM;