From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH] btrfs-progs: fix double free during scanning
Date: Fri, 2 Oct 2015 17:49:05 +0200 [thread overview]
Message-ID: <1443800945-27882-1-git-send-email-dsterba@suse.com> (raw)
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
reply other threads:[~2015-10-02 15:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443800945-27882-1-git-send-email-dsterba@suse.com \
--to=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).