[btrfs] is vulnerable to a hash-DoS attack
crypto.junod.info
crypto.junod.info
This whole article smells of grandstanding.
This attack can easily be used to disrupt systems. I can imagine every naive implementation of file upload out there being vulnerable to this. When the system goes to delete old uploaded files, it halts.
I'm not sure how "making deletes take a long time" is not a DoS attack.
Since the system would try to read the trash data, this was a problem.
I was looking at the btrfs documentation the other day and noticed that (1) it behaves worse when space runs out than ext4 does, and (2) there's no accurate way to measure free space on a btrfs volume so it's hard to avoid running out of space.
Whatever benefits btrfs has is erased if you have to deal with wrecked and full filesystems all the time.
These design decisions are not made light heartedly.
I was annoyed: How would you free space if you can't remove anything. There wasn't any snapshot of those files, but I was able to free space by removing another snapshot (which I wanted to keep, but never mind...).
See http://www.cs.stonybrook.edu/~xcai/races2.pdf and some of its references.
Also, looking at his numbers, btrfs is doing something very wrong, over simple hash collisions. A file system which takes over 5 seconds to make 61 files is simply broken (in this situation, not making general comments about btrfs).
However, it's worth noting that these sorts of attacks can give privilege escalation, not just DoS.
>Also, changing hash, unless done with care, will cause compatibility issues.
I'm not calling you out, but I'm interested in what kinds of compatibility issues you're thinking of?
* First off, btrfs does not use "hash tables". Instead, it uses hashes to create keys that index into B-Trees. The problem is that hash collisions are not handled with an efficient approach. btrfs is forced to do a lot of work to deal with these collisions.
* ZFS uses two distinct data structures to represent the contents of a directory: the so-called "micro-ZAP" and the so-called "fat-ZAP"
micro-ZAPs are for small directories. This is OK as the number of collisions is limited by the relatively small size of the micro-ZAP.
fat-ZAPs are like on-disk extensible hash-tables.
They both use CRC64, I think that fat-ZAPs might have a problem.
I'm generally a big btrfs fan, but here it seems like they got caught due to a senseless overoptimization...
Basically, this just smells like a premature optimization to me. If it were my project and lacked the hashing feature, and someone wanted to add it, I'd really want to see some numbers before accepting it.
I am not an expert on file systems, but have you thought about the following:
- using file names in disk blocks rather than file name hashes means fewer entries per disk block. That, in turn, changes the constant of your B-tree traversal.
- with variable-length keys, keeping your B-trees balanced is tricky, if not practically impossible.
EDIT: disadvantage of using hashes would be that you need to read the filename proper (with small hashes, you cannot ignore hash collisions). That would be an extra I/O. So I guess this would not be beneficial for small directories. Maybe you could start out by having in-block hashes amd filenames and only move the names to a separate block when you need a second block?
Four bytes of the name will have less entropy than such data, and having part of the filename around will not help making sure that a matching hash implies a matching filename.
Can you give explain this or give a name of a filesystem doing this?