libsepol: drop broken warning on duplicate filename transitions
Stephen Smalley
maintainerPATCH 1/1 libsepol: drop broken warning on duplicate filename transitions
As per the issue below, libsepol segfaults on loading old kernel policies that contain duplicate filename transition rules. The segfault is due to the fact that the val_to_name arrays have not yet been populated at this point in the policydb_read() processing. Since this warning apparently never worked since it was first introduced, drop it and just silently discard the duplicate like the kernel does. I was not able to produce a policy with such duplicates using the current policy toolchain, either via CIL or via binary modules with manual semodule_link/expand.
--- libsepol/src/policydb.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
libsepol/src/policydb.c +1 -8
@@ -2655,15 +2655,8 @@ int filename_trans_read(policydb_t *p, struct policy_file *fp)* Some old policies were wrongly generated with * duplicate filename transition rules. For backward * compatibility, do not reject such policies, just -* issue a warning and ignore the duplicate. +* ignore the duplicate. */ -WARN (fp->handle, -"Duplicate name-based type_transition %s %s:%s \"%s\": %s, ignoring" , - p->p_type_val_to_name[ft->stype -1 ], - p->p_type_val_to_name[ft->ttype -1 ], - p->p_class_val_to_name[ft->tclass -1 ], - ft->name, - p->p_type_val_to_name[otype->otype -1 ]);free (ft);free (name);free (otype);
Signature · 1 line
2.23.3
Quoted 24 lines · Stephen Smalley
As per the issue below, libsepol segfaults on loading old kernel policies that contain duplicate filename transition rules. The segfault is due to the fact that the
val_to_namearrays have not yet been populated at this point in thepolicydb_read()processing. Since this warning apparently never worked since it was first introduced, drop it and just silently discard the duplicate like the kernel does. I was not able to produce a policy with such duplicates using the current policy toolchain, either via CIL or via binary modules with manual semodule_link/expand.Fixes 8fdb2255215a1f14 ("libsepol,checkpolicy: convert rangetrans and filenametrans to hashtabs")Signed-off-by Stephen Smalley <[email protected]>--- libsepol/src/policydb.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)libsepol/src/policydb.c +0
-0@@ -2655,15 +2655,8 @@ int filename_trans_read(policydb_t *p, struct policy_file *fp)* Some old policies were wrongly generated with * duplicate filename transition rules. For backward * compatibility, do not reject such policies, just
libsepol/src/policydb.c int filename_trans_read(policydb_t *p, struct policy_file *fp) · line 2666
Quoted 10 lines
libsepol/src/policydb.c +1
-8-* issue a warning and ignore the duplicate. +* ignore the duplicate. */ -WARN (fp->handle, -"Duplicate name-based type_transition %s %s:%s \"%s\": %s, ignoring" , - p->p_type_val_to_name[ft->stype -1 ], - p->p_type_val_to_name[ft->ttype -1 ], - p->p_class_val_to_name[ft->tclass -1 ], - ft->name, - p->p_type_val_to_name[otype->otype -1 ]);
Not sure if it's the same situation, but should we also do something about a similar pattern in checkpolicy/policy_define.c?
Quoted 6 lines
libsepol/src/policydb.c +0
-1free (ft);free (name);free (otype); --2.23.3
Signature · 3 lines
Ondrej Mosnacek <omosnace at redhat dot com> Software Engineer, Security Technologies Red Hat, Inc.
Stephen Smalley
maintainerQuoted 41 lines · Ondrej Mosnacek
Quoted 24 lines · Stephen Smalley
As per the issue below, libsepol segfaults on loading old kernel policies that contain duplicate filename transition rules. The segfault is due to the fact that the
val_to_namearrays have not yet been populated at this point in thepolicydb_read()processing. Since this warning apparently never worked since it was first introduced, drop it and just silently discard the duplicate like the kernel does. I was not able to produce a policy with such duplicates using the current policy toolchain, either via CIL or via binary modules with manual semodule_link/expand.Fixes 8fdb2255215a1f14 ("libsepol,checkpolicy: convert rangetrans and filenametrans to hashtabs")Signed-off-by Stephen Smalley <[email protected]>--- libsepol/src/policydb.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)libsepol/src/policydb.c +0
-0@@ -2655,15 +2655,8 @@ int filename_trans_read(policydb_t *p, struct policy_file *fp)* Some old policies were wrongly generated with * duplicate filename transition rules. For backward * compatibility, do not reject such policies, just libsepol/src/policydb.c int filename_trans_read(policydb_t *p, struct policy_file *fp) · line 2666
Quoted 10 lines
libsepol/src/policydb.c +1
-8-* issue a warning and ignore the duplicate. +* ignore the duplicate. */ -WARN (fp->handle, -"Duplicate name-based type_transition %s %s:%s \"%s\": %s, ignoring" , - p->p_type_val_to_name[ft->stype -1 ], - p->p_type_val_to_name[ft->ttype -1 ], - p->p_class_val_to_name[ft->tclass -1 ], - ft->name, - p->p_type_val_to_name[otype->otype -1 ]);Not sure if it's the same situation, but should we also do something about a similar pattern in
checkpolicy/policy_define.c?
No, in that case we are compiling source policy and we want to warn on it to encourage removal of duplicates (and we have populated the val_to_name arrays there so the warning works).
Ondrej Mosnacek
Acked-byQuoted 42 lines · Stephen Smalley
Quoted 41 lines · Ondrej Mosnacek
Quoted 24 lines · Stephen Smalley
As per the issue below, libsepol segfaults on loading old kernel policies that contain duplicate filename transition rules. The segfault is due to the fact that the
val_to_namearrays have not yet been populated at this point in thepolicydb_read()processing. Since this warning apparently never worked since it was first introduced, drop it and just silently discard the duplicate like the kernel does. I was not able to produce a policy with such duplicates using the current policy toolchain, either via CIL or via binary modules with manual semodule_link/expand.Fixes 8fdb2255215a1f14 ("libsepol,checkpolicy: convert rangetrans and filenametrans to hashtabs")Signed-off-by Stephen Smalley <[email protected]>--- libsepol/src/policydb.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)libsepol/src/policydb.c +0
-0@@ -2655,15 +2655,8 @@ int filename_trans_read(policydb_t *p, struct policy_file *fp)* Some old policies were wrongly generated with * duplicate filename transition rules. For backward * compatibility, do not reject such policies, just libsepol/src/policydb.c int filename_trans_read(policydb_t *p, struct policy_file *fp) · line 2666
Quoted 10 lines
libsepol/src/policydb.c +1
-8-* issue a warning and ignore the duplicate. +* ignore the duplicate. */ -WARN (fp->handle, -"Duplicate name-based type_transition %s %s:%s \"%s\": %s, ignoring" , - p->p_type_val_to_name[ft->stype -1 ], - p->p_type_val_to_name[ft->ttype -1 ], - p->p_class_val_to_name[ft->tclass -1 ], - ft->name, - p->p_type_val_to_name[otype->otype -1 ]);Not sure if it's the same situation, but should we also do something about a similar pattern in
checkpolicy/policy_define.c?
Quoted 5 lines
No, in that case we are compiling source policy and we want to warn on it to encourage removal of duplicates (and we have populated the
val_to_namearrays there so the warning works).
Ok, makes sense. In that case:
Signature · 3 lines
Ondrej Mosnacek <omosnace at redhat dot com> Software Engineer, Security Technologies Red Hat, Inc.
Petr Lautrbach
AppliedQuoted 46 lines · Ondrej Mosnacek
Quoted 44 lines · Stephen Smalley
Quoted 42 lines · Ondrej Mosnacek
Quoted 24 lines · Stephen Smalley
As per the issue below, libsepol segfaults on loading old kernel policies that contain duplicate filename transition rules. The segfault is due to the fact that the
val_to_namearrays have not yet been populated at this point in thepolicydb_read()processing. Since this warning apparently never worked since it was first introduced, drop it and just silently discard the duplicate like the kernel does. I was not able to produce a policy with such duplicates using the current policy toolchain, either via CIL or via binary modules with manual semodule_link/expand.Fixes 8fdb2255215a1f14 ("libsepol,checkpolicy: convert rangetrans and filenametrans to hashtabs")Signed-off-by Stephen Smalley <[email protected]>--- libsepol/src/policydb.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)libsepol/src/policydb.c +0
-0@@ -2655,15 +2655,8 @@ int filename_trans_read(policydb_t *p, struct policy_file *fp)* Some old policies were wrongly generated with * duplicate filename transition rules. For backward * compatibility, do not reject such policies, just libsepol/src/policydb.c int filename_trans_read(policydb_t *p, struct policy_file *fp) · line 2666
Quoted 10 lines
libsepol/src/policydb.c +1
-8-* issue a warning and ignore the duplicate. +* ignore the duplicate. */ -WARN (fp->handle, -"Duplicate name-based type_transition %s %s:%s \"%s\": %s, ignoring" , - p->p_type_val_to_name[ft->stype -1 ], - p->p_type_val_to_name[ft->ttype -1 ], - p->p_class_val_to_name[ft->tclass -1 ], - ft->name, - p->p_type_val_to_name[otype->otype -1 ]);Not sure if it's the same situation, but should we also do something about a similar pattern in
checkpolicy/policy_define.c?
Quoted 8 lines
Quoted 3 lines
No, in that case we are compiling source policy and we want to warn on it to encourage removal of duplicates (and we have populated the
val_to_namearrays there so the warning works).Ok, makes sense. In that case:
Acked-by Ondrej Mosnacek <[email protected]>
Applied.