From patchwork Thu Apr 27 09:32:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel N Pettersson X-Patchwork-Id: 9702643 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 D454D602CC for ; Thu, 27 Apr 2017 09:33:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1A1C26E73 for ; Thu, 27 Apr 2017 09:33:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C661728616; Thu, 27 Apr 2017 09:33:08 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 05EEF285F8 for ; Thu, 27 Apr 2017 09:33:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937988AbdD0JdG (ORCPT ); Thu, 27 Apr 2017 05:33:06 -0400 Received: from bes.se.axis.com ([195.60.68.10]:39014 "EHLO bes.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755096AbdD0JdE (ORCPT ); Thu, 27 Apr 2017 05:33:04 -0400 Received: from localhost (localhost [127.0.0.1]) by bes.se.axis.com (Postfix) with ESMTP id A31F22E243; Thu, 27 Apr 2017 11:33:02 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bes.se.axis.com Received: from bes.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bes.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id e3GyI52jSRFN; Thu, 27 Apr 2017 11:33:01 +0200 (CEST) Received: from boulder03.se.axis.com (boulder03.se.axis.com [10.0.8.17]) by bes.se.axis.com (Postfix) with ESMTPS id DE3F611A8A6; Thu, 27 Apr 2017 11:33:01 +0200 (CEST) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C16581E07F; Thu, 27 Apr 2017 11:33:01 +0200 (CEST) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B6B431E07E; Thu, 27 Apr 2017 11:33:01 +0200 (CEST) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder03.se.axis.com (Postfix) with ESMTP; Thu, 27 Apr 2017 11:33:01 +0200 (CEST) Received: from lnxdanielnp1.se.axis.com (lnxdanielnp1.se.axis.com [10.93.76.2]) by seth.se.axis.com (Postfix) with ESMTP id AAE71203E; Thu, 27 Apr 2017 11:33:01 +0200 (CEST) Received: by lnxdanielnp1.se.axis.com (Postfix, from userid 20271) id A452E80A1F; Thu, 27 Apr 2017 11:33:01 +0200 (CEST) From: Daniel N Pettersson To: sfrench@samba.org Cc: linux-cifs@vger.kernel.org, Daniel N Pettersson Subject: [PATCH] cifs: fix IPv6 link local, with scope id, address parsing Date: Thu, 27 Apr 2017 11:32:36 +0200 Message-Id: <1493285556-18947-1-git-send-email-Daniel.N.Pettersson@axis.com> X-Mailer: git-send-email 2.1.4 X-TM-AS-GCONF: 00 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel N Pettersson When the IP address is gotten from the UNC, use only the address part of the UNC. Else all after the percent sign in an IPv6 link local address is interpreted as a scope id. This includes the slash and share name. A scope id is expected to be an integer and any trailing characters makes the conversion to integer fail. Example of mount command that fails: mount -i -t cifs //fe80::6a05:caff:fe3e:8ffc%2/test /mnt/t -o sec=none Signed-off-by: Daniel N Pettersson --- fs/cifs/connect.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index d82467c..3f7819e 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1945,9 +1945,14 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, } if (!got_ip) { + int len; + const char *slash; + /* No ip= option specified? Try to get it from UNC */ - if (!cifs_convert_address(dstaddr, &vol->UNC[2], - strlen(&vol->UNC[2]))) { + /* Use the address part of the UNC. */ + slash = strchr(&vol->UNC[2], '\\'); + len = slash - &vol->UNC[2]; + if (!cifs_convert_address(dstaddr, &vol->UNC[2], len)) { pr_err("Unable to determine destination address.\n"); goto cifs_parse_mount_err; }