[util-linux/f15/master] 2.19-4: fix mountinfo parsing

kzak kzak at fedoraproject.org
Thu Apr 21 08:46:56 UTC 2011


commit b21024ce79531dfbdc6e688cd2b0ddef86ca5fd8
Author: Karel Zak <kzak at redhat.com>
Date:   Thu Apr 21 10:46:35 2011 +0200

    2.19-4: fix mountinfo parsing
    
    Signed-off-by: Karel Zak <kzak at redhat.com>

 util-linux-2.19-libmount-uuid.patch |   78 +++++++++++++++++++++++++++++++++++
 util-linux.spec                     |    9 ++++-
 2 files changed, 86 insertions(+), 1 deletions(-)
---
diff --git a/util-linux-2.19-libmount-uuid.patch b/util-linux-2.19-libmount-uuid.patch
new file mode 100644
index 0000000..0487c73
--- /dev/null
+++ b/util-linux-2.19-libmount-uuid.patch
@@ -0,0 +1,78 @@
+From 307fb169ce47dff7fe01d99c25ed69752582ebce Mon Sep 17 00:00:00 2001
+From: Karel Zak <kzak at redhat.com>
+Date: Tue, 5 Apr 2011 14:17:51 +0200
+Subject: [PATCH] libmount: fix parsing of mountinfo from 2.6.39
+
+The /proc/self/mountinfo file uses " - " field as a separator between
+optional fields and next fields in the file. The '-' char could be
+used in the fields (for example in UUIDs), so it's necessary to check
+for whole " - " string rather than for '-' char only.
+
+Reported-by: "Aneesh Kumar K. V" <aneesh.kumar at linux.vnet.ibm.com>
+Signed-off-by: Karel Zak <kzak at redhat.com>
+---
+ shlibs/mount/src/tab_parse.c |   29 +++++++++++++++++++++--------
+ 1 files changed, 21 insertions(+), 8 deletions(-)
+
+diff --git a/shlibs/mount/src/tab_parse.c b/shlibs/mount/src/tab_parse.c
+index b0007fa..e285c65 100644
+--- a/shlibs/mount/src/tab_parse.c
++++ b/shlibs/mount/src/tab_parse.c
+@@ -113,9 +113,9 @@ static int mnt_parse_table_line(struct libmnt_fs *fs, char *s)
+  */
+ static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, char *s)
+ {
+-	int rc;
++	int rc, end = 0;
+ 	unsigned int maj, min;
+-	char *fstype, *src;
++	char *fstype, *src, *p;
+ 
+ 	rc = sscanf(s,	"%u "		/* (1) id */
+ 			"%u "		/* (2) parent */
+@@ -123,11 +123,7 @@ static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, char *s)
+ 			"%ms "		/* (4) mountroot */
+ 			"%ms "		/* (5) target */
+ 			"%ms"		/* (6) vfs options (fs-independent) */
+-			"%*[^-]"	/* (7) optional fields */
+-			"- "		/* (8) separator */
+-			"%ms "		/* (9) FS type */
+-			"%ms "		/* (10) source */
+-			"%ms",		/* (11) fs options (fs specific) */
++			"%n",		/* number of read bytes */
+ 
+ 			&fs->id,
+ 			&fs->parent,
+@@ -135,11 +131,28 @@ static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, char *s)
+ 			&fs->root,
+ 			&fs->target,
+ 			&fs->vfs_optstr,
++			&end);
++
++	if (rc >= 7 && end > 0)
++		s += end;
++
++	/* (7) optional fields, terminated by " - " */
++	p = strstr(s, " - ");
++	if (!p) {
++		DBG(TAB, mnt_debug("mountinfo parse error: not found separator"));
++		return -EINVAL;
++	}
++	s = p + 3;
++
++	rc += sscanf(s,	"%ms "		/* (8) FS type */
++			"%ms "		/* (9) source */
++			"%ms",		/* (10) fs options (fs specific) */
++
+ 			&fstype,
+ 			&src,
+ 			&fs->fs_optstr);
+ 
+-	if (rc == 10) {
++	if (rc >= 10) {
+ 		fs->flags |= MNT_FS_KERNEL;
+ 		fs->devno = makedev(maj, min);
+ 
+-- 
+1.7.3.4
+
diff --git a/util-linux.spec b/util-linux.spec
index d850dc3..08b9127 100644
--- a/util-linux.spec
+++ b/util-linux.spec
@@ -2,7 +2,7 @@
 Summary: A collection of basic system utilities
 Name: util-linux
 Version: 2.19
-Release: 3%{?dist}
+Release: 4%{?dist}
 License: GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+ and BSD with advertising and Public Domain
 Group: System Environment/Base
 URL: http://kernel.org/~kzak/util-linux/
@@ -90,6 +90,8 @@ Patch8: util-linux-ng-2.15-ipcs-32bit.patch
 Patch9: util-linux-ng-2.19-lsblk-SIZE.patch
 # 679799 - blkid reports partitioned disk sdc as being an LVM PV
 Patch10: util-linux-ng-2.16-blkid-wipe.patch
+# Fix /proc/self/mouninfo parsing on kernel >= 2.6.39
+Patch11: util-linux-2.19-libmount-uuid.patch
 
 %description
 The util-linux package contains a large variety of low-level system
@@ -206,6 +208,7 @@ cp %{SOURCE8} %{SOURCE9} .
 %patch8 -p1
 %patch9 -p1
 %patch10 -p1
+%patch11 -p1
 
 %build
 unset LINGUAS || :
@@ -751,6 +754,10 @@ fi
 
 
 %changelog
+* Thu Apr 21 2011 Karel Zak <kzak at redhat.com> 2.19-4
+- fix /proc/self/mountinfo parsing in libmount
+  https://lkml.org/lkml/2011/4/12/485
+
 * Thu Feb 24 2011 Karel Zak <kzak at redhat.com> 2.19-3
 - fix #679799 - blkid reports partitioned disk sdc as being an LVM PV
 


More information about the scm-commits mailing list