Skip to content

Commit b632ffa

Browse files
Christoph Hellwigdledford
authored andcommitted
IB/uverbs: reject invalid or unknown opcodes
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. Cc: stable@vger.kernel.org Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> Reviewed-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 54b9a96 commit b632ffa

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎drivers/infiniband/core/uverbs_cmd.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2372,6 +2372,12 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
23722372
next->send_flags = user_wr->send_flags;
23732373

23742374
if (is_ud) {
2375+
if (next->opcode != IB_WR_SEND &&
2376+
next->opcode != IB_WR_SEND_WITH_IMM) {
2377+
ret = -EINVAL;
2378+
goto out_put;
2379+
}
2380+
23752381
next->wr.ud.ah = idr_read_ah(user_wr->wr.ud.ah,
23762382
file->ucontext);
23772383
if (!next->wr.ud.ah) {
@@ -2411,9 +2417,11 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
24112417
user_wr->wr.atomic.compare_add;
24122418
next->wr.atomic.swap = user_wr->wr.atomic.swap;
24132419
next->wr.atomic.rkey = user_wr->wr.atomic.rkey;
2420+
case IB_WR_SEND:
24142421
break;
24152422
default:
2416-
break;
2423+
ret = -EINVAL;
2424+
goto out_put;
24172425
}
24182426
}
24192427

0 commit comments

Comments
 (0)