Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57BBAC433E0 for ; Fri, 12 Jun 2020 10:09:56 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 07436206A4 for ; Fri, 12 Jun 2020 10:09:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rdDSD0Sq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 07436206A4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjgcx-0000IX-Bm; Fri, 12 Jun 2020 10:09:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjgcw-0000IS-4e for xen-devel@lists.xenproject.org; Fri, 12 Jun 2020 10:09:34 +0000 X-Inumbo-ID: cfb4e4dc-ac94-11ea-bb8b-bc764e2007e4 Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id cfb4e4dc-ac94-11ea-bb8b-bc764e2007e4; Fri, 12 Jun 2020 10:09:33 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id c71so7561469wmd.5 for ; Fri, 12 Jun 2020 03:09:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:reply-to:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-transfer-encoding:content-language :thread-index; bh=MxgozEb2i3R/ZypnNmn6ONFzbH7k/LVj1DaDP20JXYk=; b=rdDSD0Sqo7CoUWmQBgYbwJxhEuZ8n+t1g8ucShTt9XiCODFpu4ZeiFwYitT9h/yXG8 LO8lHQ99ZCKBgLrB2S40fHfipwAFdKMml6SqL6MsIPxie+CMlClDBsH3y4i3t6+8zu7l LVShV3udvNKxq2BwYNxhjix1VL3B4FsC3OCub2I+yT7/zI8X6fGKYTTk9w0MRSa3TGwX caMXqWsZYrJ7CkXRNMIbTgAYbezfdgddk/xDHkUdLgX7rt57GWGcOGA7k2mUByUeAA1Q YqCCGDIfSBiiu3sBeNMwGMghrxCnGBCxLy56vyya3wwWgpUNGpRUCUQSoxgTFDIhHG/u hbrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:reply-to:to:cc:references:in-reply-to :subject:date:message-id:mime-version:content-transfer-encoding :content-language:thread-index; bh=MxgozEb2i3R/ZypnNmn6ONFzbH7k/LVj1DaDP20JXYk=; b=ECen1mNFmRF/3q4zdK+8AFVJk10i/McCl+25GqhmAhLh3TTB1X5R6PVvEbfT7v0bgP tBSn4YQK0rdxcMssaAy8q6oGGrQxkzeIFZc/RUdcoMgsn1tDpLcEcVopzHrZOghEvn16 xcazEoSY2TuQqgJ2szOYWWJZGdiBnET5MJEILFWNAY9hT6tnI7ESmSHuT/qIIHED+igC j3AleklnQSNX0t7F04dHsYbTz9aPHKHGEjlrFwjmWlwqaSZ+M19DQoCaEubwFN3A+erG +Om/DwZZWFqa8YJavtkN/8E6Y+SnGSHuhfcnTVXiNVqFWJ59IXGFRYSueC4h6HJvcdRU 18+g== X-Gm-Message-State: AOAM532Fe0adSwZ1UPApg0gXuuJiqjLB1JmfTOQINixBEFaDw7bVZtWw D9KCwdf7ucOcn+bjBzvMZII= X-Google-Smtp-Source: ABdhPJzudNR6VzVn46ftmM/IMMdNpZ79rD4rj8q6PMRLHjPkHaRRaZzxDCakkjNGeujEfpWCNjzaQg== X-Received: by 2002:a1c:de46:: with SMTP id v67mr12480072wmg.146.1591956572339; Fri, 12 Jun 2020 03:09:32 -0700 (PDT) Received: from CBGR90WXYV0 (54-240-197-226.amazon.com. [54.240.197.226]) by smtp.gmail.com with ESMTPSA id o10sm9317514wrq.40.2020.06.12.03.09.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jun 2020 03:09:31 -0700 (PDT) From: Paul Durrant X-Google-Original-From: "Paul Durrant" To: "'Andrew Cooper'" , "'Xen-devel'" References: <20200610114004.30023-1-andrew.cooper3@citrix.com> <010401d6408a$2c57bba0$850732e0$@xen.org> <765b4fed-60d3-9c4a-d6b7-bcd9893c525b@citrix.com> In-Reply-To: <765b4fed-60d3-9c4a-d6b7-bcd9893c525b@citrix.com> Subject: RE: [PATCH for-4.14] tools: fix error path of xendevicemodel_open() Date: Fri, 12 Jun 2020 11:09:30 +0100 Message-ID: <000101d640a1$90d46800$b27d3800$@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Content-Language: en-gb Thread-Index: AQJVAhO9pRR+GTACAAMIE1rLmlKQ5AG8VqlrAqKoKA6ntEbMEA== X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Reply-To: paul@xen.org Cc: 'Juergen Gross' , 'Ian Jackson' , 'Wei Liu' Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" > -----Original Message----- > From: Andrew Cooper > Sent: 12 June 2020 10:54 > To: paul@xen.org; 'Xen-devel' > Cc: 'Ian Jackson' ; 'Wei Liu' ; 'Juergen Gross' > Subject: Re: [PATCH for-4.14] tools: fix error path of xendevicemodel_open() > > On 12/06/2020 08:22, Paul Durrant wrote: > >> -----Original Message----- > >> From: Andrew Cooper > >> Sent: 10 June 2020 12:40 > >> To: Xen-devel > >> Cc: Andrew Cooper ; Ian Jackson ; Wei Liu > >> ; Juergen Gross ; Paul Durrant > >> Subject: [PATCH for-4.14] tools: fix error path of xendevicemodel_open() > >> > >> c/s 6902cb00e03 "tools/libxendevicemodel: extract functions and add a compat > >> layer" introduced calls to both xencall_open() and osdep_xendevicemodel_open() > >> but failed to fix up the error path. > >> > >> c/s f68c7c618a3 "libs/devicemodel: free xencall handle in error path in > >> _open()" fixed up the xencall_open() aspect of the error path (missing the > >> osdep_xendevicemodel_open() aspect), but positioned the xencall_close() > >> incorrectly, creating the same pattern proved to be problematic by c/s > >> 30a72f02870 "tools: fix error path of xenhypfs_open()". > >> > >> Reposition xtl_logger_destroy(), and introduce the missing > >> osdep_xendevicemodel_close(). > >> > >> Fixes: 6902cb00e03 ("tools/libxendevicemodel: extract functions and add a compat layer") > >> Fixes: f68c7c618a3 ("libs/devicemodel: free xencall handle in error path in _open()") > >> Backport: 4.9+ > >> Signed-off-by: Andrew Cooper > >> --- > >> CC: Ian Jackson > >> CC: Wei Liu > >> CC: Juergen Gross > >> CC: Paul Durrant > >> > >> RFC - this is still broken. > >> > > I'm slightly confused. Do you want this in 4.14 in this form or are you expecting to update it? > > In this form, it is an improvement over before. > > There is still the crash described below which needs some form of > figuring out and fixing. > Ok, in which case consider it... Release-acked-by: Paul Durrant > ~Andrew > > > > > Paul > > > >> Failure to create the logger will still hit the NULL deference, in all of the > >> stable libs, not just devicemodel. > >> > >> Also, unless I'd triple checked the history, I was about to reintroduce the > >> deadlock from c/s 9976f3874d4, because it totally counterintuitive wrong to > >> expect setup and teardown in opposite orders. > >> --- > >> tools/libs/devicemodel/core.c | 3 ++- > >> 1 file changed, 2 insertions(+), 1 deletion(-) > >> > >> diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c > >> index db501d9e80..4d4063956d 100644 > >> --- a/tools/libs/devicemodel/core.c > >> +++ b/tools/libs/devicemodel/core.c > >> @@ -67,9 +67,10 @@ xendevicemodel_handle *xendevicemodel_open(xentoollog_logger *logger, > >> return dmod; > >> > >> err: > >> - xtl_logger_destroy(dmod->logger_tofree); > >> + osdep_xendevicemodel_close(dmod); > >> xentoolcore__deregister_active_handle(&dmod->tc_ah); > >> xencall_close(dmod->xcall); > >> + xtl_logger_destroy(dmod->logger_tofree); > >> free(dmod); > >> return NULL; > >> } > >> -- > >> 2.11.0 > >