References: <20210312141003.819108-1-groug@kaod.org> <20210312141003.819108-4-groug@kaod.org> From: Connor Kuehl Message-ID: Date: Fri, 12 Mar 2021 09:13:54 -0600 MIME-Version: 1.0 In-Reply-To: <20210312141003.819108-4-groug@kaod.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Virtio-fs] [PATCH 3/3] virtiofsd: Don't allow empty filenames List-Id: Development discussions about virtio-fs List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz , qemu-devel@nongnu.org Cc: virtio-fs@redhat.com On 3/12/21 8:10 AM, Greg Kurz wrote: > POSIX.1-2017 clearly stipulates that empty filenames aren't > allowed ([1] and [2]). Since virtiofsd is supposed to mirror > the host file system hierarchy and the host can be assumed to > be linux, we don't really expect clients to pass requests with > an empty path in it. If they do so anyway, this would eventually > cause an error when trying to create/lookup the actual inode > on the underlying POSIX filesystem. But this could still confuse > some code that wouldn't be ready to cope with this. > > Filter out empty names coming from the client at the top level, > so that the rest doesn't have to care about it. This is done > everywhere we already call is_safe_path_component(), but > in a separate helper since the usual error for empty path > names is ENOENT instead of EINVAL. > > [1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_170 > [2] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13 > > Signed-off-by: Greg Kurz Reviewed-by: Connor Kuehl