@@ -582,31 +582,45 @@ static int replacement_allowed(struct aa_profile *profile, int noreplace,
582
582
return 0 ;
583
583
}
584
584
585
+ /* audit callback for net specific fields */
586
+ static void audit_cb (struct audit_buffer * ab , void * va )
587
+ {
588
+ struct common_audit_data * sa = va ;
589
+
590
+ if (sa -> aad -> iface .ns ) {
591
+ audit_log_format (ab , " ns=" );
592
+ audit_log_untrustedstring (ab , sa -> aad -> iface .ns );
593
+ }
594
+ }
595
+
585
596
/**
586
597
* aa_audit_policy - Do auditing of policy changes
587
598
* @profile: profile to check if it can manage policy
588
599
* @op: policy operation being performed
589
600
* @gfp: memory allocation flags
601
+ * @nsname: name of the ns being manipulated (MAY BE NULL)
590
602
* @name: name of profile being manipulated (NOT NULL)
591
603
* @info: any extra information to be audited (MAYBE NULL)
592
604
* @error: error code
593
605
*
594
606
* Returns: the error to be returned after audit is done
595
607
*/
596
608
static int audit_policy (struct aa_profile * profile , int op , gfp_t gfp ,
597
- const char * name , const char * info , int error )
609
+ const char * nsname , const char * name ,
610
+ const char * info , int error )
598
611
{
599
612
struct common_audit_data sa ;
600
613
struct apparmor_audit_data aad = {0 ,};
601
614
sa .type = LSM_AUDIT_DATA_NONE ;
602
615
sa .aad = & aad ;
603
616
aad .op = op ;
617
+ aad .iface .ns = nsname ;
604
618
aad .name = name ;
605
619
aad .info = info ;
606
620
aad .error = error ;
607
621
608
622
return aa_audit (AUDIT_APPARMOR_STATUS , profile , gfp ,
609
- & sa , NULL );
623
+ & sa , audit_cb );
610
624
}
611
625
612
626
/**
@@ -659,11 +673,11 @@ int aa_may_manage_policy(struct aa_profile *profile, struct aa_ns *ns, int op)
659
673
{
660
674
/* check if loading policy is locked out */
661
675
if (aa_g_lock_policy )
662
- return audit_policy (profile , op , GFP_KERNEL , NULL ,
676
+ return audit_policy (profile , op , GFP_KERNEL , NULL , NULL ,
663
677
"policy_locked" , - EACCES );
664
678
665
679
if (!policy_admin_capable (ns ))
666
- return audit_policy (profile , op , GFP_KERNEL , NULL ,
680
+ return audit_policy (profile , op , GFP_KERNEL , NULL , NULL ,
667
681
"not policy admin" , - EACCES );
668
682
669
683
/* TODO: add fine grained mediation of policy loads */
@@ -818,7 +832,7 @@ ssize_t aa_replace_profiles(struct aa_ns *view, void *udata, size_t size,
818
832
ns = aa_prepare_ns (view , ns_name );
819
833
if (!ns ) {
820
834
error = audit_policy (__aa_current_profile (), op , GFP_KERNEL ,
821
- ns_name ,
835
+ NULL , ns_name ,
822
836
"failed to prepare namespace" , - ENOMEM );
823
837
goto free ;
824
838
}
@@ -895,7 +909,7 @@ ssize_t aa_replace_profiles(struct aa_ns *view, void *udata, size_t size,
895
909
list_del_init (& ent -> list );
896
910
op = (!ent -> old && !ent -> rename ) ? OP_PROF_LOAD : OP_PROF_REPL ;
897
911
898
- audit_policy (__aa_current_profile (), op , GFP_ATOMIC ,
912
+ audit_policy (__aa_current_profile (), op , GFP_ATOMIC , NULL ,
899
913
ent -> new -> base .hname , NULL , error );
900
914
901
915
if (ent -> old ) {
@@ -950,7 +964,7 @@ ssize_t aa_replace_profiles(struct aa_ns *view, void *udata, size_t size,
950
964
951
965
/* audit cause of failure */
952
966
op = (!ent -> old ) ? OP_PROF_LOAD : OP_PROF_REPL ;
953
- audit_policy (__aa_current_profile (), op , GFP_KERNEL ,
967
+ audit_policy (__aa_current_profile (), op , GFP_KERNEL , NULL ,
954
968
ent -> new -> base .hname , info , error );
955
969
/* audit status that rest of profiles in the atomic set failed too */
956
970
info = "valid profile in failed atomic policy load" ;
@@ -961,7 +975,7 @@ ssize_t aa_replace_profiles(struct aa_ns *view, void *udata, size_t size,
961
975
continue ;
962
976
}
963
977
op = (!ent -> old ) ? OP_PROF_LOAD : OP_PROF_REPL ;
964
- audit_policy (__aa_current_profile (), op , GFP_KERNEL ,
978
+ audit_policy (__aa_current_profile (), op , GFP_KERNEL , NULL ,
965
979
tmp -> new -> base .hname , info , error );
966
980
}
967
981
free :
@@ -1036,7 +1050,7 @@ ssize_t aa_remove_profiles(struct aa_ns *view, char *fqname, size_t size)
1036
1050
1037
1051
/* don't fail removal if audit fails */
1038
1052
(void ) audit_policy (__aa_current_profile (), OP_PROF_RM , GFP_KERNEL ,
1039
- name , info , error );
1053
+ NULL , name , info , error );
1040
1054
aa_put_ns (ns );
1041
1055
aa_put_profile (profile );
1042
1056
return size ;
@@ -1047,6 +1061,6 @@ ssize_t aa_remove_profiles(struct aa_ns *view, char *fqname, size_t size)
1047
1061
1048
1062
fail :
1049
1063
(void ) audit_policy (__aa_current_profile (), OP_PROF_RM , GFP_KERNEL ,
1050
- name , info , error );
1064
+ NULL , name , info , error );
1051
1065
return error ;
1052
1066
}
0 commit comments