'Urgent data corruption issue' destroys filesystems in Linux 4.14

First reported last week by developer Pavel Goran, the problem struck bcache, a tool that lets one use a solid state disk drive as a read/write cache for another drive. bcache is often used to store data from a slow disk on faster media.

Goran noticed the problem after trying to upgrade Gentoo from version 4.13 of the Linux kernel to version 4.14. During that effort he noticed “reads from the bcache device produce different data in 4.14 and 4.13.”

After plenty of analysis, he concluded that “this looks like a very serious bug that can corrupt or completely destroy the data on bcache devices.

Others agreed with Goran, as his report quickly made its way onto the Gentoo bugs list and was later identified as having the following cause:

A new field was introduced in 74d46992e0d9, bi_partno, instead of using bdev->bd_contains and encoding the partition information in the bi_bdev field. __bio_clone_fast was changed to copy the disk information, but not the partition information. At minimum, this regressed bcache and caused data corruption.

A fix has since been implemented and will appear in Linux 4.14.1 and eventually Linux 4.15, which is due in about two months. ®