]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r336380:
authorhselasky <hselasky@FreeBSD.org>
Thu, 2 Aug 2018 08:22:53 +0000 (08:22 +0000)
committerhselasky <hselasky@FreeBSD.org>
Thu, 2 Aug 2018 08:22:53 +0000 (08:22 +0000)
commitea28af22125f3373b9b55b67192a6a24234455ea
treea87dd1d93f9484c8fa94cf44b4ff7948fd761746
parent4705d0479c330bf00f5e16e8b0e154371eebead4
MFC r336380:
Check AF family prior resolving address and introduce safer rdma_addr_size() variants in ibcore.

Garbage supplied by user will cause to UCMA module provide zero
memory size for memcpy(), because it wasn't checked, it will
produce unpredictable results in rdma_resolve_addr().

There are several places in the ucma ABI where userspace can pass in a
sockaddr but set the address family to AF_IB.  When that happens,
rdma_addr_size() will return a size bigger than sizeof struct sockaddr_in6,
and the ucma kernel code might end up copying past the end of a buffer
not sized for a struct sockaddr_ib.

Fix this by introducing new variants
    int rdma_addr_size_in6(struct sockaddr_in6 *addr);
    int rdma_addr_size_kss(struct __kernel_sockaddr_storage *addr);

that are type-safe for the types used in the ucma ABI and return 0 if the
size computed is bigger than the size of the type passed in.  We can use
these new variants to check what size userspace has passed in before
copying any addresses.

Linux commit:
2975d5de6428ff6d9317e9948f0968f7d42e5d74
09abfe7b5b2f442a85f4c4d59ecf582ad76088d7
84652aefb347297aa08e91e283adf7b18f77c2d5

Sponsored by: Mellanox Technologies
sys/ofed/drivers/infiniband/core/ib_addr.c
sys/ofed/drivers/infiniband/core/ib_ucma.c
sys/ofed/include/rdma/ib_addr.h