Skip to content

Commit 5fd2bba

Browse files
Boris Pismennygregkh
authored andcommitted
RDMA/uverbs: Check port number supplied by user verbs cmds
commit 5ecce4c9b17bed4dc9cb58bfb10447307569b77b upstream. 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") Cc: Yevgeny Kliteynik <kliteyn@mellanox.com> Cc: Tziporet Koren <tziporet@mellanox.com> Cc: Alex Polak <alexpo@mellanox.com> Signed-off-by: Boris Pismenny <borisp@mellanox.com> Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 92e90c2 commit 5fd2bba

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

drivers/infiniband/core/uverbs_cmd.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,6 +2287,10 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
22872287
if (copy_from_user(&cmd, buf, sizeof cmd))
22882288
return -EFAULT;
22892289

2290+
if (cmd.port_num < rdma_start_port(ib_dev) ||
2291+
cmd.port_num > rdma_end_port(ib_dev))
2292+
return -EINVAL;
2293+
22902294
INIT_UDATA(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
22912295
out_len);
22922296

@@ -2827,6 +2831,10 @@ ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file,
28272831
if (copy_from_user(&cmd, buf, sizeof cmd))
28282832
return -EFAULT;
28292833

2834+
if (cmd.attr.port_num < rdma_start_port(ib_dev) ||
2835+
cmd.attr.port_num > rdma_end_port(ib_dev))
2836+
return -EINVAL;
2837+
28302838
uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
28312839
if (!uobj)
28322840
return -ENOMEM;

0 commit comments

Comments
 (0)