]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
RDMA/ucma: Allow resolving address w/o specifying source address
authorRoland Dreier <roland@purestorage.com>
Thu, 19 Apr 2018 15:28:11 +0000 (08:28 -0700)
committerSasha Levin <alexander.levin@microsoft.com>
Wed, 23 May 2018 01:36:39 +0000 (21:36 -0400)
[ Upstream commit 09abfe7b5b2f442a85f4c4d59ecf582ad76088d7 ]

The RDMA CM will select a source device and address by consulting
the routing table if no source address is passed into
rdma_resolve_address().  Userspace will ask for this by passing an
all-zero source address in the RESOLVE_IP command.  Unfortunately
the new check for non-zero address size rejects this with EINVAL,
which breaks valid userspace applications.

Fix this by explicitly allowing a zero address family for the source.

Fixes: 2975d5de6428 ("RDMA/ucma: Check AF family prior resolving address")
Cc: <stable@vger.kernel.org>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
drivers/infiniband/core/ucma.c

index f7973c0b8a9356314ca116999bda6d595265b534..2daae8b758f19d03cb8011b84df06ef5c6f86d86 100644 (file)
@@ -571,7 +571,7 @@ static ssize_t ucma_resolve_ip(struct ucma_file *file,
        if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
                return -EFAULT;
 
-       if (!rdma_addr_size_in6(&cmd.src_addr) ||
+       if ((cmd.src_addr.sin6_family && !rdma_addr_size_in6(&cmd.src_addr)) ||
            !rdma_addr_size_in6(&cmd.dst_addr))
                return -EINVAL;