* [PATCH] tools/libxl: Fix leaking ssid_label in libxl_name_to_domid
@ 2019-01-27 5:45 Tamas K Lengyel
2019-01-28 12:15 ` Wei Liu
0 siblings, 1 reply; 4+ messages in thread
From: Tamas K Lengyel @ 2019-01-27 5:45 UTC (permalink / raw)
To: xen-devel; +Cc: Wei Liu, Tamas K Lengyel, Ian Jackson
On systems with XSM enabled libxl_name_to_domid leaks memory
allocated for ssid_label:
==2693== 53 bytes in 2 blocks are definitely lost in loss record 4 of 8
==2693== at 0x4C2BE6D: malloc (vg_replace_malloc.c:309)
==2693== by 0x6C0A3B9: strdup (strdup.c:42)
==2693== by 0x5108294: libxl_flask_sid_to_context (libxl_flask.c:39)
==2693== by 0x50C2B64: libxl__xcinfo2xlinfo (libxl_domain.c:267)
==2693== by 0x50C2E02: libxl_list_domain (libxl_domain.c:308)
==2693== by 0x508A3C5: libxl_name_to_domid (libxl_utils.c:77)
Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
tools/libxl/libxl_utils.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
index e50e094c48..99abfa5497 100644
--- a/tools/libxl/libxl_utils.c
+++ b/tools/libxl/libxl_utils.c
@@ -79,6 +79,8 @@ int libxl_name_to_domid(libxl_ctx *ctx, const char *name,
return ERROR_NOMEM;
for (i = 0; i < nb_domains; i++) {
+ if (dominfo[i].ssid_label)
+ free(dominfo[i].ssid_label);
domname = libxl_domid_to_name(ctx, dominfo[i].domid);
if (!domname)
continue;
--
2.20.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tools/libxl: Fix leaking ssid_label in libxl_name_to_domid
2019-01-27 5:45 [PATCH] tools/libxl: Fix leaking ssid_label in libxl_name_to_domid Tamas K Lengyel
@ 2019-01-28 12:15 ` Wei Liu
2019-01-29 0:57 ` Tamas K Lengyel
0 siblings, 1 reply; 4+ messages in thread
From: Wei Liu @ 2019-01-28 12:15 UTC (permalink / raw)
To: Tamas K Lengyel; +Cc: xen-devel, Ian Jackson, Wei Liu
On Sat, Jan 26, 2019 at 10:45:07PM -0700, Tamas K Lengyel wrote:
> On systems with XSM enabled libxl_name_to_domid leaks memory
> allocated for ssid_label:
>
> ==2693== 53 bytes in 2 blocks are definitely lost in loss record 4 of 8
> ==2693== at 0x4C2BE6D: malloc (vg_replace_malloc.c:309)
> ==2693== by 0x6C0A3B9: strdup (strdup.c:42)
> ==2693== by 0x5108294: libxl_flask_sid_to_context (libxl_flask.c:39)
> ==2693== by 0x50C2B64: libxl__xcinfo2xlinfo (libxl_domain.c:267)
> ==2693== by 0x50C2E02: libxl_list_domain (libxl_domain.c:308)
> ==2693== by 0x508A3C5: libxl_name_to_domid (libxl_utils.c:77)
>
> Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
> ---
> tools/libxl/libxl_utils.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
> index e50e094c48..99abfa5497 100644
> --- a/tools/libxl/libxl_utils.c
> +++ b/tools/libxl/libxl_utils.c
> @@ -79,6 +79,8 @@ int libxl_name_to_domid(libxl_ctx *ctx, const char *name,
> return ERROR_NOMEM;
>
> for (i = 0; i < nb_domains; i++) {
> + if (dominfo[i].ssid_label)
> + free(dominfo[i].ssid_label);
> domname = libxl_domid_to_name(ctx, dominfo[i].domid);
> if (!domname)
> continue;
Thanks for reporting this issue. I think your patch isn't future-proof.
Can you try the following patch?
---8<---
From fc9f9ad912cb61085a5bfb60aef3643dcd82a496 Mon Sep 17 00:00:00 2001
From: Wei Liu <wei.liu2@citrix.com>
Date: Mon, 28 Jan 2019 12:10:12 +0000
Subject: [PATCH] libxl: correctly dispose of dominfo list in
libxl_name_to_domid
Tamas reported ssid_label was leaked. Use the designated function to
free dominfo list to fix the leakage.
Reported-by: Tamas K Lengyel <tamas@tklengyel.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
tools/libxl/libxl_utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
index e50e094c48..f360f5e228 100644
--- a/tools/libxl/libxl_utils.c
+++ b/tools/libxl/libxl_utils.c
@@ -90,7 +90,7 @@ int libxl_name_to_domid(libxl_ctx *ctx, const char *name,
}
free(domname);
}
- free(dominfo);
+ libxl_dominfo_list_free(dominfo, nb_domains);
return ret;
}
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tools/libxl: Fix leaking ssid_label in libxl_name_to_domid
2019-01-28 12:15 ` Wei Liu
@ 2019-01-29 0:57 ` Tamas K Lengyel
2019-01-29 10:06 ` Wei Liu
0 siblings, 1 reply; 4+ messages in thread
From: Tamas K Lengyel @ 2019-01-29 0:57 UTC (permalink / raw)
To: Wei Liu; +Cc: Xen-devel, Ian Jackson
On Mon, Jan 28, 2019 at 5:16 AM Wei Liu <wei.liu2@citrix.com> wrote:
>
> On Sat, Jan 26, 2019 at 10:45:07PM -0700, Tamas K Lengyel wrote:
> > On systems with XSM enabled libxl_name_to_domid leaks memory
> > allocated for ssid_label:
> >
> > ==2693== 53 bytes in 2 blocks are definitely lost in loss record 4 of 8
> > ==2693== at 0x4C2BE6D: malloc (vg_replace_malloc.c:309)
> > ==2693== by 0x6C0A3B9: strdup (strdup.c:42)
> > ==2693== by 0x5108294: libxl_flask_sid_to_context (libxl_flask.c:39)
> > ==2693== by 0x50C2B64: libxl__xcinfo2xlinfo (libxl_domain.c:267)
> > ==2693== by 0x50C2E02: libxl_list_domain (libxl_domain.c:308)
> > ==2693== by 0x508A3C5: libxl_name_to_domid (libxl_utils.c:77)
> >
> > Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com>
> > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > Cc: Wei Liu <wei.liu2@citrix.com>
> > ---
> > tools/libxl/libxl_utils.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
> > index e50e094c48..99abfa5497 100644
> > --- a/tools/libxl/libxl_utils.c
> > +++ b/tools/libxl/libxl_utils.c
> > @@ -79,6 +79,8 @@ int libxl_name_to_domid(libxl_ctx *ctx, const char *name,
> > return ERROR_NOMEM;
> >
> > for (i = 0; i < nb_domains; i++) {
> > + if (dominfo[i].ssid_label)
> > + free(dominfo[i].ssid_label);
> > domname = libxl_domid_to_name(ctx, dominfo[i].domid);
> > if (!domname)
> > continue;
>
> Thanks for reporting this issue. I think your patch isn't future-proof.
>
> Can you try the following patch?
Works too.
Thanks,
Tamas
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tools/libxl: Fix leaking ssid_label in libxl_name_to_domid
2019-01-29 0:57 ` Tamas K Lengyel
@ 2019-01-29 10:06 ` Wei Liu
0 siblings, 0 replies; 4+ messages in thread
From: Wei Liu @ 2019-01-29 10:06 UTC (permalink / raw)
To: Tamas K Lengyel; +Cc: Xen-devel, Wei Liu, Ian Jackson
On Mon, Jan 28, 2019 at 05:57:04PM -0700, Tamas K Lengyel wrote:
> On Mon, Jan 28, 2019 at 5:16 AM Wei Liu <wei.liu2@citrix.com> wrote:
> >
> > On Sat, Jan 26, 2019 at 10:45:07PM -0700, Tamas K Lengyel wrote:
> > > On systems with XSM enabled libxl_name_to_domid leaks memory
> > > allocated for ssid_label:
> > >
> > > ==2693== 53 bytes in 2 blocks are definitely lost in loss record 4 of 8
> > > ==2693== at 0x4C2BE6D: malloc (vg_replace_malloc.c:309)
> > > ==2693== by 0x6C0A3B9: strdup (strdup.c:42)
> > > ==2693== by 0x5108294: libxl_flask_sid_to_context (libxl_flask.c:39)
> > > ==2693== by 0x50C2B64: libxl__xcinfo2xlinfo (libxl_domain.c:267)
> > > ==2693== by 0x50C2E02: libxl_list_domain (libxl_domain.c:308)
> > > ==2693== by 0x508A3C5: libxl_name_to_domid (libxl_utils.c:77)
> > >
> > > Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com>
> > > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > > Cc: Wei Liu <wei.liu2@citrix.com>
> > > ---
> > > tools/libxl/libxl_utils.c | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
> > > index e50e094c48..99abfa5497 100644
> > > --- a/tools/libxl/libxl_utils.c
> > > +++ b/tools/libxl/libxl_utils.c
> > > @@ -79,6 +79,8 @@ int libxl_name_to_domid(libxl_ctx *ctx, const char *name,
> > > return ERROR_NOMEM;
> > >
> > > for (i = 0; i < nb_domains; i++) {
> > > + if (dominfo[i].ssid_label)
> > > + free(dominfo[i].ssid_label);
> > > domname = libxl_domid_to_name(ctx, dominfo[i].domid);
> > > if (!domname)
> > > continue;
> >
> > Thanks for reporting this issue. I think your patch isn't future-proof.
> >
> > Can you try the following patch?
>
> Works too.
Thank you. I will add you reported-by and tested-by and submit this
patch properly.
Wei.
>
> Thanks,
> Tamas
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-29 10:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-27 5:45 [PATCH] tools/libxl: Fix leaking ssid_label in libxl_name_to_domid Tamas K Lengyel
2019-01-28 12:15 ` Wei Liu
2019-01-29 0:57 ` Tamas K Lengyel
2019-01-29 10:06 ` Wei Liu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.