@@ -377,7 +377,8 @@ static void ima_free_rule(struct ima_rule_entry *entry)
377
377
kfree (entry );
378
378
}
379
379
380
- static struct ima_rule_entry * ima_lsm_copy_rule (struct ima_rule_entry * entry )
380
+ static struct ima_rule_entry * ima_lsm_copy_rule (struct ima_rule_entry * entry ,
381
+ gfp_t gfp )
381
382
{
382
383
struct ima_rule_entry * nentry ;
383
384
int i ;
@@ -386,7 +387,7 @@ static struct ima_rule_entry *ima_lsm_copy_rule(struct ima_rule_entry *entry)
386
387
* Immutable elements are copied over as pointers and data; only
387
388
* lsm rules can change
388
389
*/
389
- nentry = kmemdup (entry , sizeof (* nentry ), GFP_KERNEL );
390
+ nentry = kmemdup (entry , sizeof (* nentry ), gfp );
390
391
if (!nentry )
391
392
return NULL ;
392
393
@@ -401,7 +402,8 @@ static struct ima_rule_entry *ima_lsm_copy_rule(struct ima_rule_entry *entry)
401
402
402
403
ima_filter_rule_init (nentry -> lsm [i ].type , Audit_equal ,
403
404
nentry -> lsm [i ].args_p ,
404
- & nentry -> lsm [i ].rule );
405
+ & nentry -> lsm [i ].rule ,
406
+ gfp );
405
407
if (!nentry -> lsm [i ].rule )
406
408
pr_warn ("rule for LSM \'%s\' is undefined\n" ,
407
409
nentry -> lsm [i ].args_p );
@@ -414,7 +416,7 @@ static int ima_lsm_update_rule(struct ima_rule_entry *entry)
414
416
int i ;
415
417
struct ima_rule_entry * nentry ;
416
418
417
- nentry = ima_lsm_copy_rule (entry );
419
+ nentry = ima_lsm_copy_rule (entry , GFP_KERNEL );
418
420
if (!nentry )
419
421
return - ENOMEM ;
420
422
@@ -638,7 +640,7 @@ static bool ima_match_rules(struct ima_rule_entry *rule,
638
640
}
639
641
640
642
if (rc == - ESTALE && !rule_reinitialized ) {
641
- lsm_rule = ima_lsm_copy_rule (rule );
643
+ lsm_rule = ima_lsm_copy_rule (rule , GFP_ATOMIC );
642
644
if (lsm_rule ) {
643
645
rule_reinitialized = true;
644
646
goto retry ;
@@ -1113,7 +1115,8 @@ static int ima_lsm_rule_init(struct ima_rule_entry *entry,
1113
1115
entry -> lsm [lsm_rule ].type = audit_type ;
1114
1116
result = ima_filter_rule_init (entry -> lsm [lsm_rule ].type , Audit_equal ,
1115
1117
entry -> lsm [lsm_rule ].args_p ,
1116
- & entry -> lsm [lsm_rule ].rule );
1118
+ & entry -> lsm [lsm_rule ].rule ,
1119
+ GFP_KERNEL );
1117
1120
if (!entry -> lsm [lsm_rule ].rule ) {
1118
1121
pr_warn ("rule for LSM \'%s\' is undefined\n" ,
1119
1122
entry -> lsm [lsm_rule ].args_p );
0 commit comments