Gentoo Archives: gentoo-commits

From: "Ian Delaney (idella4)" <idella4@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-emulation/xen/files: xen-4.3-CVE-2014-263-XSA-84-85.patch
Date: Fri, 07 Feb 2014 08:21:28
Message-Id: 20140207082122.1EC662004E@flycatcher.gentoo.org
1 idella4 14/02/07 08:21:22
2
3 Added: xen-4.3-CVE-2014-263-XSA-84-85.patch
4 Log:
5 revbumps; Sec patches XSA 84, 85 added wrt Sec. Bugs #500536, 500528, rm old
6
7 (Portage version: 2.2.8/cvs/Linux x86_64, signed Manifest commit with key 0xB8072B0D)
8
9 Revision Changes Path
10 1.1 app-emulation/xen/files/xen-4.3-CVE-2014-263-XSA-84-85.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/xen/files/xen-4.3-CVE-2014-263-XSA-84-85.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/xen/files/xen-4.3-CVE-2014-263-XSA-84-85.patch?rev=1.1&content-type=text/plain
14
15 Index: xen-4.3-CVE-2014-263-XSA-84-85.patch
16 ===================================================================
17 From: Xen.org security team <security () xen org>
18 Date: Thu, 06 Feb 2014 14:18:48 +0000
19
20 flask: fix reading strings from guest memory
21
22 Since the string size is being specified by the guest, we must range
23 check it properly before doing allocations based on it. While for the
24 two cases that are exposed only to trusted guests (via policy
25 restriction) this just uses an arbitrary upper limit (PAGE_SIZE), for
26 the FLASK_[GS]ETBOOL case (which any guest can use) the upper limit
27 gets enforced based on the longest name across all boolean settings.
28
29 This is XSA-84.
30
31 Reported-by: Matthew Daley <mattd@×××××××.com>
32 Signed-off-by: Jan Beulich <jbeulich@××××.com>
33 Acked-by: Daniel De Graaf <dgdegra@×××××××××.gov>
34 ===================================================================
35 From: Xen.org security team <security () xen org>
36 Date: Thu, 06 Feb 2014 12:38:51 +0000
37
38 From 593bc8c63d582ec0fc2b3a35336106cf9c3a8b34 Mon Sep 17 00:00:00 2001
39 From: Matthew Daley <mattd@×××××××.com>
40 Date: Sun, 12 Jan 2014 14:29:32 +1300
41 Subject: [PATCH] xsm/flask: correct off-by-one in
42 flask_security_avc_cachestats cpu id check
43
44 This is XSA-85
45
46 Signed-off-by: Matthew Daley <mattd@×××××××.com>
47 Reviewed-by: Jan Beulich <jbeulich@××××.com>
48 Reviewed-by: Ian Campbell <ian.campbell@××××××.com>
49 ---
50 xen/xsm/flask/flask_op.c | 2 +-
51 1 file changed, 1 insertion(+), 1 deletion(-)
52
53 diff --git a/xen/xsm/flask/flask_op.c b/xen/xsm/flask/flask_op.c
54 index 4426ab9..22878f5 100644
55 --- a/xen/xsm/flask/flask_op.c
56 +++ b/xen/xsm/flask/flask_op.c
57 @@ -53,6 +53,7 @@ static DEFINE_SPINLOCK(sel_sem);
58 /* global data for booleans */
59 static int bool_num = 0;
60 static int *bool_pending_values = NULL;
61 +static size_t bool_maxstr;
62 static int flask_security_make_bools(void);
63
64 extern int ss_initialized;
65 @@ -71,9 +72,15 @@ static int domain_has_security(struct do
66 perms, NULL);
67 }
68
69 -static int flask_copyin_string(XEN_GUEST_HANDLE_PARAM(char) u_buf, char **buf, uint32_t size)
70 +static int flask_copyin_string(XEN_GUEST_HANDLE_PARAM(char) u_buf, char **buf,
71 + size_t size, size_t max_size)
72 {
73 - char *tmp = xmalloc_bytes(size + 1);
74 + char *tmp;
75 +
76 + if ( size > max_size )
77 + return -ENOENT;
78 +
79 + tmp = xmalloc_array(char, size + 1);
80 if ( !tmp )
81 return -ENOMEM;
82
83 @@ -99,7 +106,7 @@ static int flask_security_user(struct xe
84 if ( rv )
85 return rv;
86
87 - rv = flask_copyin_string(arg->u.user, &user, arg->size);
88 + rv = flask_copyin_string(arg->u.user, &user, arg->size, PAGE_SIZE);
89 if ( rv )
90 return rv;
91
92 @@ -210,7 +217,7 @@ static int flask_security_context(struct
93 if ( rv )
94 return rv;
95
96 - rv = flask_copyin_string(arg->context, &buf, arg->size);
97 + rv = flask_copyin_string(arg->context, &buf, arg->size, PAGE_SIZE);
98 if ( rv )
99 return rv;
100
101 @@ -303,7 +310,7 @@ static int flask_security_resolve_bool(s
102 if ( arg->bool_id != -1 )
103 return 0;
104
105 - rv = flask_copyin_string(arg->name, &name, arg->size);
106 + rv = flask_copyin_string(arg->name, &name, arg->size, bool_maxstr);
107 if ( rv )
108 return rv;
109
110 @@ -334,7 +341,7 @@ static int flask_security_set_bool(struc
111 int num;
112 int *values;
113
114 - rv = security_get_bools(&num, NULL, &values);
115 + rv = security_get_bools(&num, NULL, &values, NULL);
116 if ( rv != 0 )
117 goto out;
118
119 @@ -440,7 +447,7 @@ static int flask_security_make_bools(voi
120
121 xfree(bool_pending_values);
122
123 - ret = security_get_bools(&num, NULL, &values);
124 + ret = security_get_bools(&num, NULL, &values, &bool_maxstr);
125 if ( ret != 0 )
126 goto out;
127
128 @@ -457,7 +457,7 @@ static int flask_security_avc_cachestats(struct xen_flask_cache_stats *arg)
129 {
130 struct avc_cache_stats *st;
131
132 - if ( arg->cpu > nr_cpu_ids )
133 + if ( arg->cpu >= nr_cpu_ids )
134 return -ENOENT;
135 if ( !cpu_online(arg->cpu) )
136 return -ENOENT;
137 --
138 1.8.5.2
139 --- a/xen/xsm/flask/include/conditional.h
140 +++ b/xen/xsm/flask/include/conditional.h
141 @@ -13,7 +13,9 @@
142 #ifndef _FLASK_CONDITIONAL_H_
143 #define _FLASK_CONDITIONAL_H_
144
145 -int security_get_bools(int *len, char ***names, int **values);
146 +#include <xen/types.h>
147 +
148 +int security_get_bools(int *len, char ***names, int **values, size_t *maxstr);
149
150 int security_set_bools(int len, int *values);
151
152 --- a/xen/xsm/flask/ss/services.c
153 +++ b/xen/xsm/flask/ss/services.c
154 @@ -1850,7 +1850,7 @@ int security_find_bool(const char *name)
155 return rv;
156 }
157
158 -int security_get_bools(int *len, char ***names, int **values)
159 +int security_get_bools(int *len, char ***names, int **values, size_t *maxstr)
160 {
161 int i, rc = -ENOMEM;
162
163 @@ -1858,6 +1858,8 @@ int security_get_bools(int *len, char **
164 if ( names )
165 *names = NULL;
166 *values = NULL;
167 + if ( maxstr )
168 + *maxstr = 0;
169
170 *len = policydb.p_bools.nprim;
171 if ( !*len )
172 @@ -1879,16 +1881,17 @@ int security_get_bools(int *len, char **
173
174 for ( i = 0; i < *len; i++ )
175 {
176 - size_t name_len;
177 + size_t name_len = strlen(policydb.p_bool_val_to_name[i]);
178 +
179 (*values)[i] = policydb.bool_val_to_struct[i]->state;
180 if ( names ) {
181 - name_len = strlen(policydb.p_bool_val_to_name[i]) + 1;
182 - (*names)[i] = (char*)xmalloc_array(char, name_len);
183 + (*names)[i] = xmalloc_array(char, name_len + 1);
184 if ( !(*names)[i] )
185 goto err;
186 - strlcpy((*names)[i], policydb.p_bool_val_to_name[i], name_len);
187 - (*names)[i][name_len - 1] = 0;
188 + strlcpy((*names)[i], policydb.p_bool_val_to_name[i], name_len + 1);
189 }
190 + if ( maxstr && name_len > *maxstr )
191 + *maxstr = name_len;
192 }
193 rc = 0;
194 out:
195 @@ -2006,7 +2009,7 @@ static int security_preserve_bools(struc
196 struct cond_bool_datum *booldatum;
197 struct cond_node *cur;
198
199 - rc = security_get_bools(&nbools, &bnames, &bvalues);
200 + rc = security_get_bools(&nbools, &bnames, &bvalues, NULL);
201 if ( rc )
202 goto out;
203 for ( i = 0; i < nbools; i++ )