Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3867323pxb; Tue, 17 Nov 2020 05:46:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwbVaIfMW/szRUcTKSGsn2FuBS/Y5yXtwEZfkUL/RB4gs+PKeUKe/Qn1ISq6sEd09F4Tfc X-Received: by 2002:a17:906:1253:: with SMTP id u19mr18951670eja.288.1605620802892; Tue, 17 Nov 2020 05:46:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605620802; cv=none; d=google.com; s=arc-20160816; b=OTVhXRcnJ1j+A6e7+WBHNT/an+xKs0hpFpxPWszyMKzZ3cT3kRYLFKBa+dzii6SpWr NZplB1f+6k/0ELf1GJfAQEJBvLlEBcdK4TMZsFALI8wB2wm0lLCR9Evx38BVR4I9eIzr xWmxnrYFZDzw5nsZAQCw1uqlYWvmn5PgaHl0VG055hZTg9WPSlwRprJrITdbI3cLk2MS zVeHu7n3DnytUAwMMd+6nYFrab7tj+rZyItfBQGvVVbacqv6X6L9NEz4erYlQQhwlx+p l1vu/MocutJXG+U83c1eQeePp/AJobMoMy0q975HfSkJwZVs5mclZ/Jux2wy42XlcYDc H89Q== 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=vG3GiJ/ne6Rxa6J8wgzlzTafEphHxSxCIc77Tgfy6u4=; b=xTwL9qCbZFStEcAeAgExR4pz/p4E2jtNcve9HdIZR14WSSXhXEfVrhCVeZJtKSdTXm Y0ukpprubhz+5N/z1EbwzVxm/w2ktYOS41uNcTgtXevwxsOykEE0Dy7ewZw4MFmt00GT /Am0y1ZMgtpwXoEDcXwExBFYMOmLlA7BU5VEG48aOMBDezyKt2R2UZu+787JG5rWpzT2 IRWL4+k7unaY5TZE7QIErm20wbMDFS1Qx3pmW26iGPxqLUfjRGtMs/wWSLQ5F5yj4Eii ES+EW4Dzovv7iPEIQEW7KzW+wvGPN7Oupuq7q+pK4wDHAuC0fOV9ft6DduOnZ+siPuyJ 8h4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f4M1c50m; 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 j90si14067086edc.189.2020.11.17.05.46.19; Tue, 17 Nov 2020 05:46:42 -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=f4M1c50m; 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 S2387494AbgKQNm5 (ORCPT + 99 others); Tue, 17 Nov 2020 08:42:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:55484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387468AbgKQNmr (ORCPT ); Tue, 17 Nov 2020 08:42:47 -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 1B9902468D; Tue, 17 Nov 2020 13:42:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605620566; bh=lGTBwaOLzltDInUOiWY9XHnOqmHWlpFXn63vO0PF/mo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f4M1c50mmf71jQVIAsPi8MD+8RZSZQjtUJiG3eyfaBRnpBa3LniABGE6Rw8FzO4yo a3xNedPFnW7ply2fpr75JN6kdoQ3a60ujAakYN60NX9ylHPqmW/qw1GJYeBRNLGJZG 9Ldqld3ijQoAYimXYaQa+Z/BlFoejRJdiwbYPILc= 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 5.9 255/255] Convert trailing spaces and periods in path components Date: Tue, 17 Nov 2020 14:06:35 +0100 Message-Id: <20201117122151.335452495@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122138.925150709@linuxfoundation.org> References: <20201117122138.925150709@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 @@ -488,7 +488,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;