xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-4.10] libs/evtchn: Remove active handler on clean-up or failure
@ 2017-11-10 17:10 Julien Grall
  2017-11-13  9:04 ` Ross Lagerwall
  0 siblings, 1 reply; 15+ messages in thread
From: Julien Grall @ 2017-11-10 17:10 UTC (permalink / raw)
  To: xen-devel; +Cc: ross.lagerwall, Julien Grall, wei.liu2, ian.jackson

Commit 89d55473ed16543044a31d1e0d4660cf5a3f49df "xentoolcore_restrict_all:
Implement for libxenevtchn" added a call to register allowing to
restrict the event channel.

However, the call to deregister the handler was not performed if open
failed or when closing the event channel. This will result to corrupt
the list of handlers and potentially crash the application later one.

Fix it by calling xentoolcore_deregister_active_handle on failure and
closure.

Signed-off-by: Julien Grall <julien.grall@linaro.org>

---

This patch is fixing a bug introduced after the code freeze by
"xentoolcore_restrict_all: Implement for libxenevtchn".

The call to xentoolcore_deregister_active_handle is done at the same
place as for the grants. But I am not convinced this is thread safe as
there are potential race between close the event channel and restict
handler. Do we care about that?
---
 tools/libs/evtchn/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/libs/evtchn/core.c b/tools/libs/evtchn/core.c
index 14b7549a6b..2dba58bf00 100644
--- a/tools/libs/evtchn/core.c
+++ b/tools/libs/evtchn/core.c
@@ -56,6 +56,7 @@ xenevtchn_handle *xenevtchn_open(xentoollog_logger *logger, unsigned open_flags)
 
 err:
     osdep_evtchn_close(xce);
+    xentoolcore__deregister_active_handle(&xce->tc_ah);
     xtl_logger_destroy(xce->logger_tofree);
     free(xce);
     return NULL;
@@ -69,6 +70,7 @@ int xenevtchn_close(xenevtchn_handle *xce)
         return 0;
 
     rc = osdep_evtchn_close(xce);
+    xentoolcore__deregister_active_handle(&xce->tc_ah);
     xtl_logger_destroy(xce->logger_tofree);
     free(xce);
     return rc;
-- 
2.11.0


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

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

end of thread, other threads:[~2017-11-16 15:01 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-10 17:10 [PATCH for-4.10] libs/evtchn: Remove active handler on clean-up or failure Julien Grall
2017-11-13  9:04 ` Ross Lagerwall
2017-11-14 11:51   ` Ian Jackson
2017-11-14 12:05     ` Ross Lagerwall
2017-11-14 12:15       ` Ian Jackson
2017-11-14 12:14     ` Julien Grall
2017-11-14 13:53       ` Wei Liu
2017-11-14 14:26         ` Julien Grall
2017-11-14 12:15     ` [PATCH] tools: xentoolcore_restrict_all: Do deregistration before close Ian Jackson
2017-11-14 14:02       ` Wei Liu
2017-11-14 14:19         ` Julien Grall
2017-11-14 14:57           ` [PATCH for-4.10] " Ian Jackson
2017-11-16 15:01             ` Julien Grall
2017-11-14 14:26       ` [PATCH] " Ross Lagerwall
2017-11-14 15:01         ` Ian Jackson

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).