On Wed, 2016-09-07 at 11:06 -0400, Austin S. Hemmelgarn wrote: > This is an issue with any filesystem, Not really... any other filesystem I'd know (not sure about ZFS) keeps working when there are UUID collisions... or at least it won't cause arbitrary corruptions, which then in the end may even be used for such attacks as described in that thread.
Even other multi-device containers (LVM, MD) don't at least corrupt your data like it allegedly can happen with btrfs. > it is just a bigger issue with > BTRFS. No corruption vs. possible arbitrary data corruption and leakage seems to be more than "just bigger". I'd call it unacceptable for a production system. > Take a system using ext4, or XFS, or almost any other Linux > filesystem, running almost any major distro, create a minimum sized > partition on the disk for that filesystem type, and create a > filesystem > there with the same UUID as the root filesystem. Next time that > system > reboots, things will usually blow up (XFS will refuse to mount, ext4 > and > most other filesystems will work sometimes and not others). Well but that's something completely different. It would be perfectly fine if, in case of an UUID collision, the system simply denies mounting/assembly (actually that's one of the solutions others and I've proposed in the aforementioned thread). But it's not acceptable if the system does *something* in such situation,... or if such fs/container is already mounted/active and another device with colliding UUID appears *then*, it's neither acceptable that the already active fs/container wouldn't continue to work properly. And that seems to my experience just how e.g. LVM handles this. "Not booting" is not really an issue in terms of data corruption. At least I'm pretty sure to remember that one of the main developers (was it Qu?) acknowledged these issues (both in terms of accidental corruption and security wise) and that he was glad that these issues were brought up and that they should be solved. > It hasn't, because there's not any way it can be completely > fixed. Why not? As it was laid out by myself and others, the basic solution would be: - Refuse any mounting in case UUID collisions are detected. - Generally don't do any auto-rebuilds or e.g. RAID assemblies unless specifically allowed/configured by the user (as this might also be used to extract data from a system). - If there are any collisions (either by mounting or by processes like rebuilds/added devices) require the user to specify uniquely which device he actually wants (e.g. by path). - And in case a filesystem is already mounted and UUID collisions happens then (e.g. a dd clone get's plugged in), continue to use the already active device... just as e.g. LVM does. > This > particular case is an excellent example of why it's so hard to > fix. To > close this particular hole, BTRFS itself would have to become aware > of > whether whoever is running an ioctl is running in a chroot or not, > which > is non-trivial to determine to begin with, and even harder when you > factor in the fact that chroot() is a VFS level thing, not a > underlying > filesystem thing, while ioctls are much lower level. Isn't it simply enough to: - know which blockdevices with a btrfs and with which UUIDs there are - let userland tools deny any mount/assembly/etc. actions in case of collisions - do the actual addressing of devices via the device path (so that proper devices will continued to be if the fs was already mounted when a collision occurs) ? And further, as I've said, security wise auto-assembly of multi-device seems always prone to attacks at least in certain use cases, so for the security conscious people: - Don't do auto-assembly/rebuild/etc. based on scanning for UUID - Let the user choose to do this manually via specifying the devices (via e.g. path). So a user could say something like mount -t btrfs -o device=/dev/disk/by-path/pci-0000\:00\:1f.2-ata-1,device=/dev/disk/by-path/pci-0000\:00\:2f.2-ata-2 /foo in order to be sure that just these devices would be *tried* to be used for the RAID1 btrfs, and not the one an attacker might have plugged into the USB. > That said, nobody's really done any work on mitigating the issues > either, although David Sterba has commented about having interest in > fixing issues caused by crafted filesystem images, so hopefully > things will start moving more in the direction of proper security. Well that's good do hear... it's IMO one of the bigger potential issues in btrfs, next to the ongoing stability problems[0] and still not really working RAID. Anyone working on this should probably have a look at the thread I've mentioned, cause there are really several tricky ways one could exploit this... to me especially any auto-(i.e. based on scanning for UUIDs)- assembly/rebuilding and that like seemed to pose quite a big surface. Cheers, Chris. [0] Though I must say that I personally have never had any problems or corruptions thus far, even in case of system crashes :)
smime.p7s
Description: S/MIME cryptographic signature