diff options
| author | Nikolay Borisov <[email protected]> | 2018-01-30 14:07:37 +0000 |
|---|---|---|
| committer | David Sterba <[email protected]> | 2018-02-05 16:15:14 +0000 |
| commit | fd649f10c3d21ee9d7542c609f29978bdf73ab94 (patch) | |
| tree | a79f74afd161f3b51f6016ad806a60c89e9c2e20 /net/unix/af_unix.c | |
| parent | Btrfs: fix null pointer dereference when replacing missing device (diff) | |
| download | kernel-fd649f10c3d21ee9d7542c609f29978bdf73ab94.tar.gz kernel-fd649f10c3d21ee9d7542c609f29978bdf73ab94.zip | |
btrfs: Fix use-after-free when cleaning up fs_devs with a single stale device
Commit 4fde46f0cc71 ("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: 4fde46f0cc71 ("Btrfs: free the stale device")
Signed-off-by: Nikolay Borisov <[email protected]>
Reviewed-by: Anand Jain <[email protected]>
Signed-off-by: David Sterba <[email protected]>
Diffstat (limited to 'net/unix/af_unix.c')
0 files changed, 0 insertions, 0 deletions
