Files
twx-linux/fs
Nikolay Borisov e1994e4d56 btrfs: Fix use-after-free when cleaning up fs_devs with a single stale device
commit fd649f10c3 upstream.

Commit 4fde46f0cc ("Btrfs: free the stale device") introduced
btrfs_free_stale_device which iterates the device lists for all
registered btrfs filesystems and deletes those devices which aren't
mounted. In a btrfs_devices structure has only 1 device attached to it
and it is unused then btrfs_free_stale_devices will proceed to also free
the btrfs_fs_devices struct itself. Currently this leads to a use after
free since list_for_each_entry will try to perform a check on the
already freed memory to see if it has to terminate the loop.

The fix is to use 'break' when we know we are freeing the current
fs_devs.

Fixes: 4fde46f0cc ("Btrfs: free the stale device")
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-22 09:23:32 +01:00
..
…
2017-12-20 10:04:56 +01:00
…
…
2017-08-06 19:19:42 -07:00
…
…
2017-11-30 08:37:20 +00:00
2017-06-14 13:16:24 +02:00
2018-02-25 11:03:50 +01:00
…
2017-08-06 19:19:42 -07:00
…
…
2017-12-20 10:05:00 +01:00
…
…
…
2017-06-14 13:16:24 +02:00
…
…
…
…
…
…
…
…
…
…
…
2017-06-14 13:16:24 +02:00
2018-02-16 20:09:43 +01:00
…
…
2017-06-14 13:16:24 +02:00
…
…