[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen stable-4.2] libxl: Hold the atfork lock while closing carefd
commit 56f56ff9fbb431fdfc0e0de975c1fdf77c8dcc25 Author: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> AuthorDate: Mon Feb 24 14:19:14 2014 +0000 Commit: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> CommitDate: Fri Apr 4 16:03:16 2014 +0100 libxl: Hold the atfork lock while closing carefd This avoids the process being forked while a carefd is recorded in the list but the actual fd has been closed. If that happened, a subsequent libxl_postfork_child_noexec would attempt to close the fd again. If we are lucky that results in a harmless warning; but if we are unlucky the fd number has been reused and we close an unrelated fd. This race has not been observed anywhere as far as we are aware. Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> Acked-by: Ian Campbell <Ian.Campbell@xxxxxxxxxx> CC: George Dunlap <george.dunlap@xxxxxxxxxxxxx> (cherry picked from commit 2a0c3a62ea4ad6c6bcbf80122b070f3ff3fe7dae) (cherry picked from commit 86c00cb6e2d78d5be861656a1e83956c9de96003) --- tools/libxl/libxl_fork.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tools/libxl/libxl_fork.c b/tools/libxl/libxl_fork.c index b6f0b2d..1dc30e1 100644 --- a/tools/libxl/libxl_fork.c +++ b/tools/libxl/libxl_fork.c @@ -135,9 +135,9 @@ void libxl_postfork_child_noexec(libxl_ctx *ctx) int libxl__carefd_close(libxl__carefd *cf) { if (!cf) return 0; + atfork_lock(); int r = cf->fd < 0 ? 0 : close(cf->fd); int esave = errno; - atfork_lock(); LIBXL_LIST_REMOVE(cf, entry); atfork_unlock(); free(cf); -- generated by git-patchbot for /home/xen/git/xen.git#stable-4.2 _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |