From: Ian Campbell Subject: Re: [PATCH 3/3] libxl: Fix carefd lock leak in save callout Date: Mon, 24 Feb 2014 14:48:41 +0000 Message-ID: <1393253321.16570.81.camel@kazak.uk.xensource.com> References: <1393251555-22418-1-git-send-email-ian.jackson@eu.citrix.com> <1393251555-22418-4-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1393251555-22418-4-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: George Dunlap , xen-devel@lists.xensource.com, M A Young List-Id: xen-devel@lists.xenproject.org On Mon, 2014-02-24 at 14:19 +0000, Ian Jackson wrote: > If libxl_pipe fails we leave the carefd locked, which translates to > the atfork lock remaining held. This would probably cause the process > to deadlock shortly afterwards. > > Of course libxl_pipe is very unlikely to fail unless things are > already going very badly. This bug has not been observed anywhere as > far as we are aware. > > Signed-off-by: Ian Jackson Acked-by: Ian Campbell > CC: George Dunlap > --- > tools/libxl/libxl_save_callout.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/tools/libxl/libxl_save_callout.c b/tools/libxl/libxl_save_callout.c > index 6e45b2f..e3bda8f 100644 > --- a/tools/libxl/libxl_save_callout.c > +++ b/tools/libxl/libxl_save_callout.c > @@ -185,7 +185,11 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs, > for (childfd=0; childfd<2; childfd++) { > /* Setting up the pipe for the child's fd childfd */ > int fds[2]; > - if (libxl_pipe(CTX,fds)) { rc = ERROR_FAIL; goto out; } > + if (libxl_pipe(CTX,fds)) { > + rc = ERROR_FAIL; > + libxl__carefd_unlock(); > + goto out; > + } > int childs_end = childfd==0 ? 0 /*read*/ : 1 /*write*/; > int our_end = childfd==0 ? 1 /*write*/ : 0 /*read*/; > childs_pipes[childfd] = libxl__carefd_record(CTX, fds[childs_end]);