Project

General

Profile

Actions

Bug #3316

open

hammer2_dirent_create() allows creating >1 dirents with the same name

Added by tkusumi almost 2 years ago. Updated almost 2 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Start date:
06/05/2022
Due date:
% Done:

0%

Estimated time:

Description

When creating a file/directory in HAMMER2, hammer2_dirent_create() scans lhc of a given name if a chain or ondisk blockref already exists. If it exists, the function assigns a different (incremented) lhc value. This ends up allowing two or more inodes with the same dirent name under the same directory.

Note that some (or many) filesystem implementation scans its parent directory contents and return EEXIST if the same name already exists.

In reality, VFS prevents this via name lookup and returns EEXIST before it reaches there. But if a program runs HAMMER2 without VFS on top of it, namely makefs(8), this can not be prevented.

In fact below diff creates an image containing two entities (different inode#, different blockref key, but same name and data) of each regular file in the source directory.
https://leaf.dragonflybsd.org/~tkusumi/diff/makefs_hammer2_dup_regfile.patch

Actions #1

Updated by dillon almost 2 years ago

The directory hash collision space does not guarantee name uniqueness, so the iterator is there on purpose to deal with hash collisions (names might be different, but key calculates to the same value). Higher levels are responsible for ensuring that name duplication is disallowed.

There is a second reason here too... even though it isn't in the filesystem (yet), the multi-master quorum algorithm has to be able to synchronize valid entries even in the presence of invalid entries, so it is possible for two entries to exist on the media for the same filename where one has quorum and the other does not. Temporarily (the one without quorum would eventually be deleted).

So I don't think this is a bug per-say.

-Matt

Actions

Also available in: Atom PDF