From: Mark Bloch Date: Fri, 6 May 2016 19:45:26 +0000 (+0300) Subject: IB/core: Fix a potential array overrun in CMA and SA agent X-Git-Tag: v3.16.37~223 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=da71e66f13f8b7609d184fee5285126329451d87;p=thirdparty%2Fkernel%2Fstable.git IB/core: Fix a potential array overrun in CMA and SA agent commit 2fa2d4fb1166d1ef35f0aacac6165d53ab1b89c7 upstream. Fix array overrun when going over callback table. In declaration of callback table, the max size isn't provided and in registration phase, it is provided. There is potential scenario where a new operation is added and it is not supported by current client. The acceptance of such operation by ib_netlink will cause to array overrun. Fixes: 809d5fc9bf65 ("infiniband: pass rdma_cm module to netlink_dump_start") Fixes: b493d91d333e ("iwcm: common code for port mapper") Fixes: 2ca546b92a02 ("IB/sa: Route SA pathrecord query through netlink") Signed-off-by: Mark Bloch Reviewed-by: Leon Romanovsky Signed-off-by: Leon Romanovsky Signed-off-by: Doug Ledford [bwh: Backported to 3.16: - Only cma.c needs to be fixed - Adjust context] Signed-off-by: Ben Hutchings --- diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 06441a43c3aac..cf3d9dee8aff1 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -3679,7 +3679,8 @@ static int __init cma_init(void) if (ret) goto err; - if (ibnl_add_client(RDMA_NL_RDMA_CM, RDMA_NL_RDMA_CM_NUM_OPS, cma_cb_table)) + if (ibnl_add_client(RDMA_NL_RDMA_CM, ARRAY_SIZE(cma_cb_table), + cma_cb_table)) printk(KERN_WARNING "RDMA CMA: failed to add netlink callback\n"); return 0;