libsepol: log an error if we hit the max depth for __evaluate_classperms_list()
Stephen Smalley
maintainerPATCH v2 1/1 libsepol: log an error if we hit the max depth for __evaluate_classperms_list()
Add a cil_log() statement so that we do not fail silently if we hit the max depth. While we are here, introduce a #define for the max depth and use it, and fix the comparison so that we fail immediately when the depth has already reached the limit.
---
v2 adds the missing newline to cil_log(); was confused by the fact that cil_tree_log() doesn't want one but cil_log() does.
libsepol/cil/src/cil_post.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
libsepol/cil/src/cil_post.c +6 -1
@@ -49,6 +49,8 @@#include "cil_symtab.h" #include "cil_deny.h" +#define MAX_CLASSPERMS_DEPTH (32) +#define GEN_REQUIRE_ATTR \ "cil_gen_require"/* Also in libsepol/src/module_to_cil.c */ #define TYPEATTR_INFIX "_typeattr_"/* Also in libsepol/src/module_to_cil.c */
@@ -2296,8 +2298,11 @@ static int __evaluate_classperms_list(struct cil_list *classperms,int rc =SEPOL_ERR ;struct cil_list_item *curr; -if (depth >32 ) +if (depth >=MAX_CLASSPERMS_DEPTH ) { +cil_log (CIL_ERR ,"Exceeded max classperms depth (%u)\n" , +MAX_CLASSPERMS_DEPTH );return SEPOL_ERR ; + }cil_list_for_each (curr, classperms) {if (curr->flavor ==CIL_CLASSPERMS ) {
Signature · 1 line
2.55.0
Quoted 7 lines · Stephen Smalley
Add a
cil_log()statement so that we do not fail silently if we hit the max depth. While we are here, introduce a #define for the max depth and use it, and fix the comparison so that we fail immediately when the depth has already reached the limit.Signed-off-by Stephen Smalley <[email protected]>
Quoted 36 lines
---
v2 adds the missing newline tocil_log(); was confused by the fact thatcil_tree_log()doesn't want one butcil_log()does.libsepol/cil/src/cil_post.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)libsepol/cil/src/cil_post.c +6
-2@@ -49,6 +49,8 @@#include "cil_symtab.h" #include "cil_deny.h" +#define MAX_CLASSPERMS_DEPTH (32) +#define GEN_REQUIRE_ATTR \ "cil_gen_require"/* Also in libsepol/src/module_to_cil.c */ #define TYPEATTR_INFIX "_typeattr_"/* Also in libsepol/src/module_to_cil.c */ @@ -2296,8 +2298,11 @@ static int __evaluate_classperms_list(struct cil_list *classperms,int rc =SEPOL_ERR ;struct cil_list_item *curr; -if (depth >32 ) +if (depth >=MAX_CLASSPERMS_DEPTH ) { +cil_log (CIL_ERR ,"Exceeded max classperms depth (%u)\n" , +MAX_CLASSPERMS_DEPTH );return SEPOL_ERR ; + }cil_list_for_each (curr, classperms) {if (curr->flavor ==CIL_CLASSPERMS ) { --2.55.0
Stephen Smalley
maintainerQuoted 4 lines · James Carter
Quoted 1 line · Stephen Smalley
Quoted 8 lines
Quoted 6 lines
Add a
cil_log()statement so that we do not fail silently if we hit the max depth. While we are here, introduce a #define for the max depth and use it, and fix the comparison so that we fail immediately when the depth has already reached the limit.Signed-off-by Stephen Smalley <[email protected]>Acked-by James Carter <[email protected]>
Merged.