How I learned to stop worrying and yank the USB - Taylor R Campbell - EuroBSDcon 2022

preview_player
Показать описание
There's a whole lot of device driver code out there that works so long as the
device stays plugged in. But some devices, such as USB devices, can be removed while in use. This is a common cause of crashes on BSD systems. How can we make the operating system gracefully handle device removal?

This talk will discuss problems and race conditions we found in the NetBSD
driver framework, how we've adapted the APIs to address them, and strategies for making device drivers robust to devices suddenly disappearing.
Рекомендации по теме
Комментарии
Автор

Isn't the title of this talk quite misleading?
I mean, sure, it's great when physically yanking an USB device doesn't corrupt internal kernel state (which in the worst case might crash the kernel or even lead to kernel vulnerabilities), and this is what the talk is all about. Seems to me, that's fair enough as far as it goes.
However, there is another reason why just yanking an USB disk device is not such a great idea. Even if internal kernel state, open(2), read(2), write(2), ioctl(2) and close(2) are all handled correctly, data on the USB device may still be corrupt if unmount(2) is not called on the file system, in the worst case leading to data loss in files in the file system or even in file system corruption. The reason is that file system code does not necessarily write all transactions to the disk before returning from write(2) to the application program but may cache such changes in the kernel to collect them for more efficient physical disk I/O. Such data cached by the kernel file system code may still get lost.
Or are you saying that your new d_close functions do the equivalent of unmount(2) for mass storage devices? Naively, that would look like a layering violation causing considerable complexity - and possibly fragility?

So i suspect you still need to engage your brain and not just "stop worrying and yank mounted USB file systems", right?
Or what am i missing here?

IngoSchwarze
Автор

I wondered why he was nearly impossible to understand... And then saw that he's wearing a mask 🤣

ericgillespie