* [PATCH] libsepol/cil: Fix detected RESOURCE_LEAK (CWE-772)
@ 2021-09-09 16:44 Petr Lautrbach
2021-09-09 17:25 ` James Carter
0 siblings, 1 reply; 6+ messages in thread
From: Petr Lautrbach @ 2021-09-09 16:44 UTC (permalink / raw
To: selinux; +Cc: Petr Lautrbach
libsepol/cil/src/cil_binary.c:4823: alloc_arg: "bounds_check_type" allocates memory that is stored into "bad".
libsepol/cil/src/cil_binary.c:4840: var_assign: Assigning: "cur" = "bad".
libsepol/cil/src/cil_binary.c:4844: noescape: Resource "cur" is not freed or pointed-to in "cil_avrule_from_sepol".
libsepol/cil/src/cil_binary.c:4847: leaked_storage: Variable "cur" going out of scope leaks the storage it points to.
libsepol/cil/src/cil_binary.c:4847: leaked_storage: Variable "bad" going out of scope leaks the storage it points to.
Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
---
libsepol/cil/src/cil_binary.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
index 43c37fc24686..4a80cb562424 100644
--- a/libsepol/cil/src/cil_binary.c
+++ b/libsepol/cil/src/cil_binary.c
@@ -4842,6 +4842,7 @@ static int cil_check_type_bounds(const struct cil_db *db, policydb_t *pdb, void
rc = cil_avrule_from_sepol(pdb, cur, &target, type_value_to_cil, class_value_to_cil, perm_value_to_cil);
if (rc != SEPOL_OK) {
cil_log(CIL_ERR, "Failed to convert sepol avrule to CIL\n");
+ bounds_destroy_bad(bad);
goto exit;
}
__cil_print_rule(" ", "allow", &target);
--
2.32.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] libsepol/cil: Fix detected RESOURCE_LEAK (CWE-772)
2021-09-09 16:44 Petr Lautrbach
@ 2021-09-09 17:25 ` James Carter
2021-09-13 13:47 ` Petr Lautrbach
0 siblings, 1 reply; 6+ messages in thread
From: James Carter @ 2021-09-09 17:25 UTC (permalink / raw
To: Petr Lautrbach; +Cc: SElinux list
On Thu, Sep 9, 2021 at 12:45 PM Petr Lautrbach <plautrba@redhat.com> wrote:
>
> libsepol/cil/src/cil_binary.c:4823: alloc_arg: "bounds_check_type" allocates memory that is stored into "bad".
> libsepol/cil/src/cil_binary.c:4840: var_assign: Assigning: "cur" = "bad".
> libsepol/cil/src/cil_binary.c:4844: noescape: Resource "cur" is not freed or pointed-to in "cil_avrule_from_sepol".
> libsepol/cil/src/cil_binary.c:4847: leaked_storage: Variable "cur" going out of scope leaks the storage it points to.
> libsepol/cil/src/cil_binary.c:4847: leaked_storage: Variable "bad" going out of scope leaks the storage it points to.
>
> Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
Acked-by: James Carter <jwcart2@gmail.com>
> ---
> libsepol/cil/src/cil_binary.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
> index 43c37fc24686..4a80cb562424 100644
> --- a/libsepol/cil/src/cil_binary.c
> +++ b/libsepol/cil/src/cil_binary.c
> @@ -4842,6 +4842,7 @@ static int cil_check_type_bounds(const struct cil_db *db, policydb_t *pdb, void
> rc = cil_avrule_from_sepol(pdb, cur, &target, type_value_to_cil, class_value_to_cil, perm_value_to_cil);
> if (rc != SEPOL_OK) {
> cil_log(CIL_ERR, "Failed to convert sepol avrule to CIL\n");
> + bounds_destroy_bad(bad);
> goto exit;
> }
> __cil_print_rule(" ", "allow", &target);
> --
> 2.32.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] libsepol/cil: Fix detected RESOURCE_LEAK (CWE-772)
2021-09-09 17:25 ` James Carter
@ 2021-09-13 13:47 ` Petr Lautrbach
0 siblings, 0 replies; 6+ messages in thread
From: Petr Lautrbach @ 2021-09-13 13:47 UTC (permalink / raw
To: James Carter; +Cc: SElinux list
James Carter <jwcart2@gmail.com> writes:
> On Thu, Sep 9, 2021 at 12:45 PM Petr Lautrbach <plautrba@redhat.com> wrote:
>>
>> libsepol/cil/src/cil_binary.c:4823: alloc_arg: "bounds_check_type" allocates memory that is stored into "bad".
>> libsepol/cil/src/cil_binary.c:4840: var_assign: Assigning: "cur" = "bad".
>> libsepol/cil/src/cil_binary.c:4844: noescape: Resource "cur" is not freed or pointed-to in "cil_avrule_from_sepol".
>> libsepol/cil/src/cil_binary.c:4847: leaked_storage: Variable "cur" going out of scope leaks the storage it points to.
>> libsepol/cil/src/cil_binary.c:4847: leaked_storage: Variable "bad" going out of scope leaks the storage it points to.
>>
>> Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
>
> Acked-by: James Carter <jwcart2@gmail.com>
Merged.
>> ---
>> libsepol/cil/src/cil_binary.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
>> index 43c37fc24686..4a80cb562424 100644
>> --- a/libsepol/cil/src/cil_binary.c
>> +++ b/libsepol/cil/src/cil_binary.c
>> @@ -4842,6 +4842,7 @@ static int cil_check_type_bounds(const struct cil_db *db, policydb_t *pdb, void
>> rc = cil_avrule_from_sepol(pdb, cur, &target, type_value_to_cil, class_value_to_cil, perm_value_to_cil);
>> if (rc != SEPOL_OK) {
>> cil_log(CIL_ERR, "Failed to convert sepol avrule to CIL\n");
>> + bounds_destroy_bad(bad);
>> goto exit;
>> }
>> __cil_print_rule(" ", "allow", &target);
>> --
>> 2.32.0
>>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] libsepol/cil: Fix detected RESOURCE_LEAK (CWE-772)
@ 2024-04-30 15:30 Vit Mojzis
2024-04-30 17:31 ` James Carter
0 siblings, 1 reply; 6+ messages in thread
From: Vit Mojzis @ 2024-04-30 15:30 UTC (permalink / raw
To: selinux
libsepol-3.6/cil/src/cil_binary.c:902: alloc_fn: Storage is returned from allocation function "cil_malloc".
libsepol-3.6/cil/src/cil_binary.c:902: var_assign: Assigning: "mls_level" = storage returned from "cil_malloc(24UL)".
libsepol-3.6/cil/src/cil_binary.c:903: noescape: Resource "mls_level" is not freed or pointed-to in "mls_level_init".
libsepol-3.6/cil/src/cil_binary.c:905: noescape: Resource "mls_level" is not freed or pointed-to in "mls_level_cpy".
libsepol-3.6/cil/src/cil_binary.c:919: leaked_storage: Variable "mls_level" going out of scope leaks the storage it points to.
Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
---
libsepol/cil/src/cil_binary.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
index 95bd18ba..c8144a5a 100644
--- a/libsepol/cil/src/cil_binary.c
+++ b/libsepol/cil/src/cil_binary.c
@@ -904,6 +904,7 @@ static int cil_sensalias_to_policydb(policydb_t *pdb, struct cil_alias *cil_alia
rc = mls_level_cpy(mls_level, sepol_level->level);
if (rc != SEPOL_OK) {
+ free(mls_level);
goto exit;
}
sepol_alias->level = mls_level;
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] libsepol/cil: Fix detected RESOURCE_LEAK (CWE-772)
2024-04-30 15:30 [PATCH] libsepol/cil: Fix detected RESOURCE_LEAK (CWE-772) Vit Mojzis
@ 2024-04-30 17:31 ` James Carter
2024-05-02 18:06 ` James Carter
0 siblings, 1 reply; 6+ messages in thread
From: James Carter @ 2024-04-30 17:31 UTC (permalink / raw
To: Vit Mojzis; +Cc: selinux
On Tue, Apr 30, 2024 at 11:34 AM Vit Mojzis <vmojzis@redhat.com> wrote:
>
> libsepol-3.6/cil/src/cil_binary.c:902: alloc_fn: Storage is returned from allocation function "cil_malloc".
> libsepol-3.6/cil/src/cil_binary.c:902: var_assign: Assigning: "mls_level" = storage returned from "cil_malloc(24UL)".
> libsepol-3.6/cil/src/cil_binary.c:903: noescape: Resource "mls_level" is not freed or pointed-to in "mls_level_init".
> libsepol-3.6/cil/src/cil_binary.c:905: noescape: Resource "mls_level" is not freed or pointed-to in "mls_level_cpy".
> libsepol-3.6/cil/src/cil_binary.c:919: leaked_storage: Variable "mls_level" going out of scope leaks the storage it points to.
>
> Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
Acked-by: James Carter <jwcart2@gmail.com>
> ---
> libsepol/cil/src/cil_binary.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
> index 95bd18ba..c8144a5a 100644
> --- a/libsepol/cil/src/cil_binary.c
> +++ b/libsepol/cil/src/cil_binary.c
> @@ -904,6 +904,7 @@ static int cil_sensalias_to_policydb(policydb_t *pdb, struct cil_alias *cil_alia
>
> rc = mls_level_cpy(mls_level, sepol_level->level);
> if (rc != SEPOL_OK) {
> + free(mls_level);
> goto exit;
> }
> sepol_alias->level = mls_level;
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] libsepol/cil: Fix detected RESOURCE_LEAK (CWE-772)
2024-04-30 17:31 ` James Carter
@ 2024-05-02 18:06 ` James Carter
0 siblings, 0 replies; 6+ messages in thread
From: James Carter @ 2024-05-02 18:06 UTC (permalink / raw
To: Vit Mojzis; +Cc: selinux
On Tue, Apr 30, 2024 at 1:31 PM James Carter <jwcart2@gmail.com> wrote:
>
> On Tue, Apr 30, 2024 at 11:34 AM Vit Mojzis <vmojzis@redhat.com> wrote:
> >
> > libsepol-3.6/cil/src/cil_binary.c:902: alloc_fn: Storage is returned from allocation function "cil_malloc".
> > libsepol-3.6/cil/src/cil_binary.c:902: var_assign: Assigning: "mls_level" = storage returned from "cil_malloc(24UL)".
> > libsepol-3.6/cil/src/cil_binary.c:903: noescape: Resource "mls_level" is not freed or pointed-to in "mls_level_init".
> > libsepol-3.6/cil/src/cil_binary.c:905: noescape: Resource "mls_level" is not freed or pointed-to in "mls_level_cpy".
> > libsepol-3.6/cil/src/cil_binary.c:919: leaked_storage: Variable "mls_level" going out of scope leaks the storage it points to.
> >
> > Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
>
> Acked-by: James Carter <jwcart2@gmail.com>
>
Merged.
Thanks,
Jim
> > ---
> > libsepol/cil/src/cil_binary.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
> > index 95bd18ba..c8144a5a 100644
> > --- a/libsepol/cil/src/cil_binary.c
> > +++ b/libsepol/cil/src/cil_binary.c
> > @@ -904,6 +904,7 @@ static int cil_sensalias_to_policydb(policydb_t *pdb, struct cil_alias *cil_alia
> >
> > rc = mls_level_cpy(mls_level, sepol_level->level);
> > if (rc != SEPOL_OK) {
> > + free(mls_level);
> > goto exit;
> > }
> > sepol_alias->level = mls_level;
> > --
> > 2.43.0
> >
> >
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-05-02 18:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-30 15:30 [PATCH] libsepol/cil: Fix detected RESOURCE_LEAK (CWE-772) Vit Mojzis
2024-04-30 17:31 ` James Carter
2024-05-02 18:06 ` James Carter
-- strict thread matches above, loose matches on Subject: below --
2021-09-09 16:44 Petr Lautrbach
2021-09-09 17:25 ` James Carter
2021-09-13 13:47 ` Petr Lautrbach
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).