In ib_uverbs_poll_cq() code there is a potential integer overflow if
userspace passes in a large cmd.ne. The calls to kmalloc() would
allocate smaller buffers than intended, leading to memory corruption.
There iss also an information leak if resp wasn't all used.
Unprivileged userspace may call this function, although only if an
RDMA device that uses this function is present.
Fix this by copying CQ entries one at a time, which avoids the
allocation entirely, and also by moving this copying into a function
that makes sure to initialize all memory copied to userspace.
Special thanks to Jason Gunthorpe <email@example.com>
for his help and advice.
Signed-off-by: Dan Carpenter <firstname.lastname@example.org>
[ Monkey around with things a bit to avoid bad code generation by gcc
when designated initializers are used. - Roland ]
Signed-off-by: Roland Dreier <email@example.com>
Signed-off-by: Paolo Pisati <firstname.lastname@example.org>
drivers/infiniband/core/uverbs_cmd.c | 101 +++++++++++++++++++---------------
1 files changed, 57 insertions(+), 44 deletions(-)
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 495c803..3f9d3fe 100644
@@ -877,68 +877,81 @@ out:
return ret ? ret : in_len;