Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:Update
util-linux.2662
util-linux-libmount-btrfs-crash.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File util-linux-libmount-btrfs-crash.patch of Package util-linux.2662
From e9cd2e2bd9ec91a0b1050c4aa79555d142985924 Mon Sep 17 00:00:00 2001 From: Karel Zak <kzak@redhat.com> Date: Thu, 31 Mar 2016 11:45:55 +0200 Subject: [PATCH] libmount: Fix possible NULL dereference in get_btrfs_fs_root() The function mnt_table_get_fs_root() should be robust enough to accept NULL as mountinfo -- the right behaviour is to default to '/'. The set_fs_root() (tab_update.c) has to understand when mountinfo is necessary (for bind mounts and btrfs). Reported-by: Stanislav Brabec <sbrabec@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com> --- libmount/src/tab.c | 4 +++- libmount/src/tab_update.c | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libmount/src/tab.c b/libmount/src/tab.c index a7a1b6b..d7a633c 100644 --- a/libmount/src/tab.c +++ b/libmount/src/tab.c @@ -1346,6 +1346,8 @@ err: * * For btrfs subvolumes this function returns NULL, but @fsroot properly set. * + * If @tb is NULL then defaults to '/'. + * * Returns: entry from @tb that will be used as a source for @fs if the @fs is * bindmount. * @@ -1432,7 +1434,7 @@ struct libmnt_fs *mnt_table_get_fs_root(struct libmnt_table *tb, /* * btrfs-subvolume mount -- get subvolume name and use it as a root-fs path */ - else if (fstype && (!strcmp(fstype, "btrfs") || !strcmp(fstype, "auto"))) { + else if (tb && fstype && (!strcmp(fstype, "btrfs") || !strcmp(fstype, "auto"))) { if (get_btrfs_fs_root(tb, fs, &root) < 0) goto err; } diff --git a/libmount/src/tab_update.c b/libmount/src/tab_update.c index 40adba9..631e1cd 100644 --- a/libmount/src/tab_update.c +++ b/libmount/src/tab_update.c @@ -357,7 +357,7 @@ static int set_fs_root(struct libmnt_update *upd, struct libmnt_fs *fs, { struct libmnt_fs *src_fs; char *fsroot = NULL; - const char *src; + const char *src, *fstype; int rc = 0; DBG(UPDATE, ul_debug("setting FS root")); @@ -366,16 +366,21 @@ static int set_fs_root(struct libmnt_update *upd, struct libmnt_fs *fs, assert(upd->fs); assert(fs); + fstype = mnt_fs_get_fstype(fs); + if (mountflags & MS_BIND) { if (!upd->mountinfo) upd->mountinfo = mnt_new_table_from_file(_PATH_PROC_MOUNTINFO); - src = mnt_fs_get_srcpath(fs); if (src) { rc = mnt_fs_set_bindsrc(upd->fs, src); if (rc) goto err; } + + } else if (fstype && (strcmp(fstype, "btrfs") == 0 || strcmp(fstype, "auto") == 0)) { + if (!upd->mountinfo) + upd->mountinfo = mnt_new_table_from_file(_PATH_PROC_MOUNTINFO); } src_fs = mnt_table_get_fs_root(upd->mountinfo, fs, -- 2.7.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor