On 1/31/20 3:24 PM, James Carter wrote:
The classperms associated with each map class permission and with each classpermissionset are verified in __cil_verify_classperms() which had multiple problems with how it did the verification. 1) Verification was short-circuited when the first normal class is found. The second classpermissionset statement below would not have been verified. (classpermission cp1) (classpermissionset cp1 (CLASS (PERM))) (classpermissionset cp1 cp2) 2) The classperms of a map class permission and classpermissionset were not checked for being NULL before the function recursively called itself. This would result in a segfault if the missing map or set was referred to before the classmap or classpermission occured. This error was reported by Dominick Grift (dominick.grift@xxxxxxxxxxx). These rules would cause a segfault. (classmap cm1 (mp1)) (classmapping cm1 mp1 (cm2 (mp2))) (classmap cm2 (mp2)) But an error would be produced for these rules. (classmap cm1 (mp1)) (classmap cm2 (mp2)) (classmapping cm2 mp2 (cm1 (mp1))) 3) The loop detection logic was incomplete and could only detect a loop with a certain statement ordering. These rules would cause a stack overflow. (classmap cm1 (mp1)) (classmapping cm1 mp1 (cm2 (mp2))) (classmap cm2 (mp2)) (classmapping cm2 mp2 (cm3 (mp3))) (classmap cm3 (mp3)) (classmapping cm3 mp3 (cm2 (mp2))) Rewrote __cil_verify_classperms() to fix these errors. Signed-off-by: James Carter <jwcart2@xxxxxxxxxxxxx>
Acked-by: Stephen Smalley <sds@xxxxxxxxxxxxx>
--- libsepol/cil/src/cil_verify.c | 83 ++++++++++++++++------------------- 1 file changed, 37 insertions(+), 46 deletions(-)
[...]