[Bug 288266] maybe rm -rf or getdirentries() should suppress names containing "/"

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 16 Jul 2025 18:43:48 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=288266

            Bug ID: 288266
           Summary: maybe rm -rf or getdirentries() should suppress names
                    containing "/"
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: rtm@lcs.mit.edu

Created attachment 262210
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=262210&action=edit
FAT file system with a file named "/."

I've attached a FAT file system in which directory d/ contains a
file whose name is "/.". This causes rm -rf and find to be confused --
they follow "/." into the real root directory, doing something like

  cd /mnt/d
  ls
  cd /.
  ...

So here's a way to rm -rf your root disk:

# mdconfig -f fat15a.img
# mount_msdosfs /dev/md0 /mnt
# rm -rf /mnt/d

This is arguably not what one would expect.

-- 
You are receiving this mail because:
You are the assignee for the bug.