Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f575394f authored by Roland Dreier's avatar Roland Dreier
Browse files

[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 <jackm@mellanox.co.il>

Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 9825051e
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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;