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=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 90DC1C433E6 for ; Thu, 28 Jan 2021 14:48:17 +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 3452664DE8 for ; Thu, 28 Jan 2021 14:48:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3452664DE8 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.77114.139494 (Exim 4.92) (envelope-from ) id 1l58ad-00088I-1L; Thu, 28 Jan 2021 14:48:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 77114.139494; Thu, 28 Jan 2021 14:48:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l58ac-00088B-Uf; Thu, 28 Jan 2021 14:48:06 +0000 Received: by outflank-mailman (input) for mailman id 77114; Thu, 28 Jan 2021 14:48:05 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l58ab-000882-QN for xen-devel@lists.xenproject.org; Thu, 28 Jan 2021 14:48:05 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id de339bd3-d126-42f4-9d44-8437d222389c; Thu, 28 Jan 2021 14:48:05 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2DE36ACBA; Thu, 28 Jan 2021 14:48:04 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: de339bd3-d126-42f4-9d44-8437d222389c X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611845284; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tI101rdws8S8QrrRhoEwqvoto1+NPzPP1Q9en7PJHPA=; b=pi3y//QVHLidCmACwz8h2e7BhEZHm/DtXfSdXYBO8Pf1qGlX53NGweXFW1LfRYvgnVjEZ7 QmT4jWmaG5ucYCvHd3ZF9QVc3Qdx0a98+FHMZYAhyCf2mZPSkaELNhszS9G1BJJ9LbU5Lp yd+C3Otb0usEHexAdANri4wM4xKtMrs= Subject: Re: [PATCH v3] x86/mm: Short circuit damage from "fishy" ref/typecount failure To: Andrew Cooper Cc: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , Wei Liu , Paul Durrant , Tamas K Lengyel , Xen-devel References: <20210119094122.23713-1-andrew.cooper3@citrix.com> <20210119130254.27058-1-andrew.cooper3@citrix.com> <98f64276-ec5d-7242-f10f-126fe7ee1f7e@suse.com> <45f5d1f0-1a89-706f-f202-91ddb1d8b094@citrix.com> <0c279f99-e74e-ced0-4947-b9a104160671@citrix.com> From: Jan Beulich Message-ID: <144d3985-67fe-10d3-11ef-3452b6f2656a@suse.com> Date: Thu, 28 Jan 2021 15:48:04 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <0c279f99-e74e-ced0-4947-b9a104160671@citrix.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 25.01.2021 18:59, Andrew Cooper wrote: > I am literally not changing the current behaviour.  Xen *will* hit a > BUG() if any of these domain_crash() paths are taken. > > If you do not believe me, then please go and actually check what happens > when simulating a ref-acquisition failure. Okay, I've started with the debugging patch below. After the other error handling fixed (see the patch just sent), this works fine and - with the changes not marked "//temp" - even stops leaking the page in that case. This latter fact proves (to me) that at least on this path there's no ref lost anywhere, and there's also no BUG() elsewhere that we would trigger. As re-assurance I observed subsequent run attempts of the same guest to end up re-using this same page for this same purpose in a number of cases. You patch altered two other, similar paths, and I can't exclude there to be a problem there. Since the exercise was useful for fixing the other two bugs anyway, I guess I'll do the same for those paths later on and see what I get. Jan --- unstable.orig/xen/arch/x86/hvm/vmx/vmx.c +++ unstable/xen/arch/x86/hvm/vmx/vmx.c @@ -3076,13 +3076,22 @@ static int vmx_alloc_vlapic_mapping(stru if ( !pg ) return -ENOMEM; - if ( !get_page_and_type(pg, d, PGT_writable_page) ) +printk("%pd: APIC access MFN: %lx (c=%lx t=%lx)\n", d, mfn_x(page_to_mfn(pg)), pg->count_info, pg->u.inuse.type_info);//temp +//temp if ( !get_page_and_type(pg, d, PGT_writable_page) ) { /* * The domain can't possibly know about this page yet, so failure * here is a clear indication of something fishy going on. */ domain_crash(d); + if ( get_page(pg, d) ) + { + put_page_alloc_ref(pg); +printk("%pd: MFN %lx: (c=%lx t=%lx)\n", d, mfn_x(page_to_mfn(pg)), pg->count_info, pg->u.inuse.type_info);//temp + put_page(pg); + } + else + printk("%pd: leaking MFN %lx\n", d, mfn_x(page_to_mfn(pg))); return -ENODATA; }