libsepol: Free context on genfscon wildcard error in kernel_to_*
PATCH 1/1 libsepol: Free context on genfscon wildcard error in kernel_to_*
A policy with the policy capability genfs_seclabel_wildcard should have all of its genfscon paths end with "*" (which is added for backwards compatibility when compiling the policy). When converting a kernel policy to CIL or a policy.conf, an error occurs if the genfscon path does not end with "*". On this error path the context is not freed in either kernel_to_cil or kernel_to_conf.
Free the context when exiting with an error for a genfscon path not ending with a "*" when required.
--- libsepol/src/kernel_to_cil.c | 1 + libsepol/src/kernel_to_conf.c | 1 + 2 files changed, 2 insertions(+)
libsepol/src/kernel_to_cil.c +1 -0
@@ -2964,6 +2964,7 @@ static int write_genfscon_rules_to_cil(FILE *out, struct policydb *pdb) name[name_len - 1] != '*') {ERR (NULL ,"genfscon path must end with '*' when genfs_seclabel_wildcard" ); +free (ctx); rc =-1 ; goto exit; }
libsepol/src/kernel_to_conf.c +1 -0
@@ -2825,6 +2825,7 @@ static int write_genfscon_rules_to_conf(FILE *out, struct policydb *pdb) name[name_len - 1] != '*') {ERR (NULL ,"genfscon path must end with '*' when genfs_seclabel_wildcard" ); +free (ctx); rc =-1 ; goto exit; }
Signature · 1 line
2.55.0
Quoted 8 lines · James Carter
A policy with the policy capability
genfs_seclabel_wildcardshould have all of its genfscon paths end with "*" (which is added for backwards compatibility when compiling the policy). When converting a kernel policy to CIL or a policy.conf, an error occurs if the genfscon path does not end with "*". On this error path the context is not freed in eitherkernel_to_cilorkernel_to_conf.
Quoted 4 lines
Free the context when exiting with an error for a genfscon path not ending with a "*" when required.
Signed-off-by James Carter <[email protected]>
Stephen Smalley
maintainerQuoted 10 lines · Stephen Smalley
Quoted 8 lines · James Carter
A policy with the policy capability
genfs_seclabel_wildcardshould have all of its genfscon paths end with "*" (which is added for backwards compatibility when compiling the policy). When converting a kernel policy to CIL or a policy.conf, an error occurs if the genfscon path does not end with "*". On this error path the context is not freed in eitherkernel_to_cilorkernel_to_conf.
Quoted 6 lines
Quoted 4 lines
Free the context when exiting with an error for a genfscon path not ending with a "*" when required.
Signed-off-by James Carter <[email protected]>Acked-by Stephen Smalley <[email protected]>
Merged.