Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1555931imu; Wed, 9 Jan 2019 21:55:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN7Bvhit19dif5XAee9oUPEnFdVoTlV7OSPTRj2FA1Rhdfo5Abd/lMg4lkXtYd/jNXBauEK0 X-Received: by 2002:a17:902:6a4:: with SMTP id 33mr8813247plh.99.1547099722549; Wed, 09 Jan 2019 21:55:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547099722; cv=none; d=google.com; s=arc-20160816; b=W4UJGZAoeiLAZddp6Mvdo5Zcefr1kSjoYpxPt4Z+6LrzBzVIq7QGNEH+NdRTYyq4I7 mmrh5ymlZFQEcs4ReeBw0lNWkHUoHgYuMGxrGsI1a2iwPaLha/WFJQE/OQ2L01JZ3GIM xMQnCcdg9jCYg3MVKghvRN7nE/7mXWnCEl0MTfkRkoerzMsi8zbRzWoz7yKX1F9u5PAB Zty36QxROltaYynKVScETcUx6L1Ac+uK++h9OhexVXh4v4tOe3NU7VpFj6vQrB0MxO3s Vwem7IgWSMr4d15FpTvnVA/OWRH7Np0i5r+Z5pOXyb2mqiuUInKqqz0+IjaBtLAXbhQR Djmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date; bh=TXW/zw+gSxd9BnDD4L4t09RJ9rnFC+b5cORq3qzhbWY=; b=DNj4S4hfGEyXfmkcMr4jaZxhxxbyup0Ky7LADjR19KlSRn2ovA2o2mCHb2xilyT1sV 8kV37pXQE3SsUQeei+rm9oYMb5j77+iikuDSvgGND0aXYGL1WJTD2qilgP/OJRM/x103 9lapGLRGB6HH+xyRyh/vDf2RBeadM/F3+/lMyUoVJPdHKZfdwQrWNIZXz4NVWD0Fi3S/ 11fzAyu/7dUKZshZyBClw361PRB+UZW19MxmOLe4sibh8sy/qQadaiKZC+++82mcGMwQ RQ9SLvE1SvyplKuoDc0hE9Neh3u6KFccV3B2jVfCBh1KzJPjrnle2Iuzny2/N0K7e1fn KbXg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3si73018311pgo.595.2019.01.09.21.55.07; Wed, 09 Jan 2019 21:55:22 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727137AbfAJFwf convert rfc822-to-8bit (ORCPT + 99 others); Thu, 10 Jan 2019 00:52:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54474 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725536AbfAJFwe (ORCPT ); Thu, 10 Jan 2019 00:52:34 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 10343C049DFC; Thu, 10 Jan 2019 05:52:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DA031179CB; Thu, 10 Jan 2019 05:52:33 +0000 (UTC) Received: from zmail21.collab.prod.int.phx2.redhat.com (zmail21.collab.prod.int.phx2.redhat.com [10.5.83.24]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 371CA3F7CB; Thu, 10 Jan 2019 05:52:33 +0000 (UTC) Date: Thu, 10 Jan 2019 00:52:32 -0500 (EST) From: Pankaj Gupta To: Sean Christopherson Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, leozinho29 eu , Mike Galbraith , Adam Borowski , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Christian =?utf-8?Q?K=C3=B6nig?= , Jan Kara , Matthew Wilcox , Ross Zwisler , Dan Williams , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Michal Hocko , Felix Kuehling , Ralph Campbell , John Hubbard , Andrew Morton , Linus Torvalds Message-ID: <1861725446.61345592.1547099552878.JavaMail.zimbra@redhat.com> In-Reply-To: <20190110005117.18282-1-sean.j.christopherson@intel.com> References: <20190110005117.18282-1-sean.j.christopherson@intel.com> Subject: Re: [PATCH] mm/mmu_notifier: mm/rmap.c: Fix a mmu_notifier range bug in try_to_unmap_one MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Originating-IP: [10.65.161.12, 10.4.195.7] Thread-Topic: mm/mmu_notifier: mm/rmap.c: Fix a mmu_notifier range bug in try_to_unmap_one Thread-Index: NxVIbboUSCe9zovHI7aboNWzdLjs1g== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 10 Jan 2019 05:52:34 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > The conversion to use a structure for mmu_notifier_invalidate_range_*() > unintentionally changed the usage in try_to_unmap_one() to init the > 'struct mmu_notifier_range' with vma->vm_start instead of @address, > i.e. it invalidates the wrong address range. Revert to the correct > address range. > > Manifests as KVM use-after-free WARNINGs and subsequent "BUG: Bad page > state in process X" errors when reclaiming from a KVM guest due to KVM > removing the wrong pages from its own mappings. > > Reported-by: leozinho29_eu@hotmail.com > Reported-by: Mike Galbraith > Reported-by: Adam Borowski > Cc: Jérôme Glisse > Cc: Christian König > Cc: Jan Kara > Cc: Matthew Wilcox > Cc: Ross Zwisler > Cc: Dan Williams > Cc: Paolo Bonzini > Cc: Radim Krčmář > Cc: Michal Hocko > Cc: Felix Kuehling > Cc: Ralph Campbell > Cc: John Hubbard > Cc: Andrew Morton > Cc: Linus Torvalds > Fixes: ac46d4f3c432 ("mm/mmu_notifier: use structure for > invalidate_range_start/end calls v2") > Signed-off-by: Sean Christopherson > --- > > FWIW, I looked through all other calls to mmu_notifier_range_init() in > the patch and didn't spot any other unintentional functional changes. > > mm/rmap.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/rmap.c b/mm/rmap.c > index 68a1a5b869a5..0454ecc29537 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -1371,8 +1371,8 @@ static bool try_to_unmap_one(struct page *page, struct > vm_area_struct *vma, > * Note that the page can not be free in this function as call of > * try_to_unmap() must hold a reference on the page. > */ > - mmu_notifier_range_init(&range, vma->vm_mm, vma->vm_start, > - min(vma->vm_end, vma->vm_start + > + mmu_notifier_range_init(&range, vma->vm_mm, address, > + min(vma->vm_end, address + > (PAGE_SIZE << compound_order(page)))); > if (PageHuge(page)) { > /* > -- I was suspecting this patch for some other issue. But could not spot this after in depth analyzing the changed "invalidate_range_start/end calls". Its indeed a good catch. Reviewed-by: Pankaj gupta > 2.19.2 > >