From patchwork Thu Apr 19 15:28:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland Dreier X-Patchwork-Id: 10351059 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2C4F760231 for ; Thu, 19 Apr 2018 15:28:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B2C728A85 for ; Thu, 19 Apr 2018 15:28:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F61428A87; Thu, 19 Apr 2018 15:28:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8537E28A85 for ; Thu, 19 Apr 2018 15:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752780AbeDSP2S (ORCPT ); Thu, 19 Apr 2018 11:28:18 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:35401 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752689AbeDSP2S (ORCPT ); Thu, 19 Apr 2018 11:28:18 -0400 Received: by mail-pg0-f65.google.com with SMTP id j11so2672498pgf.2 for ; Thu, 19 Apr 2018 08:28:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google; h=sender:from:to:cc:subject:date:message-id; bh=ATd5Os4mA5+4CQwTKnr1yMDAVDA2scciIhLeLvs51UY=; b=gvJqCXa2ZvBypcc8vTz2ZhJL3W8iSnlf0hnYYQDKg+nLA2kz8kXLUBzBxUmW7nLZXM E0GAZAbu8OCp9cvpaAQxny0So3yGnVpO/YaNjhemkbvi2tnCGl2AGK7Q8j8eNS7yMUcX IAL5UjNeYdQl/u0RiDjBabXNKHhfJPLde59kE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=ATd5Os4mA5+4CQwTKnr1yMDAVDA2scciIhLeLvs51UY=; b=BYRDtv33YKD7dsrlm1XByOpLl42QcpmdMpZPylZGK2OclXxEwOp63900tUg8m6rCEP kYHrDWH1IjLD1kZ6oe1L/voLPmMNSShNZGU2fHFhElVAXZC0RdIzU+9FbkBd/8e54YdR 5pdoVX5cWIIWFFBQeEvn7X42sQssUz0E6TPw6PhnNotfVufSVBJlDoN0DXA072SWr+xV pJHc6jLMmyzOFfX3cyreMV9Y2rPROfOi4kctqR7MfT/pBTz+WWLZNTHfcsSwqiWORDXl i8fAWI8XfRRHkxARwqKysOJ29F6YaU09uoItJHKcSTmcAZ55BDlZk3SGD3K/anrwyWdn nJJA== X-Gm-Message-State: ALQs6tAf9O/2E2NfQ2gfho7mRZNlR1p1GjgK78SrpUA/X3k4Xy7GkK3c YeGNSpOFcfPeMfogssffjjcmQw== X-Google-Smtp-Source: AIpwx4+9KgrsOderYKedOAwvaWW0DBLQSM8Vos/89w/oVUhTx6Qt7YwquqYDc1jh30PD0VOWSWiS5Q== X-Received: by 10.99.104.71 with SMTP id d68mr5321485pgc.99.1524151697398; Thu, 19 Apr 2018 08:28:17 -0700 (PDT) Received: from roland-x1-yoga.purestorage.com ([64.84.68.252]) by smtp.gmail.com with ESMTPSA id 125sm6801946pff.158.2018.04.19.08.28.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 08:28:15 -0700 (PDT) From: Roland Dreier To: Doug Ledford , Jason Gunthorpe , Leon Romanovsky Cc: linux-rdma@vger.kernel.org, Roland Dreier , stable@vger.kernel.org Subject: [PATCH] RDMA/ucma: Allow resolving address without specifying source address Date: Thu, 19 Apr 2018 08:28:11 -0700 Message-Id: <20180419152811.4340-1-roland@kernel.org> X-Mailer: git-send-email 2.17.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Roland Dreier 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: Signed-off-by: Roland Dreier --- drivers/infiniband/core/ucma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 74329483af6d..0a7242ce7c1f 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -683,7 +683,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;