All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] tools: Fixes for 4.4
@ 2014-01-21 18:45 Ian Jackson
  2014-01-21 18:45 ` [PATCH 1/3] libxl: events: Pass correct nfds to poll Ian Jackson
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Ian Jackson @ 2014-01-21 18:45 UTC (permalink / raw)
  To: xen-devel; +Cc: George Dunlap

I think these three bugfixes are clear 4.4 material.

 a 1/3 libxl: events: Pass correct nfds to poll
 a 2/3 xl: Free optdata_begin when saving domain config
 a 3/3 xenstore: xs_suspend_evtchn_port: always free portstr

They have all been acked by Ian Campbell.

Thanks,
Ian.

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

* [PATCH 1/3] libxl: events: Pass correct nfds to poll
  2014-01-21 18:45 [PATCH v2 0/3] tools: Fixes for 4.4 Ian Jackson
@ 2014-01-21 18:45 ` Ian Jackson
  2014-01-21 18:45 ` [PATCH 2/3] xl: Free optdata_begin when saving domain config Ian Jackson
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Ian Jackson @ 2014-01-21 18:45 UTC (permalink / raw)
  To: xen-devel; +Cc: George Dunlap, Jim Fehlig, Ian Jackson, Ian Campbell

libxl_event.c:eventloop_iteration would pass the allocated pollfds
array size, rather than the used size, to poll (and to
afterpoll_internal).

The effect is that if the number of fds to poll on reduces, libxl will
poll on stale entries.  Because of the way the return value from poll
is processed these stale entries are often harmless because any events
coming back from poll ignored by libxl.  However, it could cause
malfunctions:

It could result in unwanted SIGTTIN/SIGTTOU/SIGPIPE, for example, if
the fd has been reused to refer to an object which can generate those
signals.  Alternatively, it could result in libxl spinning if the
stale entry refers to an fd which happens now to be ready for the
previously-requested operation.

I have tested this with a localhost migration and inspected the strace
output.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Jim Fehlig <jfehlig@suse.com>
Cc: Ian Campbell <Ian.Campbell@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
---
 tools/libxl/libxl_event.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c
index bdef7ac..1c48fee 100644
--- a/tools/libxl/libxl_event.c
+++ b/tools/libxl/libxl_event.c
@@ -1386,7 +1386,7 @@ static int eventloop_iteration(libxl__egc *egc, libxl__poller *poller) {
      * can unlock it when it polls.
      */
     EGC_GC;
-    int rc;
+    int rc, nfds;
     struct timeval now;
     
     rc = libxl__gettimeofday(gc, &now);
@@ -1395,7 +1395,7 @@ static int eventloop_iteration(libxl__egc *egc, libxl__poller *poller) {
     int timeout;
 
     for (;;) {
-        int nfds = poller->fd_polls_allocd;
+        nfds = poller->fd_polls_allocd;
         timeout = -1;
         rc = beforepoll_internal(gc, poller, &nfds, poller->fd_polls,
                                  &timeout, now);
@@ -1413,7 +1413,7 @@ static int eventloop_iteration(libxl__egc *egc, libxl__poller *poller) {
     }
 
     CTX_UNLOCK;
-    rc = poll(poller->fd_polls, poller->fd_polls_allocd, timeout);
+    rc = poll(poller->fd_polls, nfds, timeout);
     CTX_LOCK;
 
     if (rc < 0) {
@@ -1428,8 +1428,7 @@ static int eventloop_iteration(libxl__egc *egc, libxl__poller *poller) {
     rc = libxl__gettimeofday(gc, &now);
     if (rc) goto out;
 
-    afterpoll_internal(egc, poller,
-                       poller->fd_polls_allocd, poller->fd_polls, now);
+    afterpoll_internal(egc, poller, nfds, poller->fd_polls, now);
 
     rc = 0;
  out:
-- 
1.7.10.4

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

* [PATCH 2/3] xl: Free optdata_begin when saving domain config
  2014-01-21 18:45 [PATCH v2 0/3] tools: Fixes for 4.4 Ian Jackson
  2014-01-21 18:45 ` [PATCH 1/3] libxl: events: Pass correct nfds to poll Ian Jackson
