Message ID | 20211123163851.438425-1-plautrba@redhat.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | semodule: Don't forget to munmap() data | expand |
On Tue, Nov 23, 2021 at 11:41 AM Petr Lautrbach <plautrba@redhat.com> wrote: > > semanage_module_extract() mmap()'s the module raw data but it leaves on > the caller to munmap() them. > > Reported-by: Ondrej Mosnacek <omosnace@redhat.com> > Signed-off-by: Petr Lautrbach <plautrba@redhat.com> Acked-by: James Carter <jwcart2@gmail.com> > --- > policycoreutils/semodule/semodule.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/policycoreutils/semodule/semodule.c b/policycoreutils/semodule/semodule.c > index 57f005ce2c62..94a9d131bb79 100644 > --- a/policycoreutils/semodule/semodule.c > +++ b/policycoreutils/semodule/semodule.c > @@ -394,6 +394,9 @@ static char *hash_module_data(const char *module_name, const int prio) { > sha256_buf[i * 2] = 0; > > cleanup_extract: > + if (data_len > 0) { > + munmap(data, data_len); > + } > semanage_module_info_destroy(sh, extract_info); > free(extract_info); > semanage_module_key_destroy(sh, modkey); > -- > 2.33.1 >
James Carter <jwcart2@gmail.com> writes: > On Tue, Nov 23, 2021 at 11:41 AM Petr Lautrbach <plautrba@redhat.com> wrote: >> >> semanage_module_extract() mmap()'s the module raw data but it leaves on >> the caller to munmap() them. >> >> Reported-by: Ondrej Mosnacek <omosnace@redhat.com> >> Signed-off-by: Petr Lautrbach <plautrba@redhat.com> > > Acked-by: James Carter <jwcart2@gmail.com> Merged. >> --- >> policycoreutils/semodule/semodule.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/policycoreutils/semodule/semodule.c b/policycoreutils/semodule/semodule.c >> index 57f005ce2c62..94a9d131bb79 100644 >> --- a/policycoreutils/semodule/semodule.c >> +++ b/policycoreutils/semodule/semodule.c >> @@ -394,6 +394,9 @@ static char *hash_module_data(const char *module_name, const int prio) { >> sha256_buf[i * 2] = 0; >> >> cleanup_extract: >> + if (data_len > 0) { >> + munmap(data, data_len); >> + } >> semanage_module_info_destroy(sh, extract_info); >> free(extract_info); >> semanage_module_key_destroy(sh, modkey); >> -- >> 2.33.1 >>
diff --git a/policycoreutils/semodule/semodule.c b/policycoreutils/semodule/semodule.c index 57f005ce2c62..94a9d131bb79 100644 --- a/policycoreutils/semodule/semodule.c +++ b/policycoreutils/semodule/semodule.c @@ -394,6 +394,9 @@ static char *hash_module_data(const char *module_name, const int prio) { sha256_buf[i * 2] = 0; cleanup_extract: + if (data_len > 0) { + munmap(data, data_len); + } semanage_module_info_destroy(sh, extract_info); free(extract_info); semanage_module_key_destroy(sh, modkey);
semanage_module_extract() mmap()'s the module raw data but it leaves on the caller to munmap() them. Reported-by: Ondrej Mosnacek <omosnace@redhat.com> Signed-off-by: Petr Lautrbach <plautrba@redhat.com> --- policycoreutils/semodule/semodule.c | 3 +++ 1 file changed, 3 insertions(+)