Skip to content

Commit 8b2c7e7

Browse files
rleontorvalds
authored andcommitted
RDAM/netlink: Fix out-of-bound access while checking message validity
The netlink message sent with type == 0, which doesn't have any client behind it, caused to the overflow in max_num_ops array. Fix it by declaring zero number of ops for the first client. Fixes: c990172 ("RDMA/netlink: Remove netlink clients infrastructure") Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 5969d1b commit 8b2c7e7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/infiniband/core/netlink.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ EXPORT_SYMBOL(rdma_nl_chk_listeners);
5757

5858
static bool is_nl_msg_valid(unsigned int type, unsigned int op)
5959
{
60-
static const unsigned int max_num_ops[RDMA_NL_NUM_CLIENTS - 1] = {
60+
static const unsigned int max_num_ops[RDMA_NL_NUM_CLIENTS] = {
61+
0,
6162
RDMA_NL_RDMA_CM_NUM_OPS,
6263
RDMA_NL_IWPM_NUM_OPS,
6364
0,
@@ -70,10 +71,10 @@ static bool is_nl_msg_valid(unsigned int type, unsigned int op)
7071
*/
7172
BUILD_BUG_ON(RDMA_NL_NUM_CLIENTS != 6);
7273

73-
if (type > RDMA_NL_NUM_CLIENTS - 1)
74+
if (type >= RDMA_NL_NUM_CLIENTS)
7475
return false;
7576

76-
return (op < max_num_ops[type - 1]) ? true : false;
77+
return (op < max_num_ops[type]) ? true : false;
7778
}
7879

7980
static bool is_nl_valid(unsigned int type, unsigned int op)

0 commit comments

Comments
 (0)