4 ms·
I believe this spec is incompatible with the Linux kernel page cache. Imagine this scenario: Someone plugs in a U2F microcontroller and copies a new U2F file
by londons_explore 6y ago
I believe this spec is incompatible with the Linux kernel page cache.
Imagine this scenario:
Someone plugs in a U2F microcontroller and copies a new U2F file to it.
The fat filesystem driver can pick any 512 byte sectors to save the data on. There is no guarantee they are contiguous.
Any 512 byte sector written involves reading a 4k page to populate the page cache.
It is possible for a 4k page to have a mix of 512 byte sectors that are part of the newly written file and those from the current.U2F from the device.
The page cache is written out in an arbitrary order.
When that page containing a mix of sectors is written out to the device, it will become flashed with a mix of the new and old firmware images, and won't work properly.
- detaro 6y agoThe device does not allow reading of flashed data, so this can't happen. When it reads, it reads a static file system image of blocks that do not match the pattern, which it'll write into a black hole.
- londons_explore 6y agoWhat's CURRENT.U2F then?
- detaro 6y agoOk, yes, if that's not 4k aligned & padded you could read data from that (otherwise the OS wouldn't load something from it to then write data to the same blocks) - I had somehow missed that on rereading. But even then it's not in the U2F block format, so you'd have to randomly have a block in your firmware that matches the format correctly for that bug to trigger.
- londons_explore 6y agoI was under the impression that this is in the U2F block format to allow users to copy the file off one microcontroller and onto another...
- mPReDiToR 6y agoAhh,"randomly". Frustratingly often correlates with something Mr Sod said which turned into a Law.
- jepler 6y agoThat's a good point, but in practice, it works fine on Linux. It looks like the static content of the disk, including CURRENT.UF2, is all at the start, so the only time you could have a mix of CURRENT.UF2 content and the uploaded uf2 in a single page cache entry would be the very last of CURRENT.UF2 and the very start of the new flash content. I'm tempted to wave my hands and say that will work out fine (since that content would be overwritten again when reaching the end of the uploaded uf2) but it does seem like a potential problem and it would be nice to know why it's okay..