Skip to content

Commit 5ecce4c

Browse files
Boris Pismennydledford
authored andcommitted
RDMA/uverbs: Check port number supplied by user verbs cmds
The ib_uverbs_create_ah() ind ib_uverbs_modify_qp() calls receive the port number from user input as part of its attributes and assumes it is valid. Down on the stack, that parameter is used to access kernel data structures. If the value is invalid, the kernel accesses memory it should not. To prevent this, verify the port number before using it. BUG: KASAN: use-after-free in ib_uverbs_create_ah+0x6d5/0x7b0 Read of size 4 at addr ffff880018d67ab8 by task syz-executor/313 BUG: KASAN: slab-out-of-bounds in modify_qp.isra.4+0x19d0/0x1ef0 Read of size 4 at addr ffff88006c40ec58 by task syz-executor/819 Fixes: 67cdb40 ("[IB] uverbs: Implement more commands") Fixes: 189aba9 ("IB/uverbs: Extend modify_qp and support packet pacing") Cc: <[email protected]> # v2.6.14+ Cc: <[email protected]> Cc: Yevgeny Kliteynik <[email protected]> Cc: Tziporet Koren <[email protected]> Cc: Alex Polak <[email protected]> Signed-off-by: Boris Pismenny <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent a379d69 commit 5ecce4c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/infiniband/core/uverbs_cmd.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,11 @@ static int modify_qp(struct ib_uverbs_file *file,
19311931
goto out;
19321932
}
19331933

1934+
if (!rdma_is_port_valid(qp->device, cmd->base.port_num)) {
1935+
ret = -EINVAL;
1936+
goto release_qp;
1937+
}
1938+
19341939
attr->qp_state = cmd->base.qp_state;
19351940
attr->cur_qp_state = cmd->base.cur_qp_state;
19361941
attr->path_mtu = cmd->base.path_mtu;
@@ -2541,6 +2546,9 @@ ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file,
25412546
if (copy_from_user(&cmd, buf, sizeof cmd))
25422547
return -EFAULT;
25432548

2549+
if (!rdma_is_port_valid(ib_dev, cmd.attr.port_num))
2550+
return -EINVAL;
2551+
25442552
INIT_UDATA(&udata, buf + sizeof(cmd),
25452553
(unsigned long)cmd.response + sizeof(resp),
25462554
in_len - sizeof(cmd), out_len - sizeof(resp));

0 commit comments

Comments
 (0)