* [PATCH] btrfs-progs: fix double free during scanning
@ 2015-10-02 15:49 David Sterba
0 siblings, 0 replies; only message in thread
From: David Sterba @ 2015-10-02 15:49 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
If there are different devices mounted to the same directory we can run
into double free issue in the scanning code and this can lead to a
crash. The dev_info_arg buffer allocation get_fs_info might be skipped,
eg. if the FS_INFO ioctl fails due to EPERM in older kernels. Reset the
pointer before each loop starts.
Signed-off-by: David Sterba <dsterba@suse.com>
---
cmds-filesystem.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index b4576ed30360..366373473c56 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -485,6 +485,7 @@ static int btrfs_scan_kernel(void *search, unsigned unit_mode)
if (search && !match_search_item_kernel(fs_info_arg.fsid,
mnt->mnt_dir, label, search)) {
kfree(dev_info_arg);
+ dev_info_arg = NULL;
continue;
}
@@ -500,6 +501,7 @@ static int btrfs_scan_kernel(void *search, unsigned unit_mode)
if (fd != -1)
close(fd);
kfree(dev_info_arg);
+ dev_info_arg = NULL;
}
out:
--
2.1.3
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-10-02 15:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-02 15:49 [PATCH] btrfs-progs: fix double free during scanning David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).