Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3877647pxb; Tue, 17 Nov 2020 06:02:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNWVTtfjtE/pXRUvyD47u6gaBEm5E5e1006dQH55bQTJLy31pjUb08BEWIsv+XuVVumKR2 X-Received: by 2002:a2e:90c5:: with SMTP id o5mr1791771ljg.136.1605621769704; Tue, 17 Nov 2020 06:02:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605621769; cv=none; d=google.com; s=arc-20160816; b=tR1h0JRUtwWTYAR7OWHfIS5SjGik1Qh7VH4sxu+KJsL7C+WH1fWUn7xtGpRcztwfPp hKo1lqBDG7za0LDFPtsj7tqM4U0RaRpmuPJX/EidQTqrhp2RZpia3ZmDBMXlYPafhI1m 2l0szFp3IYQrFF1LhERWVk9Pm9XF79mTBFkndKcE0y/Hsol6S8phptUXprf3+HoRTSi/ A4C0CGBh/zTH38ie9X4jJgUHIqYwjLQqJfBdmgAW9DblORg5fLbhy46ABjAvFLTKjoio XXsMPpq/lcIG/3GRPx5VGOcPAhZ+JemRTXQflQhbxEMTmC1GEf42HNh11e7wyEG+9amd bpUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Zt/8ppvLvCMgOOSstfx4wQMmc7iWggHQ7/rLJnGOaBU=; b=YIoVVf7gGvDGSdGJgS/i1saOqZBZ698gsLn25yF2DSLU+lcjArIUqfo2ESqomN4oVO wZr7wtZxEsq5GRGAU+t6k5R35+0m45B+lzj6LpXn+gBtj9AmhsSsAHF1onNYB0exPkLe lYF4j8nyJJ1Ozg7uno7MP1/VvSjDOISt/Z9lcW7nrUBn1OfLPOnZjmDdFRTYovhfgpuG b0EX6ZgQr7MuU0cqBU6wl1qC2yhJSafrRAjIKwZyn9xiSGCK7oWBdAVEjpwnZEk73xHv 7sI5VUavh4d34e1FCfSeO1IEa5LII6sQh918IqMaGJM05oYuQvm0SeCZiR9QkDKRow/v 1OrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jmM10Pjb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o1si12430562ejn.643.2020.11.17.06.02.19; Tue, 17 Nov 2020 06:02:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jmM10Pjb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732108AbgKQOAL (ORCPT + 99 others); Tue, 17 Nov 2020 09:00:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:49096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729577AbgKQNQz (ORCPT ); Tue, 17 Nov 2020 08:16:55 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 A58A424248; Tue, 17 Nov 2020 13:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619015; bh=xkxCDZrvI81kovN52nHtM7xfGI8a26IvSOwrGz1V8sQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jmM10PjbfAdKyhcrhxV6HjaHzQ6TiP5ge/pJIsvrp3j2cj+5BiLhck4jp/Jd68ja1 xqCChegcwn9/VDo0L9/eOq/w/tBIcqsqHdI2pii5mJo/ztoBC0e1a9cTSq0dwJSTdD sGb6LclnE4ePuPGivlHJizEwDH6ALLx53u6KXBMs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Boris Protopopov , Ronnie Sahlberg , Steve French Subject: [PATCH 4.14 85/85] Convert trailing spaces and periods in path components Date: Tue, 17 Nov 2020 14:05:54 +0100 Message-Id: <20201117122115.221452982@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122111.018425544@linuxfoundation.org> References: <20201117122111.018425544@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Boris Protopopov commit 57c176074057531b249cf522d90c22313fa74b0b upstream. When converting trailing spaces and periods in paths, do so for every component of the path, not just the last component. If the conversion is not done for every path component, then subsequent operations in directories with trailing spaces or periods (e.g. create(), mkdir()) will fail with ENOENT. This is because on the server, the directory will have a special symbol in its name, and the client needs to provide the same. Signed-off-by: Boris Protopopov Acked-by: Ronnie Sahlberg Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/cifs/cifs_unicode.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/fs/cifs/cifs_unicode.c +++ b/fs/cifs/cifs_unicode.c @@ -501,7 +501,13 @@ cifsConvertToUTF16(__le16 *target, const else if (map_chars == SFM_MAP_UNI_RSVD) { bool end_of_string; - if (i == srclen - 1) + /** + * Remap spaces and periods found at the end of every + * component of the path. The special cases of '.' and + * '..' do not need to be dealt with explicitly because + * they are addressed in namei.c:link_path_walk(). + **/ + if ((i == srclen - 1) || (source[i+1] == '\\')) end_of_string = true; else end_of_string = false;