@@ -115,7 +115,7 @@ static inline aa_state_t match_component(struct aa_profile *profile,
115115 * @label: label to check access permissions for
116116 * @stack: whether this is a stacking request
117117 * @state: state to start match in
118- * @subns : whether to do permission checks on components in a subns
118+ * @inview : whether to match labels in view or only in scope
119119 * @request: permissions to request
120120 * @perms: perms struct to set
121121 *
@@ -127,17 +127,17 @@ static inline aa_state_t match_component(struct aa_profile *profile,
127127 */
128128static int label_compound_match (struct aa_profile * profile ,
129129 struct aa_label * label , bool stack ,
130- aa_state_t state , bool subns , u32 request ,
130+ aa_state_t state , bool inview , u32 request ,
131131 struct aa_perms * perms )
132132{
133133 struct aa_ruleset * rules = profile -> label .rules [0 ];
134134 struct aa_profile * tp ;
135135 struct label_it i ;
136136 struct path_cond cond = { };
137137
138- /* find first subcomponent that is visible */
138+ /* find first subcomponent that is in view and going to be interated with */
139139 label_for_each (i , label , tp ) {
140- if (!aa_ns_visible (profile -> ns , tp -> ns , subns ))
140+ if (!aa_ns_visible (profile -> ns , tp -> ns , inview ))
141141 continue ;
142142 state = match_component (profile , tp , stack , state );
143143 if (!state )
@@ -151,7 +151,7 @@ static int label_compound_match(struct aa_profile *profile,
151151
152152next :
153153 label_for_each_cont (i , label , tp ) {
154- if (!aa_ns_visible (profile -> ns , tp -> ns , subns ))
154+ if (!aa_ns_visible (profile -> ns , tp -> ns , inview ))
155155 continue ;
156156 state = aa_dfa_match (rules -> file -> dfa , state , "//&" );
157157 state = match_component (profile , tp , false, state );
@@ -177,7 +177,7 @@ static int label_compound_match(struct aa_profile *profile,
177177 * @label: label to check access permissions for
178178 * @stack: whether this is a stacking request
179179 * @start: state to start match in
180- * @subns : whether to do permission checks on components in a subns
180+ * @inview : whether to match labels in view or only in scope
181181 * @request: permissions to request
182182 * @perms: an initialized perms struct to add accumulation to
183183 *
@@ -189,7 +189,7 @@ static int label_compound_match(struct aa_profile *profile,
189189 */
190190static int label_components_match (struct aa_profile * profile ,
191191 struct aa_label * label , bool stack ,
192- aa_state_t start , bool subns , u32 request ,
192+ aa_state_t start , bool inview , u32 request ,
193193 struct aa_perms * perms )
194194{
195195 struct aa_ruleset * rules = profile -> label .rules [0 ];
@@ -201,7 +201,7 @@ static int label_components_match(struct aa_profile *profile,
201201
202202 /* find first subcomponent to test */
203203 label_for_each (i , label , tp ) {
204- if (!aa_ns_visible (profile -> ns , tp -> ns , subns ))
204+ if (!aa_ns_visible (profile -> ns , tp -> ns , inview ))
205205 continue ;
206206 state = match_component (profile , tp , stack , start );
207207 if (!state )
@@ -218,7 +218,7 @@ static int label_components_match(struct aa_profile *profile,
218218 aa_apply_modes_to_perms (profile , & tmp );
219219 aa_perms_accum (perms , & tmp );
220220 label_for_each_cont (i , label , tp ) {
221- if (!aa_ns_visible (profile -> ns , tp -> ns , subns ))
221+ if (!aa_ns_visible (profile -> ns , tp -> ns , inview ))
222222 continue ;
223223 state = match_component (profile , tp , stack , start );
224224 if (!state )
@@ -245,26 +245,26 @@ static int label_components_match(struct aa_profile *profile,
245245 * @label: label to match (NOT NULL)
246246 * @stack: whether this is a stacking request
247247 * @state: state to start in
248- * @subns : whether to match subns components
248+ * @inview : whether to match labels in view or only in scope
249249 * @request: permission request
250250 * @perms: Returns computed perms (NOT NULL)
251251 *
252252 * Returns: the state the match finished in, may be the none matching state
253253 */
254254static int label_match (struct aa_profile * profile , struct aa_label * label ,
255- bool stack , aa_state_t state , bool subns , u32 request ,
255+ bool stack , aa_state_t state , bool inview , u32 request ,
256256 struct aa_perms * perms )
257257{
258258 int error ;
259259
260260 * perms = nullperms ;
261- error = label_compound_match (profile , label , stack , state , subns ,
261+ error = label_compound_match (profile , label , stack , state , inview ,
262262 request , perms );
263263 if (!error )
264264 return error ;
265265
266266 * perms = allperms ;
267- return label_components_match (profile , label , stack , state , subns ,
267+ return label_components_match (profile , label , stack , state , inview ,
268268 request , perms );
269269}
270270
@@ -880,14 +880,16 @@ static struct aa_label *handle_onexec(const struct cred *subj_cred,
880880 AA_BUG (!bprm );
881881 AA_BUG (!buffer );
882882
883- /* TODO: determine how much we want to loosen this */
884- error = fn_for_each_in_ns (label , profile ,
883+ /* TODO: determine how much we want to loosen this
884+ * only check profiles in scope for permission to change at exec
885+ */
886+ error = fn_for_each_in_scope (label , profile ,
885887 profile_onexec (subj_cred , profile , onexec , stack ,
886888 bprm , buffer , cond , unsafe ));
887889 if (error )
888890 return ERR_PTR (error );
889891
890- new = fn_label_build_in_ns (label , profile , GFP_KERNEL ,
892+ new = fn_label_build_in_scope (label , profile , GFP_KERNEL ,
891893 stack ? aa_label_merge (& profile -> label , onexec ,
892894 GFP_KERNEL )
893895 : aa_get_newest_label (onexec ),
@@ -897,7 +899,7 @@ static struct aa_label *handle_onexec(const struct cred *subj_cred,
897899 return new ;
898900
899901 /* TODO: get rid of GLOBAL_ROOT_UID */
900- error = fn_for_each_in_ns (label , profile ,
902+ error = fn_for_each_in_scope (label , profile ,
901903 aa_audit_file (subj_cred , profile , & nullperms ,
902904 OP_CHANGE_ONEXEC ,
903905 AA_MAY_ONEXEC , bprm -> filename , NULL ,
@@ -1123,7 +1125,7 @@ static struct aa_label *change_hat(const struct cred *subj_cred,
11231125 /*find first matching hat */
11241126 for (i = 0 ; i < count && !hat ; i ++ ) {
11251127 name = hats [i ];
1126- label_for_each_in_ns (it , labels_ns (label ), label , profile ) {
1128+ label_for_each_in_scope (it , labels_ns (label ), label , profile ) {
11271129 if (sibling && PROFILE_IS_HAT (profile )) {
11281130 root = aa_get_profile_rcu (& profile -> parent );
11291131 } else if (!sibling && !PROFILE_IS_HAT (profile )) {
@@ -1159,7 +1161,7 @@ static struct aa_label *change_hat(const struct cred *subj_cred,
11591161 * change_hat.
11601162 */
11611163 name = NULL ;
1162- label_for_each_in_ns (it , labels_ns (label ), label , profile ) {
1164+ label_for_each_in_scope (it , labels_ns (label ), label , profile ) {
11631165 if (!list_empty (& profile -> base .profiles )) {
11641166 info = "hat not found" ;
11651167 error = - ENOENT ;
@@ -1170,7 +1172,7 @@ static struct aa_label *change_hat(const struct cred *subj_cred,
11701172 error = - ECHILD ;
11711173
11721174fail :
1173- label_for_each_in_ns (it , labels_ns (label ), label , profile ) {
1175+ label_for_each_in_scope (it , labels_ns (label ), label , profile ) {
11741176 /*
11751177 * no target as it has failed to be found or built
11761178 *
@@ -1188,7 +1190,7 @@ static struct aa_label *change_hat(const struct cred *subj_cred,
11881190 return ERR_PTR (error );
11891191
11901192build :
1191- new = fn_label_build_in_ns (label , profile , GFP_KERNEL ,
1193+ new = fn_label_build_in_scope (label , profile , GFP_KERNEL ,
11921194 build_change_hat (subj_cred , profile , name ,
11931195 sibling ),
11941196 aa_get_label (& profile -> label ));
@@ -1251,7 +1253,7 @@ int aa_change_hat(const char *hats[], int count, u64 token, int flags)
12511253 bool empty = true;
12521254
12531255 rcu_read_lock ();
1254- label_for_each_in_ns (i , labels_ns (label ), label , profile ) {
1256+ label_for_each_in_scope (i , labels_ns (label ), label , profile ) {
12551257 empty &= list_empty (& profile -> base .profiles );
12561258 }
12571259 rcu_read_unlock ();
@@ -1338,7 +1340,7 @@ int aa_change_hat(const char *hats[], int count, u64 token, int flags)
13381340 perms .kill = AA_MAY_CHANGEHAT ;
13391341
13401342fail :
1341- fn_for_each_in_ns (label , profile ,
1343+ fn_for_each_in_scope (label , profile ,
13421344 aa_audit_file (subj_cred , profile , & perms , OP_CHANGE_HAT ,
13431345 AA_MAY_CHANGEHAT , NULL , NULL , target ,
13441346 GLOBAL_ROOT_UID , info , error ));
@@ -1446,7 +1448,7 @@ int aa_change_profile(const char *fqname, int flags)
14461448 */
14471449 stack = true;
14481450 perms .audit = request ;
1449- (void ) fn_for_each_in_ns (label , profile ,
1451+ (void ) fn_for_each_in_scope (label , profile ,
14501452 aa_audit_file (subj_cred , profile , & perms , op ,
14511453 request , auditname , NULL , target ,
14521454 GLOBAL_ROOT_UID , stack_msg , 0 ));
@@ -1492,7 +1494,7 @@ int aa_change_profile(const char *fqname, int flags)
14921494 *
14931495 * if (!stack) {
14941496 */
1495- error = fn_for_each_in_ns (label , profile ,
1497+ error = fn_for_each_in_scope (label , profile ,
14961498 change_profile_perms_wrapper (op , auditname ,
14971499 subj_cred ,
14981500 profile , target , stack ,
@@ -1506,7 +1508,7 @@ int aa_change_profile(const char *fqname, int flags)
15061508check :
15071509 /* check if tracing task is allowed to trace target domain */
15081510 error = may_change_ptraced_domain (subj_cred , target , & info );
1509- if (error && !fn_for_each_in_ns (label , profile ,
1511+ if (error && !fn_for_each_in_scope (label , profile ,
15101512 COMPLAIN_MODE (profile )))
15111513 goto audit ;
15121514
@@ -1522,7 +1524,7 @@ int aa_change_profile(const char *fqname, int flags)
15221524
15231525 /* stacking is always a subset, so only check the nonstack case */
15241526 if (!stack ) {
1525- new = fn_label_build_in_ns (label , profile , GFP_KERNEL ,
1527+ new = fn_label_build_in_scope (label , profile , GFP_KERNEL ,
15261528 aa_get_label (target ),
15271529 aa_get_label (& profile -> label ));
15281530 /*
@@ -1565,7 +1567,7 @@ int aa_change_profile(const char *fqname, int flags)
15651567 }
15661568
15671569audit :
1568- error = fn_for_each_in_ns (label , profile ,
1570+ error = fn_for_each_in_scope (label , profile ,
15691571 aa_audit_file (subj_cred ,
15701572 profile , & perms , op , request , auditname ,
15711573 NULL , new ? new : target ,
0 commit comments