Commit 7808f78e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Ben Hutchings

IB/uverbs: reject invalid or unknown opcodes

commit b632ffa7 upstream.

We have many WR opcodes that are only supported in kernel space
and/or require optional information to be copied into the WR
structure.  Reject all those not explicitly handled so that we
can't pass invalid information to drivers.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: default avatarSagi Grimberg <sagig@mellanox.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent ed2a4a92
...@@ -1979,6 +1979,12 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, ...@@ -1979,6 +1979,12 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
next->send_flags = user_wr->send_flags; next->send_flags = user_wr->send_flags;
if (is_ud) { if (is_ud) {
if (next->opcode != IB_WR_SEND &&
next->opcode != IB_WR_SEND_WITH_IMM) {
ret = -EINVAL;
goto out_put;
}
next->wr.ud.ah = idr_read_ah(user_wr->wr.ud.ah, next->wr.ud.ah = idr_read_ah(user_wr->wr.ud.ah,
file->ucontext); file->ucontext);
if (!next->wr.ud.ah) { if (!next->wr.ud.ah) {
...@@ -2015,9 +2021,11 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, ...@@ -2015,9 +2021,11 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
user_wr->wr.atomic.compare_add; user_wr->wr.atomic.compare_add;
next->wr.atomic.swap = user_wr->wr.atomic.swap; next->wr.atomic.swap = user_wr->wr.atomic.swap;
next->wr.atomic.rkey = user_wr->wr.atomic.rkey; next->wr.atomic.rkey = user_wr->wr.atomic.rkey;
case IB_WR_SEND:
break; break;
default: default:
break; ret = -EINVAL;
goto out_put;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment