Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1509443pxb; Fri, 1 Oct 2021 12:11:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtkN+kGrtrFiJ0ublQv/GIVjzrIjw1cj7yV4O6HuYrqEdV6IzG+BdvBxyLY/EGljSfJzTj X-Received: by 2002:a05:6a00:d:b0:44c:bf1:36fb with SMTP id h13-20020a056a00000d00b0044c0bf136fbmr7140767pfk.85.1633115467116; Fri, 01 Oct 2021 12:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633115467; cv=none; d=google.com; s=arc-20160816; b=vSL82lQdv1BDqncwxuPq3SJuL5Ub2o3Cu7n79QXvu8Ro6S3gwDNU8/CJaR4X/zhLuI hunTuzpc1SDfsjbNLqvFhZxlRyKV1IJPenTpKVPHaaaMZSSJEsZf+YlJRezvaUIe8XLp TWfWRoPhPhiI0Vexvgy4gG9lPS5sq/uiEv98Ug66z92ANwaXxYBER9C1fGVUuf09W7ws fZjNyXxcnxQxnUWRyoWNzyjHOxa9KEKyhNCunDn05PcEYRQGb/mQWvomo12QBUfFRqRI f0CERAY4wxtH20MkqX/ZSyAfXkwCTTlQQqT+I0J7z9eV7PyE5WgghJYA3yLfsDkIJ+w9 mObA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=rgAJAKacPUJvPZSMc+bBd8ALP3a7v5i8czbiThcnzzc=; b=W1iyddKMuYMjzP49OiXvAIYlZGo0X0txeIKzRliC4TghH1D2zYajEWy5Ed8sfw3u7+ 8S0qXTcy8z8obJESMloPDK/wf1dZo9Fo/uFoN/apxZYlwTPtTtZxtjSARmCdQE/3x500 vSl4BQ+03G95dePZ6FguEmBhlj4wjNU/OLozwM/Kv2MCQ6MbcS/1dYvCVfUTzRLmQqFk /fnK28Z5HpOA1/0XFheZ/5Asj3WHu1jjVeB0eh4Ikd0FTCLgNMVeiv5R+98e7RQkiEt1 iUAhK9952y8JRFR4M/INEQRtkFoxgnWiCPLQkTDH6LmqARry6DxCd+bdj3U3SokXXRC9 Lv/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si9247304pls.163.2021.10.01.12.10.53; Fri, 01 Oct 2021 12:11:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354645AbhJASnq (ORCPT + 99 others); Fri, 1 Oct 2021 14:43:46 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:35368 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231826AbhJASn2 (ORCPT ); Fri, 1 Oct 2021 14:43:28 -0400 Received: from cwcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 191IfVMf008675 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 1 Oct 2021 14:41:32 -0400 Received: by cwcc.thunk.org (Postfix, from userid 15806) id ABED215C34AA; Fri, 1 Oct 2021 14:41:31 -0400 (EDT) Date: Fri, 1 Oct 2021 14:41:31 -0400 From: "Theodore Ts'o" To: Shreeya Patel Cc: viro@zeniv.linux.org.uk, adilger.kernel@dilger.ca, krisman@collabora.com, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: Re: [PATCH 2/2] fs: ext4: Fix the inconsistent name exposed by /proc/self/cwd Message-ID: References: <8402d1c99877a4fcb152de71005fa9cfb25d86a8.1632909358.git.shreeya.patel@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8402d1c99877a4fcb152de71005fa9cfb25d86a8.1632909358.git.shreeya.patel@collabora.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, Sep 29, 2021 at 04:23:39PM +0530, Shreeya Patel wrote: > /proc/self/cwd is a symlink created by the kernel that uses whatever > name the dentry has in the dcache. Since the dcache is populated only > on the first lookup, with the string used in that lookup, cwd will > have an unexpected case, depending on how the data was first looked-up > in a case-insesitive filesystem. > > Steps to reproduce :- > > root@test-box:/src# mkdir insensitive/foo > root@test-box:/src# cd insensitive/FOO > root@test-box:/src/insensitive/FOO# ls -l /proc/self/cwd > lrwxrwxrwx 1 root root /proc/self/cwd -> /src/insensitive/FOO > > root@test-box:/src/insensitive/FOO# cd ../fOo > root@test-box:/src/insensitive/fOo# ls -l /proc/self/cwd > lrwxrwxrwx 1 root root /proc/self/cwd -> /src/insensitive/FOO > > Above example shows that 'FOO' was the name used on first lookup here and > it is stored in dcache instead of the original name 'foo'. This results > in inconsistent name exposed by /proc/self/cwd since it uses the name > stored in dcache. > > To avoid the above inconsistent name issue, handle the inexact-match string > ( a string which is not a byte to byte match, but is an equivalent > unicode string ) case in ext4_lookup which would store the original name > in dcache using d_add_ci instead of the inexact-match string name. I'm not sure this is a problem. /proc//cwd just needs to point at the current working directory for the process. Why do we care whether it matches the case that was stored on disk? Whether we use /src/insensitive/FOO, or /src/insensitive/Foo, or /src/insensitive/foo, all of these will reach the cwd for that process. - Ted