[haiku-bugs] Re: [Haiku] #10336: TRIM / fstrim can destroy data on SSD's when executed

  • From: "Haiku" <trac@xxxxxxxxxxxx>
  • To: undisclosed-recipients: ;
  • Date: Mon, 18 Jan 2021 18:36:19 -0000

#10336: TRIM / fstrim can destroy data on SSD's when executed
---------------------------+----------------------------
  Reporter:  kallisti5     |      Owner:  axeld
      Type:  bug           |     Status:  in-progress
  Priority:  high          |  Milestone:  Unscheduled
 Component:  Drivers/Disk  |    Version:  R1/Development
Resolution:                |   Keywords:  TRIM fstrim
Blocked By:                |   Blocking:
  Platform:  All           |
---------------------------+----------------------------
Comment (by pulkomandy):

 I'm looking at the fstrim sourecode and I'm wondering... @kallisti5, do
 you remember how you used it?

 It appears fstrim just opens a path and sends a B_TRIM_DEVICE for the
 range 0 to uint64_max. Apparently, if you do that on the mount point
 (fstrim /boot), the ioctl will be handled by bfs, which will then trim
 only the relevant parts of the underlying disk partition. However, if you
 run it on the disk device (fstrim /dev/disk/...), it will bypass the
 filesystem part, and simply erase the whole partition. Combined with the
 previous bug (see my above comments), it would in fact erase the start of
 the disk, for a size equal to the partition size.

 Is there any chance that's what you tried when you ended up with a
 completely erased disk?

 Probably we should guard against that?
-- 
Ticket URL: <https://dev.haiku-os.org/ticket/10336#comment:61>
Haiku <https://dev.haiku-os.org>
The Haiku operating system.

Other related posts: