Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3882729pxb; Tue, 17 Nov 2020 06:08:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJwYuYy/csZdU2GxKDLoXY9tjaurIT9QQah/uN0psrgrvwJeNrySXw13iuCt7Dxw5gMmZ72h X-Received: by 2002:a1c:e3d4:: with SMTP id a203mr4825174wmh.177.1605622117340; Tue, 17 Nov 2020 06:08:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605622117; cv=none; d=google.com; s=arc-20160816; b=vqXrEzT7pSNrB/TWhsHQ42o+b3i8poSbfscCWDpPwxdlQzTogwlPBg/671cSpfXXFS RkC77lUL2ZPGhxzZD1MofpgoEeXC+iEDxd4QGz9Irq71RcYKfDwy6b26x2o4gzjo7C0A xhWzkw1PM9GVaxSnzCY/8kZhO4UmQHK+uxys9OwbaL5agKNhDX9ARelVlw4JsOiMUCC8 bYCGXNyvnNjpH5vvhPR764tKMZqax7D9fnfns2WNrzPq3/eakJMfpyf3mOmbYV3NOvVR uiKRGsEbwoZcO+C6avT8cYZU7gQR6/IqhadUhiVsfEdpFDDilQVci4YvmIkh2t76ElHZ Ed0w== 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=NlvhuOfyVp0GEug0SI15AIhQRgMS7BU0ibCf+zhG9Js=; b=XIuZ9rwaWe+K/O69+qYn/xOBPPPsxGJyMJ/ekJLBZJ+fASr9EWAKblWQ3X9jQDD1EH j24Xpkr/puwyUpvpWbKw7YS9lA6z0yMR6HxhHUS5OvhYIIzvxJ65qbChJiheDJzhyQas 36UDel39hT5SoefNBW+BEJcMbll6DsQmoPsCUnwTSA0vI3xLin2Rjjag7UvQV5wAzOWt +l2q5NhSo9jzuqtTSyalzSN2ROCdWdotEfo9YvBJs+03SBwtt/kUf7N+BF8w3aTduqH+ 8w9+nD+Td5ggJ3y66h1J0PfSTThW8KAvDx8PynmpyHaX2rKgQhw0kfem4Ior/tR5nwu+ pOqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hNIcb1xf; 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 bx4si13971077edb.505.2020.11.17.06.08.13; Tue, 17 Nov 2020 06:08:37 -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=hNIcb1xf; 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 S1729243AbgKQOFS (ORCPT + 99 others); Tue, 17 Nov 2020 09:05:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:38142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729396AbgKQNJM (ORCPT ); Tue, 17 Nov 2020 08:09:12 -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 EE741246C0; Tue, 17 Nov 2020 13:09:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605618551; bh=9k1GzaQskuGl5Gm1SQOBqk+VcyKLvXW2BgKdbA76bUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hNIcb1xfd1MAw4djjNs6JIPlMdtGXmCFDo+9lFTTLk4SoSdfzU+/r8duTrfxG75wh kLnn5WDl68BPyuk0navJ5+pT4jCFbYsVWLEDte3v7Yetirh/7la1Q7WsL72hsnSQYs M/K8lx4dL00xEMRou3YDrqYu5VAwo5/QGilv8dQo= 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.4 64/64] Convert trailing spaces and periods in path components Date: Tue, 17 Nov 2020 14:05:27 +0100 Message-Id: <20201117122109.332079931@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122106.144800239@linuxfoundation.org> References: <20201117122106.144800239@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 @@ -493,7 +493,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;