Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3852256pxb; Tue, 17 Nov 2020 05:24:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzH7PPXTxO/i9R+4DxU6445JKPzrz5r2L22Bw74hpEgQ3BmiY8ZEdSPlrZwJt00DOyUIdhh X-Received: by 2002:a17:906:5e52:: with SMTP id b18mr13600447eju.39.1605619487200; Tue, 17 Nov 2020 05:24:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605619487; cv=none; d=google.com; s=arc-20160816; b=RGBwm8PuqzaR4aLOlTGc1KHQUEn+ZkbV1UslTkttDlAyfdf7io99pO8Zl+Fj0upxuF xcAJdziFBb1B2bAZrYmr6wqoAUWugJKIpdO1zLkSbsAQof8tHBeHzPRpNhbfUHv493MO 2o6MH3rqZytEnRnT3m++kM6sfEkqXW24Ehf4FLIpzZRkbS6H014nInqWU9dD9dI3Q7V+ t9rOow6XV1fkYejvlxOPq+C5XAMLPVmDGscJPN3Yb2zy2tmROtMC56VqTu+BXwDhxrst XxUPWRggGsyePqJqNimDxKWuCjbLSDL4Fwr5769OK6+oUTIS7MuyrSUoFmkkvOt4SrT7 QYvA== 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=mU9MipdMVl+5gqlMcGn3cM2aYFQVVMcTpi/qZ4FvNUWfIlZTb34tKCAGRzwFxB4syT SPBjw30CUgniV+bqbvEbBh+suXozWFLQJ4M7J+pJgCtwqwofS6y9unKdbuP3uZuqqM38 kLGr6gqL7TbV5jCnnX4Y+GftHjEWaGm+xob4jBGe3oGqt5PcKse1PtSqucLlz42JQHrt RJ39Gloi8C7Te7SwYOqJ9bXmxUnZNavRrpP4++84ZRmUY/OG2neDo/2hGWuMQ43x7pzl Bzd7JCsgi76rt8pvMJlImi3GWCByKhedjRMF2AVmHwABMIAEi4BDykjFFbnmt6m22Y9h 5zEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qZqG0p65; 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 i5si14358717edn.310.2020.11.17.05.24.24; Tue, 17 Nov 2020 05:24:47 -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=qZqG0p65; 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 S1731138AbgKQNWO (ORCPT + 99 others); Tue, 17 Nov 2020 08:22:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:56190 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730896AbgKQNWB (ORCPT ); Tue, 17 Nov 2020 08:22:01 -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 C9BB424631; Tue, 17 Nov 2020 13:21:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619320; bh=xkxCDZrvI81kovN52nHtM7xfGI8a26IvSOwrGz1V8sQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qZqG0p653dgdkwRhb+TzglgL0weSYwgKS1QMxYsy+1RcnZUgP6rH67FH2+Qgfs+dF GgYx/F0vKwWN+f0ut4oOKxUvAyzlN006DnxtP2NkNRrmrnrBWHyrXmaoQ1qW+cjWMI SRN5oF8xDrlJQOWKU5gxRhJoSwyAWjeqnLm7oErg= 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.19 101/101] Convert trailing spaces and periods in path components Date: Tue, 17 Nov 2020 14:06:08 +0100 Message-Id: <20201117122118.051942361@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122113.128215851@linuxfoundation.org> References: <20201117122113.128215851@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;