xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libxenctrl: Fix xc_interface_close() crash if it gets NULL as an argument
@ 2013-12-02 19:13 Daniel Kiper
  2013-12-03  9:47 ` Ian Campbell
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Kiper @ 2013-12-02 19:13 UTC (permalink / raw)
  To: ian.campbell, ian.jackson, stefano.stabellini, xen-devel; +Cc: Daniel Kiper

xc_interface_close() crashes if it gets NULL as an argument. However,
it just calls xc_interface_close_common() which is called by many
others functions. It means that they are also vulnerable. So fix above
mentioned issue by adding NULL check in xc_interface_close_common().
This way we fix similar issue in other functions which calls
xc_interface_close_common() too.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 tools/libxc/xc_private.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c
index 524862e..838fd21 100644
--- a/tools/libxc/xc_private.c
+++ b/tools/libxc/xc_private.c
@@ -198,6 +198,9 @@ static int xc_interface_close_common(xc_interface *xch)
 {
     int rc = 0;
 
+    if (!xch)
+	return 0;
+
     xc__hypercall_buffer_cache_release(xch);
 
     xtl_logger_destroy(xch->dombuild_logger_tofree);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] libxenctrl: Fix xc_interface_close() crash if it gets NULL as an argument
  2013-12-02 19:13 [PATCH] libxenctrl: Fix xc_interface_close() crash if it gets NULL as an argument Daniel Kiper
@ 2013-12-03  9:47 ` Ian Campbell
  2013-12-03 11:58   ` Daniel Kiper
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Campbell @ 2013-12-03  9:47 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: xen-devel, ian.jackson, stefano.stabellini

On Mon, 2013-12-02 at 20:13 +0100, Daniel Kiper wrote:
> xc_interface_close() crashes if it gets NULL as an argument. However,
> it just calls xc_interface_close_common() which is called by many
> others functions. It means that they are also vulnerable. So fix above
> mentioned issue by adding NULL check in xc_interface_close_common().
> This way we fix similar issue in other functions which calls
> xc_interface_close_common() too.
> 
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>

I suppose this makes sense in the same way that free(NULL) does:
        Acked-by: Ian Campbell <ian.campbell@citrix.com>

Did you observe this with a particular caller?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libxenctrl: Fix xc_interface_close() crash if it gets NULL as an argument
  2013-12-03  9:47 ` Ian Campbell
@ 2013-12-03 11:58   ` Daniel Kiper
  2013-12-04 14:53     ` Ian Campbell
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Kiper @ 2013-12-03 11:58 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel, ian.jackson, stefano.stabellini

On Tue, Dec 03, 2013 at 09:47:35AM +0000, Ian Campbell wrote:
> On Mon, 2013-12-02 at 20:13 +0100, Daniel Kiper wrote:
> > xc_interface_close() crashes if it gets NULL as an argument. However,
> > it just calls xc_interface_close_common() which is called by many
> > others functions. It means that they are also vulnerable. So fix above
> > mentioned issue by adding NULL check in xc_interface_close_common().
> > This way we fix similar issue in other functions which calls
> > xc_interface_close_common() too.
> >
> > Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
>
> I suppose this makes sense in the same way that free(NULL) does:
>         Acked-by: Ian Campbell <ian.campbell@citrix.com>

Thanks.

> Did you observe this with a particular caller?

Yes, I found this issue by chance in kaxec-tools. It is fixed
right now but I agree that this type of functions should
behave with NULL like free(NULL).

Daniel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libxenctrl: Fix xc_interface_close() crash if it gets NULL as an argument
  2013-12-03 11:58   ` Daniel Kiper
@ 2013-12-04 14:53     ` Ian Campbell
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Campbell @ 2013-12-04 14:53 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: xen-devel, ian.jackson, stefano.stabellini

On Tue, 2013-12-03 at 12:58 +0100, Daniel Kiper wrote:
> On Tue, Dec 03, 2013 at 09:47:35AM +0000, Ian Campbell wrote:
> > On Mon, 2013-12-02 at 20:13 +0100, Daniel Kiper wrote:
> > > xc_interface_close() crashes if it gets NULL as an argument. However,
> > > it just calls xc_interface_close_common() which is called by many
> > > others functions. It means that they are also vulnerable. So fix above
> > > mentioned issue by adding NULL check in xc_interface_close_common().
> > > This way we fix similar issue in other functions which calls
> > > xc_interface_close_common() too.
> > >
> > > Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> >
> > I suppose this makes sense in the same way that free(NULL) does:
> >         Acked-by: Ian Campbell <ian.campbell@citrix.com>
> 
> Thanks.

And now applied.

> > Did you observe this with a particular caller?
> 
> Yes, I found this issue by chance in kaxec-tools. It is fixed

Great, thanks.

> right now but I agree that this type of functions should
> behave with NULL like free(NULL).
> 
> Daniel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-04 14:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-02 19:13 [PATCH] libxenctrl: Fix xc_interface_close() crash if it gets NULL as an argument Daniel Kiper
2013-12-03  9:47 ` Ian Campbell
2013-12-03 11:58   ` Daniel Kiper
2013-12-04 14:53     ` Ian Campbell

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 NNTP newsgroup(s).