Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10406802ybi; Wed, 24 Jul 2019 22:39:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7iu+HBuJ7i+8nlVstbfMGMFCPWqATqF+Qxljrbv2ZivDJWIXEjOrUm2QVtopXqf+BZHqL X-Received: by 2002:a63:5a4d:: with SMTP id k13mr82172050pgm.174.1564033149381; Wed, 24 Jul 2019 22:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564033149; cv=none; d=google.com; s=arc-20160816; b=tPlTwVEkSVzBwsOOhplvZJM8F54dWO8OYn6c1VU5xpIk+emS42n1kiUw3VK3sfy3N4 H8LVySOVFYAGZGKE642M5PkA8UkiERoq/KNBLQE3X5Y2TqnJ9WD08N0gDfnFcSyA6wOz UyuvNWcmZ5N4jPwSu2hfbzR3mj/DtQKO2XyV5iHhBE/YWGIUlvibTCiJ13dLX08gZUdI xqQcHsHCxQRyxhP4fHWtGkCF2DHAI7xRmiSjGkRy29pzR/HVR8sa6wApJmRZEiYOf8Qm LFkGGAmtIJnJoQogucvTt7wDAfgy41cOAOJ0WVo+O3lxeisJUgPmrtNq89oqwOUL5FPO a1Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KXce18tC7/JKvvkncVtuylz7ocACGm9S/2h33hD52Jc=; b=yGLg3Yuth3bFMM9OkJzKVVQr3IVQhPRmav0RXgtN6Yeo1Dr0cRh8LMZWtELoJcBY8L Oog+qXz9Wqb50QfKaxNTTTleyI1P18PXj2tkOKF+vQ6mNxZMvKX/vVIozubc/q/XPxKi qMC2sTjjccjYZrl5srOPrp5UPkSB0C+1/GyEVFgm11hFKr6YYUKVNVjphe3fcN+jqjxX 3aMorjNbNozydTwcSzY1VnAy4jQeAethBqeha9MpW4xEBgeJimLp5G2XlSyYwsqUu0rF ixob9OWJqq+Xy+iNAx6V3lMQjGqVQJ2X/6fBlvXAvrDXAOPGq55XCzz+fgj1K7DUcy0s BZUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f7LOulmn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u1si14325517plb.234.2019.07.24.22.38.54; Wed, 24 Jul 2019 22:39:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f7LOulmn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405049AbfGXT65 (ORCPT + 99 others); Wed, 24 Jul 2019 15:58:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:45852 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405004AbfGXT6y (ORCPT ); Wed, 24 Jul 2019 15:58:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CB6A120665; Wed, 24 Jul 2019 19:58:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563998333; bh=CyBCEbDBz1BSAcBzsXW89LRvaF7GfCsGEVdKEaDP2d8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f7LOulmn+CT1sEy1HaIUJ1t/ar2VFZ/rnOkHfL3JSC6Ys6PTut9im4sYtPqE8t5A5 MpUYHfMKJvGuz6IapA+40xbDlaSdJiy2SMRyhLk6yuAHI5Dhwn6f7Z/G0BLGZqfW1Y 1e5rhc7pWvEOEcQ70y0w3F6vqfOlD+v8NywtWZBo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bart Van Assche , Jason Gunthorpe Subject: [PATCH 5.1 328/371] RDMA/srp: Accept again source addresses that do not have a port number Date: Wed, 24 Jul 2019 21:21:20 +0200 Message-Id: <20190724191748.507692141@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bart Van Assche commit bcef5b7215681250c4bf8961dfe15e9e4fef97d0 upstream. The function srp_parse_in() is used both for parsing source address specifications and for target address specifications. Target addresses must have a port number. Having to specify a port number for source addresses is inconvenient. Make sure that srp_parse_in() supports again parsing addresses with no port number. Cc: Fixes: c62adb7def71 ("IB/srp: Fix IPv6 address parsing") Signed-off-by: Bart Van Assche Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/ulp/srp/ib_srp.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -3481,13 +3481,14 @@ static const match_table_t srp_opt_token * @net: [in] Network namespace. * @sa: [out] Address family, IP address and port number. * @addr_port_str: [in] IP address and port number. + * @has_port: [out] Whether or not @addr_port_str includes a port number. * * Parse the following address formats: * - IPv4: :, e.g. 1.2.3.4:5. * - IPv6: \[\]:, e.g. [1::2:3%4]:5. */ static int srp_parse_in(struct net *net, struct sockaddr_storage *sa, - const char *addr_port_str) + const char *addr_port_str, bool *has_port) { char *addr_end, *addr = kstrdup(addr_port_str, GFP_KERNEL); char *port_str; @@ -3496,9 +3497,12 @@ static int srp_parse_in(struct net *net, if (!addr) return -ENOMEM; port_str = strrchr(addr, ':'); - if (!port_str) - return -EINVAL; - *port_str++ = '\0'; + if (port_str && strchr(port_str, ']')) + port_str = NULL; + if (port_str) + *port_str++ = '\0'; + if (has_port) + *has_port = port_str != NULL; ret = inet_pton_with_scope(net, AF_INET, addr, port_str, sa); if (ret && addr[0]) { addr_end = addr + strlen(addr) - 1; @@ -3520,6 +3524,7 @@ static int srp_parse_options(struct net char *p; substring_t args[MAX_OPT_ARGS]; unsigned long long ull; + bool has_port; int opt_mask = 0; int token; int ret = -EINVAL; @@ -3618,7 +3623,8 @@ static int srp_parse_options(struct net ret = -ENOMEM; goto out; } - ret = srp_parse_in(net, &target->rdma_cm.src.ss, p); + ret = srp_parse_in(net, &target->rdma_cm.src.ss, p, + NULL); if (ret < 0) { pr_warn("bad source parameter '%s'\n", p); kfree(p); @@ -3634,7 +3640,10 @@ static int srp_parse_options(struct net ret = -ENOMEM; goto out; } - ret = srp_parse_in(net, &target->rdma_cm.dst.ss, p); + ret = srp_parse_in(net, &target->rdma_cm.dst.ss, p, + &has_port); + if (!has_port) + ret = -EINVAL; if (ret < 0) { pr_warn("bad dest parameter '%s'\n", p); kfree(p);