All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libxc: fix segfault on uninitialized xch->fmem
@ 2017-04-03 16:02 Seraphime Kirkovski
  2017-04-04 10:15 ` Wei Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Seraphime Kirkovski @ 2017-04-03 16:02 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Wei Liu, Seraphime Kirkovski

Currently in xc_interface_open, xch->fmem is not initialized
and in some rare case the code fails before ever assigning a value
to it.

I got this in master:

   $ sudo ./xl/xl run
   xencall: error: Could not obtain handle on privileged command interface: No such file or directory
   Segmentation fault

This initializes xch->fmem to NULL

Signed-off-by: Seraphime Kirkovski <kirkseraph@gmail.com>
---
 tools/libxc/xc_private.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c
index 72e6242417..4ed46fde5f 100644
--- a/tools/libxc/xc_private.c
+++ b/tools/libxc/xc_private.c
@@ -32,6 +32,7 @@ struct xc_interface_core *xc_interface_open(xentoollog_logger *logger,
 {
     struct xc_interface_core xch_buf, *xch = &xch_buf;
 
+    xch->fmem = NULL;
     xch->flags = open_flags;
     xch->dombuild_logger_file = 0;
     xc_clear_last_error(xch);
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH] libxc: fix segfault on uninitialized xch->fmem
  2017-04-03 16:02 [PATCH] libxc: fix segfault on uninitialized xch->fmem Seraphime Kirkovski
@ 2017-04-04 10:15 ` Wei Liu
  2017-04-04 11:33   ` Seraphime Kirkovski
  0 siblings, 1 reply; 3+ messages in thread
From: Wei Liu @ 2017-04-04 10:15 UTC (permalink / raw)
  To: Seraphime Kirkovski; +Cc: Ian Jackson, Wei Liu, xen-devel

On Mon, Apr 03, 2017 at 06:02:30PM +0200, Seraphime Kirkovski wrote:
> Currently in xc_interface_open, xch->fmem is not initialized
> and in some rare case the code fails before ever assigning a value
> to it.
> 
> I got this in master:
> 
>    $ sudo ./xl/xl run
>    xencall: error: Could not obtain handle on privileged command interface: No such file or directory
>    Segmentation fault
> 
> This initializes xch->fmem to NULL
> 
> Signed-off-by: Seraphime Kirkovski <kirkseraph@gmail.com>
> ---
>  tools/libxc/xc_private.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c
> index 72e6242417..4ed46fde5f 100644
> --- a/tools/libxc/xc_private.c
> +++ b/tools/libxc/xc_private.c
> @@ -32,6 +32,7 @@ struct xc_interface_core *xc_interface_open(xentoollog_logger *logger,
>  {
>      struct xc_interface_core xch_buf, *xch = &xch_buf;
>  
> +    xch->fmem = NULL;

Since there are a few handles in xch, it would be better to initialise
them all at once by doing:

    struct xc_interface_core xch_buf = { 0 }

>      xch->flags = open_flags;
>      xch->dombuild_logger_file = 0;
>      xc_clear_last_error(xch);
> -- 
> 2.11.0
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH] libxc: fix segfault on uninitialized xch->fmem
  2017-04-04 10:15 ` Wei Liu
@ 2017-04-04 11:33   ` Seraphime Kirkovski
  0 siblings, 0 replies; 3+ messages in thread
From: Seraphime Kirkovski @ 2017-04-04 11:33 UTC (permalink / raw)
  To: Wei Liu; +Cc: ian.jackson, xen-devel

On Tue, Apr 04, 2017 at 11:15:07AM +0100, Wei Liu wrote:
> Since there are a few handles in xch, it would be better to initialise
> them all at once by doing:
> 
>     struct xc_interface_core xch_buf = { 0 }
> 
> >      xch->flags = open_flags;
> >      xch->dombuild_logger_file = 0;
> >      xc_clear_last_error(xch);
> > -- 
> > 2.11.0
> > 

Hi, thanks for the reply.

Literally 10 minutes after sending this, I thought that a bzero would
be better. Will send a V2 shortly.

(Sorry about the resend, mailer problems...)

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

end of thread, other threads:[~2017-04-04 11:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-03 16:02 [PATCH] libxc: fix segfault on uninitialized xch->fmem Seraphime Kirkovski
2017-04-04 10:15 ` Wei Liu
2017-04-04 11:33   ` Seraphime Kirkovski

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.