NetBSD Problem Report #59076
From triaxx@netbsd.org Fri Feb 14 22:00:26 2025
Return-Path: <triaxx@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits)
client-signature RSA-PSS (2048 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id C6AF21A923C
for <gnats-bugs@gnats.NetBSD.org>; Fri, 14 Feb 2025 22:00:25 +0000 (UTC)
Message-Id: <20250214220024.A7FFF1A923D@mollari.NetBSD.org>
Date: Fri, 14 Feb 2025 22:00:24 +0000 (UTC)
From: triaxx@netbsd.org
Reply-To: triaxx@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: File is silently removed when renaming on msdos filesystem when mounted with -l
X-Send-Pr-Version: 3.95
>Number: 59076
>Category: kern
>Synopsis: File is silently removed when renaming on msdos filesystem when mounted with -l
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Feb 14 22:05:00 +0000 2025
>Last-Modified: Fri Feb 14 23:05:01 +0000 2025
>Originator: Frédéric Fauberteau
>Release: NetBSD 10.1
>Organization:
>Environment:
System: NetBSD goliath.triaxx.org 10.99.12 NetBSD 10.99.12 (GENERIC) #0: Mon Feb 10 00:52:25 CET 2025 triaxx@goliath.triaxx.org:/usr/obj/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
I have a msdos filesystem mounted with:
# mount -tmsdos -orw,-U,-l,-M755,-m644
I try to rename a file from uppercase to lowercase:
# cd /mnt/boot/EFI/NETBSD
# mv BOOT.CFG boot.cfg
The file BOOT.CFG is silently removed.
>How-To-Repeat:
# touch BOOT.CFG && mv BOOT.CFG boot.cfg
>Fix:
>Audit-Trail:
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: kern/59076: File is silently removed when renaming on msdos
filesystem when mounted with -l
Date: Fri, 14 Feb 2025 23:00:43 +0000
On Fri, Feb 14, 2025 at 10:05:00PM +0000, triaxx@netbsd.org wrote:
> I have a msdos filesystem mounted with:
> # mount -tmsdos -orw,-U,-l,-M755,-m644
>
> I try to rename a file from uppercase to lowercase:
> # cd /mnt/boot/EFI/NETBSD
> # mv BOOT.CFG boot.cfg
>
> The file BOOT.CFG is silently removed.
So the reason for this is that rename checks for whether you're trying
to rename a file over itself, and unless you enable the POSIX_MISTAKE
version it does this by examining the filename with memcmp.
So on all case-insensitive, case-folding, unicode-normalizing, etc.
filesystems it will sometimes get wrong answers, not engage the
special-case logic that protects against this behavior, and delete the
file.
The logic in question is at line 309 of genfs_rename.c:
else if ((fdvp == tdvp) &&
(fcnp->cn_namelen == tcnp->cn_namelen) &&
(memcmp(fcnp->cn_nameptr, tcnp->cn_nameptr,
fcnp->cn_namelen) == 0))
/* Renaming an entry over itself does nothing. */
error = 0;
This needs to be able to call a fs-specific compare function instead.
Which is going to be a right pain, I think. The only real way to do it
is to add a name compare function to some ops table; the main question
I think is whether to add it to genfs_rename_ops (sufficient to deal
with this problem) or put it in struct vfsops where it can be used in
other contexts.
I'm worried what kind of silly things the namecache might get up to
without also having this hook, especially given that everything
relating to invalidation and housekeeping in the namecache is very
squirrelly.
--
David A. Holland
dholland@netbsd.org
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.