Received: by 10.223.176.46 with SMTP id f43csp576837wra; Thu, 18 Jan 2018 22:24:00 -0800 (PST) X-Google-Smtp-Source: ACJfBos05l00l8ZDk0prZauBUBP2QswOAUbFBdsgtGwUiqwSu8/Z7n8H++hkO5x4iqSdsUT5w+1y X-Received: by 2002:a17:902:bd44:: with SMTP id b4-v6mr1083950plx.220.1516343040855; Thu, 18 Jan 2018 22:24:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516343040; cv=none; d=google.com; s=arc-20160816; b=DEl4AUlxEs6RdzUA6SSRTAkeOBg5gWhWJrhbmk2bic+0O0UENgOgC7gzeeAmaL7DCP bokqcciyagi+lJKhSPxiLozIHET+Bi8py1SK1mQR6/RaY5ikNehrupeDdaIH+2LAFfi3 DztHQ8PEe39+ML4RfYD51VNeljooxZWjKuikpeiQiqSNHoHtaGmu0/1CENaALx/4xRzo 6Zkrc/qPlnMa6QyiT842isXxsjP273VuWroEC06dyEx3a6lTRJr6RwHy8g2QL4nsRhCJ Fke2meV8/ERHY/Q5Ry/kLXMUixe/nPfKhp88zWR0dhmmwKKeqlWe02ulyuskM2sWYb8u IvbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :references:subject:cc:to:mime-version:user-agent:from:date :message-id:arc-authentication-results; bh=/CKdfQRjB39txk+LSfZes7oa/hHhPQFNI8Gsj3ClVYE=; b=W136MMacMAiuQ4aAH9bJiUmGO4MQrNyC+7jpuHIxFWYyQUFBuPaMBZdxaehWnMgsSC IoB/Wmn3sOcYLnCphvy4OR29Ihyuekpa4119mRT48SWZhC0OemG4aQLgeGn1bufyZ1+Z IhNyjyx6PiQQHUUZkHHfxgH7xmL9WWBx6fPGnVLFZ+rCgC1jmbrCsPtUUkAOmntX+1GB vI2K018xmbXLlAcG/BecBGUpCBVZpiLm+whQH5bPMEMkPA6PGh1sW+qV1hUQSYO4ML8I 5BIiyMSr73IdaPr5KyGhITeu+IDo/HEXJBq+fxBYeN/WThWcZvemXcOTAoy9oqxMRVqo f46Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g21si7845896pgn.58.2018.01.18.22.23.46; Thu, 18 Jan 2018 22:24:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752190AbeASGVx (ORCPT + 99 others); Fri, 19 Jan 2018 01:21:53 -0500 Received: from mga03.intel.com ([134.134.136.65]:18356 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750722AbeASGVr (ORCPT ); Fri, 19 Jan 2018 01:21:47 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jan 2018 22:21:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,380,1511856000"; d="scan'208";a="10946364" Received: from unknown (HELO [10.239.13.97]) ([10.239.13.97]) by orsmga007.jf.intel.com with ESMTP; 18 Jan 2018 22:21:42 -0800 Message-ID: <5A618F0B.4090805@intel.com> Date: Fri, 19 Jan 2018 14:24:11 +0800 From: Wei Wang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: "Michael S. Tsirkin" CC: virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-mm@kvack.org, mhocko@kernel.org, akpm@linux-foundation.org, pbonzini@redhat.com, liliang.opensource@gmail.com, yang.zhang.wz@gmail.com, quan.xu0@gmail.com, nilal@redhat.com, riel@redhat.com Subject: Re: [PATCH v22 2/3] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ References: <1516165812-3995-1-git-send-email-wei.w.wang@intel.com> <1516165812-3995-3-git-send-email-wei.w.wang@intel.com> <20180117180337-mutt-send-email-mst@kernel.org> In-Reply-To: <20180117180337-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/18/2018 12:44 AM, Michael S. Tsirkin wrote: > On Wed, Jan 17, 2018 at 01:10:11PM +0800, Wei Wang wrote: >> >> +static void virtballoon_changed(struct virtio_device *vdev) >> +{ >> + struct virtio_balloon *vb = vdev->priv; >> + unsigned long flags; >> + __u32 cmd_id; >> + s64 diff = towards_target(vb); >> + >> + if (diff) { >> + spin_lock_irqsave(&vb->stop_update_lock, flags); >> + if (!vb->stop_update) > Why do you ignore stop_update for freeze? > This means new wq entries can be added during remove > causing use after free issues. I think stop_update isn't needed, because the lock has already been handled internally by the APIs. Similar examples like mem_cgroup_css_free() in "mm/memcontrol.c", there is no such locks used for cancel_work_sync(&memcg->high_work). Best, Wei