summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/util-linux
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2015-03-11 14:47:08 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-03-16 17:42:06 +0000
commitb14dd6a177fb682008a97582e04bc2b6282952a3 (patch)
treecd95b1697db44ce1c5c079b4cf9db038aeda57b6 /meta/recipes-core/util-linux
parente5f9a6729c24d3d6c2e4bba9fead697adaa7f704 (diff)
downloadpoky-b14dd6a177fb682008a97582e04bc2b6282952a3.tar.gz
util-linux: fix CVE-2014-9114
Backport a patch to fix CVE-2014-9114. The patch has been integrated in util-linux-2.26. [YOCTO #7180] (From OE-Core rev: 6a5c24f22621f41b17267a6ebedecec631d0156d) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/util-linux')
-rw-r--r--meta/recipes-core/util-linux/util-linux/CVE-2014-9114.patch174
-rw-r--r--meta/recipes-core/util-linux/util-linux_2.25.2.bb1
2 files changed, 175 insertions, 0 deletions
diff --git a/meta/recipes-core/util-linux/util-linux/CVE-2014-9114.patch b/meta/recipes-core/util-linux/util-linux/CVE-2014-9114.patch
new file mode 100644
index 0000000000..5eaa08df63
--- /dev/null
+++ b/meta/recipes-core/util-linux/util-linux/CVE-2014-9114.patch
@@ -0,0 +1,174 @@
1Upstream-Status: Backport
2
3This patch is for CVE-2014-9114.
4This patch should be removed once util-linux is upgraded to 2.26.
5
6Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
7
8From 89e90ae7b2826110ea28c1c0eb8e7c56c3907bdc Mon Sep 17 00:00:00 2001
9From: Karel Zak <kzak@redhat.com>
10Date: Thu, 27 Nov 2014 13:39:35 +0100
11Subject: [PATCH] libblkid: care about unsafe chars in cache
12
13The high-level libblkid API uses /run/blkid/blkid.tab cache to
14store probing results. The cache format is
15
16 <device NAME="value" ...>devname</device>
17
18and unfortunately the cache code does not escape quotation marks:
19
20 # mkfs.ext4 -L 'AAA"BBB'
21
22 # cat /run/blkid/blkid.tab
23 ...
24 <device ... LABEL="AAA"BBB" ...>/dev/sdb1</device>
25
26such string is later incorrectly parsed and blkid(8) returns
27nonsenses. And for use-cases like
28
29 # eval $(blkid -o export /dev/sdb1)
30
31it's also insecure.
32
33Note that mount, udevd and blkid -p are based on low-level libblkid
34API, it bypass the cache and directly read data from the devices.
35
36The current udevd upstream does not depend on blkid(8) output at all,
37it's directly linked with the library and all unsafe chars are encoded by
38\x<hex> notation.
39
40 # mkfs.ext4 -L 'X"`/tmp/foo` "' /dev/sdb1
41 # udevadm info --export-db | grep LABEL
42 ...
43 E: ID_FS_LABEL=X__/tmp/foo___
44 E: ID_FS_LABEL_ENC=X\x22\x60\x2ftmp\x2ffoo\x60\x20\x22
45
46Signed-off-by: Karel Zak <kzak@redhat.com>
47---
48 libblkid/src/read.c | 21 ++++++++++++++++++---
49 libblkid/src/save.c | 22 +++++++++++++++++++++-
50 misc-utils/blkid.8 | 5 ++++-
51 misc-utils/blkid.c | 4 ++--
52 4 files changed, 45 insertions(+), 7 deletions(-)
53
54diff --git a/libblkid/src/read.c b/libblkid/src/read.c
55index 0e91c9c..81ab0df 100644
56--- a/libblkid/src/read.c
57+++ b/libblkid/src/read.c
58@@ -252,15 +252,30 @@ static int parse_token(char **name, char **value, char **cp)
59 *value = skip_over_blank(*value + 1);
60
61 if (**value == '"') {
62- end = strchr(*value + 1, '"');
63- if (!end) {
64+ char *p = end = *value + 1;
65+
66+ /* convert 'foo\"bar' to 'foo"bar' */
67+ while (*p) {
68+ if (*p == '\\') {
69+ p++;
70+ *end = *p;
71+ } else {
72+ *end = *p;
73+ if (*p == '"')
74+ break;
75+ }
76+ p++;
77+ end++;
78+ }
79+
80+ if (*end != '"') {
81 DBG(READ, ul_debug("unbalanced quotes at: %s", *value));
82 *cp = *value;
83 return -BLKID_ERR_CACHE;
84 }
85 (*value)++;
86 *end = '\0';
87- end++;
88+ end = ++p;
89 } else {
90 end = skip_over_word(*value);
91 if (*end) {
92diff --git a/libblkid/src/save.c b/libblkid/src/save.c
93index 8216f09..5e8bbee 100644
94--- a/libblkid/src/save.c
95+++ b/libblkid/src/save.c
96@@ -26,6 +26,21 @@
97
98 #include "blkidP.h"
99
100+
101+static void save_quoted(const char *data, FILE *file)
102+{
103+ const char *p;
104+
105+ fputc('"', file);
106+ for (p = data; p && *p; p++) {
107+ if ((unsigned char) *p == 0x22 || /* " */
108+ (unsigned char) *p == 0x5c) /* \ */
109+ fputc('\\', file);
110+
111+ fputc(*p, file);
112+ }
113+ fputc('"', file);
114+}
115 static int save_dev(blkid_dev dev, FILE *file)
116 {
117 struct list_head *p;
118@@ -43,9 +58,14 @@ static int save_dev(blkid_dev dev, FILE *file)
119
120 if (dev->bid_pri)
121 fprintf(file, " PRI=\"%d\"", dev->bid_pri);
122+
123 list_for_each(p, &dev->bid_tags) {
124 blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags);
125- fprintf(file, " %s=\"%s\"", tag->bit_name,tag->bit_val);
126+
127+ fputc(' ', file); /* space between tags */
128+ fputs(tag->bit_name, file); /* tag NAME */
129+ fputc('=', file); /* separator between NAME and VALUE */
130+ save_quoted(tag->bit_val, file); /* tag "VALUE" */
131 }
132 fprintf(file, ">%s</device>\n", dev->bid_name);
133
134diff --git a/misc-utils/blkid.8 b/misc-utils/blkid.8
135index 156a14b..c95b833 100644
136--- a/misc-utils/blkid.8
137+++ b/misc-utils/blkid.8
138@@ -200,7 +200,10 @@ partitions. This output format is \fBDEPRECATED\fR.
139 .TP
140 .B export
141 print key=value pairs for easy import into the environment; this output format
142-is automatically enabled when I/O Limits (\fB-i\fR option) are requested
143+is automatically enabled when I/O Limits (\fB-i\fR option) are requested.
144+
145+The non-printing characters are encoded by ^ and M- notation and all
146+potentially unsafe characters are escaped.
147 .RE
148 .TP
149 .BI \-O " offset"
150diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
151index a6ca660..1bd8646 100644
152--- a/misc-utils/blkid.c
153+++ b/misc-utils/blkid.c
154@@ -306,7 +306,7 @@ static void print_value(int output, int num, const char *devname,
155 printf("DEVNAME=%s\n", devname);
156 fputs(name, stdout);
157 fputs("=", stdout);
158- safe_print(value, valsz, NULL);
159+ safe_print(value, valsz, " \\\"'$`<>");
160 fputs("\n", stdout);
161
162 } else {
163@@ -315,7 +315,7 @@ static void print_value(int output, int num, const char *devname,
164 fputs(" ", stdout);
165 fputs(name, stdout);
166 fputs("=\"", stdout);
167- safe_print(value, valsz, "\"");
168+ safe_print(value, valsz, "\"\\");
169 fputs("\"", stdout);
170 }
171 }
172--
1731.9.1
174
diff --git a/meta/recipes-core/util-linux/util-linux_2.25.2.bb b/meta/recipes-core/util-linux/util-linux_2.25.2.bb
index 697b9000c0..0ff1e7cc64 100644
--- a/meta/recipes-core/util-linux/util-linux_2.25.2.bb
+++ b/meta/recipes-core/util-linux/util-linux_2.25.2.bb
@@ -14,6 +14,7 @@ SRC_URI += "file://util-linux-ng-replace-siginterrupt.patch \
14 file://uclibc-__progname-conflict.patch \ 14 file://uclibc-__progname-conflict.patch \
15 file://configure-sbindir.patch \ 15 file://configure-sbindir.patch \
16 file://fix-parallel-build.patch \ 16 file://fix-parallel-build.patch \
17 file://CVE-2014-9114.patch \
17 ${OLDHOST} \ 18 ${OLDHOST} \
18" 19"
19 20