@@ -146,7 +146,8 @@ static struct aa_perms compute_fperms_other(struct aa_dfa *dfa,
146
146
*
147
147
* Returns: remapped perm table
148
148
*/
149
- static struct aa_perms * compute_fperms (struct aa_dfa * dfa )
149
+ static struct aa_perms * compute_fperms (struct aa_dfa * dfa ,
150
+ u32 * size )
150
151
{
151
152
aa_state_t state ;
152
153
unsigned int state_count ;
@@ -159,6 +160,7 @@ static struct aa_perms *compute_fperms(struct aa_dfa *dfa)
159
160
table = kvcalloc (state_count * 2 , sizeof (struct aa_perms ), GFP_KERNEL );
160
161
if (!table )
161
162
return NULL ;
163
+ * size = state_count * 2 ;
162
164
163
165
/* zero init so skip the trap state (state == 0) */
164
166
for (state = 1 ; state < state_count ; state ++ ) {
@@ -169,7 +171,8 @@ static struct aa_perms *compute_fperms(struct aa_dfa *dfa)
169
171
return table ;
170
172
}
171
173
172
- static struct aa_perms * compute_xmatch_perms (struct aa_dfa * xmatch )
174
+ static struct aa_perms * compute_xmatch_perms (struct aa_dfa * xmatch ,
175
+ u32 * size )
173
176
{
174
177
struct aa_perms * perms ;
175
178
int state ;
@@ -182,6 +185,7 @@ static struct aa_perms *compute_xmatch_perms(struct aa_dfa *xmatch)
182
185
perms = kvcalloc (state_count , sizeof (struct aa_perms ), GFP_KERNEL );
183
186
if (!perms )
184
187
return NULL ;
188
+ * size = state_count ;
185
189
186
190
/* zero init so skip the trap state (state == 0) */
187
191
for (state = 1 ; state < state_count ; state ++ )
@@ -242,7 +246,8 @@ static struct aa_perms compute_perms_entry(struct aa_dfa *dfa,
242
246
return perms ;
243
247
}
244
248
245
- static struct aa_perms * compute_perms (struct aa_dfa * dfa , u32 version )
249
+ static struct aa_perms * compute_perms (struct aa_dfa * dfa , u32 version ,
250
+ u32 * size )
246
251
{
247
252
unsigned int state ;
248
253
unsigned int state_count ;
@@ -255,6 +260,7 @@ static struct aa_perms *compute_perms(struct aa_dfa *dfa, u32 version)
255
260
table = kvcalloc (state_count , sizeof (struct aa_perms ), GFP_KERNEL );
256
261
if (!table )
257
262
return NULL ;
263
+ * size = state_count ;
258
264
259
265
/* zero init so skip the trap state (state == 0) */
260
266
for (state = 1 ; state < state_count ; state ++ )
@@ -289,7 +295,7 @@ static void remap_dfa_accept(struct aa_dfa *dfa, unsigned int factor)
289
295
/* TODO: merge different dfa mappings into single map_policy fn */
290
296
int aa_compat_map_xmatch (struct aa_policydb * policy )
291
297
{
292
- policy -> perms = compute_xmatch_perms (policy -> dfa );
298
+ policy -> perms = compute_xmatch_perms (policy -> dfa , & policy -> size );
293
299
if (!policy -> perms )
294
300
return - ENOMEM ;
295
301
@@ -300,7 +306,7 @@ int aa_compat_map_xmatch(struct aa_policydb *policy)
300
306
301
307
int aa_compat_map_policy (struct aa_policydb * policy , u32 version )
302
308
{
303
- policy -> perms = compute_perms (policy -> dfa , version );
309
+ policy -> perms = compute_perms (policy -> dfa , version , & policy -> size );
304
310
if (!policy -> perms )
305
311
return - ENOMEM ;
306
312
@@ -311,7 +317,7 @@ int aa_compat_map_policy(struct aa_policydb *policy, u32 version)
311
317
312
318
int aa_compat_map_file (struct aa_policydb * policy )
313
319
{
314
- policy -> perms = compute_fperms (policy -> dfa );
320
+ policy -> perms = compute_fperms (policy -> dfa , & policy -> size );
315
321
if (!policy -> perms )
316
322
return - ENOMEM ;
317
323
0 commit comments