@@ -1150,11 +1150,37 @@ static bool verify_dfa_xindex(struct aa_dfa *dfa, int table_size)
1150
1150
return true;
1151
1151
}
1152
1152
1153
- static bool verify_perm_indexes (struct aa_policydb * pdb )
1153
+ static bool verify_perm (struct aa_perms * perm )
1154
+ {
1155
+ /* TODO: allow option to just force the perms into a valid state */
1156
+ if (perm -> allow & perm -> deny )
1157
+ return false;
1158
+ if (perm -> subtree & ~perm -> allow )
1159
+ return false;
1160
+ if (perm -> cond & (perm -> allow | perm -> deny ))
1161
+ return false;
1162
+ if (perm -> kill & perm -> allow )
1163
+ return false;
1164
+ if (perm -> complain & (perm -> allow | perm -> deny ))
1165
+ return false;
1166
+ if (perm -> prompt & (perm -> allow | perm -> deny ))
1167
+ return false;
1168
+ if (perm -> complain & perm -> prompt )
1169
+ return false;
1170
+ if (perm -> hide & perm -> allow )
1171
+ return false;
1172
+
1173
+ return true;
1174
+ }
1175
+
1176
+ static bool verify_perms (struct aa_policydb * pdb )
1154
1177
{
1155
1178
int i ;
1156
1179
1157
1180
for (i = 0 ; i < pdb -> size ; i ++ ) {
1181
+ if (!verify_perm (& pdb -> perms [i ]))
1182
+ return false;
1183
+ /* verify indexes into str table */
1158
1184
if (pdb -> perms [i ].xindex >= pdb -> trans .size )
1159
1185
return false;
1160
1186
if (pdb -> perms [i ].tag >= pdb -> trans .size )
@@ -1187,17 +1213,17 @@ static int verify_profile(struct aa_profile *profile)
1187
1213
return - EPROTO ;
1188
1214
}
1189
1215
1190
- if (!verify_perm_indexes (& profile -> file )) {
1216
+ if (!verify_perms (& profile -> file )) {
1191
1217
audit_iface (profile , NULL , NULL ,
1192
1218
"Unpack: Invalid perm index" , NULL , - EPROTO );
1193
1219
return - EPROTO ;
1194
1220
}
1195
- if (!verify_perm_indexes (& profile -> policy )) {
1221
+ if (!verify_perms (& profile -> policy )) {
1196
1222
audit_iface (profile , NULL , NULL ,
1197
1223
"Unpack: Invalid perm index" , NULL , - EPROTO );
1198
1224
return - EPROTO ;
1199
1225
}
1200
- if (!verify_perm_indexes (& profile -> xmatch )) {
1226
+ if (!verify_perms (& profile -> xmatch )) {
1201
1227
audit_iface (profile , NULL , NULL ,
1202
1228
"Unpack: Invalid perm index" , NULL , - EPROTO );
1203
1229
return - EPROTO ;
0 commit comments