@ 2014-01-21 18:45 ` Ian Jackson
  2014-01-21 18:45 ` [PATCH 3/3] xenstore: xs_suspend_evtchn_port: always free portstr Ian Jackson
  2014-01-27 12:14 ` [PATCH v2 0/3] tools: Fixes for 4.4 George Dunlap
  3 siblings, 0 replies; 6+ messages in thread
From: Ian Jackson @ 2014-01-21 18:45 UTC (permalink / raw)
  To: xen-devel; +Cc: George Dunlap, Ian Jackson, Ian Campbell

This makes valgrind a bit happier.

It is also
Coverity-CID: 1055903

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Ian Campbell <Ian.Campbell@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
---
 tools/libxl/xl_cmdimpl.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index d93e01b..aff6f90 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3442,6 +3442,8 @@ static void save_domain_core_writeconfig(int fd, const char *source,
                      ctx, fd, optdata_begin, hdr.optional_data_len,
                      source, "header"));
 
+    free(optdata_begin);
+
     fprintf(stderr, "Saving to %s new xl format (info"
             " 0x%"PRIx32"/0x%"PRIx32"/%"PRIu32")\n",
             source, hdr.mandatory_flags, hdr.optional_flags,
-- 
1.7.10.4

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

* [PATCH 3/3] xenstore: xs_suspend_evtchn_port: always free portstr
  2014-01-21 18:45 [PATCH v2 0/3] tools: Fixes for 4.4 Ian Jackson
  2014-01-21 18:45 ` [PATCH 1/3] libxl: events: Pass correct nfds to poll Ian Jackson
  2014-01-21 18:45 ` [PATCH 2/3] xl: Free optdata_begin when saving domain config Ian Jackson
@ 2014-01-21 18:45 ` Ian Jackson
  2014-01-27 12:14 ` [PATCH v2 0/3] tools: Fixes for 4.4 George Dunlap
  3 siblings, 0 replies; 6+ messages in thread
From: Ian Jackson @ 2014-01-21 18:45 UTC (permalink / raw)
  To: xen-devel; +Cc: George Dunlap, Ian Jackson

If portstr!=NULL but plen==0 this function would leak portstr.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>

---
v2: Fix whitespace error.
---
 tools/xenstore/xs.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/xenstore/xs.c b/tools/xenstore/xs.c
index a636498..dd03a85 100644
--- a/tools/xenstore/xs.c
+++ b/tools/xenstore/xs.c
@@ -1095,12 +1095,15 @@ int xs_suspend_evtchn_port(int domid)
     portstr = xs_read(xs, XBT_NULL, path, &plen);
     xs_daemon_close(xs);
 
-    if (!portstr || !plen)
-        return -1;
+    if (!portstr || !plen) {
+        port = -1;
+        goto out;
+    }
 
     port = atoi(portstr);
-    free(portstr);
 
+out:
+    free(portstr);
     return port;
 }
 
-- 
1.7.10.4

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

* Re: [PATCH v2 0/3] tools: Fixes for 4.4
  2014-01-21 18:45 [PATCH v2 0/3] tools: Fixes for 4.4 Ian Jackson
                   ` (2 preceding siblings ...)
  2014-01-21 18:45 ` [PATCH 3/3] xenstore: xs_suspend_evtchn_port: always free portstr Ian Jackson
@ 2014-01-27 12:14 ` George Dunlap
  2014-01-28 11:47   ` Ian Campbell
  3 siblings, 1 reply; 6+ messages in thread
From: George Dunlap @ 2014-01-27 12:14 UTC (permalink / raw)
  To: Ian Jackson, xen-devel

On 01/21/2014 06:45 PM, Ian Jackson wrote:
> I think these three bugfixes are clear 4.4 material.
>
>   a 1/3 libxl: events: Pass correct nfds to poll
>   a 2/3 xl: Free optdata_begin when saving domain config
>   a 3/3 xenstore: xs_suspend_evtchn_port: always free portstr
>
> They have all been acked by Ian Campbell.

All three:

Release-acked-by: George Dunlap <george.dunlap@eu.citrix.com>

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

* Re: [PATCH v2 0/3] tools: Fixes for 4.4
  2014-01-27 12:14 ` [PATCH v2 0/3] tools: Fixes for 4.4 George Dunlap
@ 2014-01-28 11:47   ` Ian Campbell
  0 siblings, 0 replies; 6+ messages in thread
From: Ian Campbell @ 2014-01-28 11:47 UTC (permalink / raw)
  To: George Dunlap; +Cc: xen-devel, Ian Jackson

On Mon, 2014-01-27 at 12:14 +0000, George Dunlap wrote:
> On 01/21/2014 06:45 PM, Ian Jackson wrote:
> > I think these three bugfixes are clear 4.4 material.
> >
> >   a 1/3 libxl: events: Pass correct nfds to poll
> >   a 2/3 xl: Free optdata_begin when saving domain config
> >   a 3/3 xenstore: xs_suspend_evtchn_port: always free portstr
> >
> > They have all been acked by Ian Campbell.
> 
> All three:
> 
> Release-acked-by: George Dunlap <george.dunlap@eu.citrix.com>

Applied.

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

end of thread, other threads:[~2014-01-28 11:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-21 18:45 [PATCH v2 0/3] tools: Fixes for 4.4 Ian Jackson
2014-01-21 18:45 ` [PATCH 1/3] libxl: events: Pass correct nfds to poll Ian Jackson
2014-01-21 18:45 ` [PATCH 2/3] xl: Free optdata_begin when saving domain config Ian Jackson
2014-01-21 18:45 ` [PATCH 3/3] xenstore: xs_suspend_evtchn_port: always free portstr Ian Jackson
2014-01-27 12:14 ` [PATCH v2 0/3] tools: Fixes for 4.4 George Dunlap
2014-01-28 11:47   ` Ian Campbell

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.