Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1389040imu; Wed, 9 Jan 2019 17:44:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN7j8LHGANMyrpwManYNxGLTwxikb0k4xMGCUMRwSU6HEO7C5A6TaYQvYdjGvhFf1BIXFMeY X-Received: by 2002:a17:902:8b88:: with SMTP id ay8mr8494056plb.55.1547084648699; Wed, 09 Jan 2019 17:44:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547084648; cv=none; d=google.com; s=arc-20160816; b=0di4jQ+U8jKDi6pt/zcOkLBsJFji31ctrT4BSbibEipOfIlo1N4gHICQDH7+g4wKh5 DOLokpJmY/3U5niXHagwzuHYrWDhYILm8Lof79fY9lWwHpM1g41xmS/weIgltznM317b 4xVh7+8/60STSStXL1RHYj4x4C0TSR6YfUjlkuDxDjx5K1BaPDVQoBXF4iNGohn9Jx0I P8XumxJ5FqjZV/4h7HmN95RFfyn6NaGT47Iq8Ual3V+nQBRJ3vmDUCnphZxzjP+u/gil sfO6xIR2z3wsZEZBhTdJmIYuaAJ35RztUug4jcPy+z0EsLzCixJ7kj0gn/iwZMuV6Fz7 FTrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=bCurXpnsxK9w3jvVxfzyYtpvMdOSCsFgS+WFSP2870U=; b=NShU2jU6cHQHqmlWR2j0ASHYzowTU0lWuX1VE/UQRqyFxJbiWUYFmoPi/ud123aiTC S/XZNjkMLrld5qJrY5kLL42O80sE0g/Rkuj6oGLc2nxQWiCc/oB35jfxcHXKhwPoy2xr cOZzyFIw3LjTQGlAKQwypIWPiDE5egfLbxyF8R3PPI12zexhq7lPBKyqapJIgnqIiheO DsoS7ByMfxz6pXGDDN8JSPROc4zZLS1Zig/Sf8EGMYG2slZu69OY9ioaQvGhu/LtO/Dj UXtMsKjil7OyI8reG8ll01I+pIbq+TQb3Zbss3kaSpqu8rPag7edQiNu0lHkrLDPFJ3w Sgvg== 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 t10si16813817plh.307.2019.01.09.17.43.52; Wed, 09 Jan 2019 17:44:08 -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 S1727005AbfAJBmK (ORCPT + 99 others); Wed, 9 Jan 2019 20:42:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35100 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726425AbfAJBmJ (ORCPT ); Wed, 9 Jan 2019 20:42:09 -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 083AE811AC; Thu, 10 Jan 2019 01:42:09 +0000 (UTC) Received: from redhat.com (ovpn-123-7.rdu2.redhat.com [10.10.123.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 900AF18341; Thu, 10 Jan 2019 01:42:04 +0000 (UTC) Date: Wed, 9 Jan 2019 20:42:02 -0500 From: Jerome Glisse To: Sean Christopherson Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, leozinho29_eu@hotmail.com, Mike Galbraith , Adam Borowski , Christian =?iso-8859-1?Q?K=F6nig?= , 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 Subject: Re: [PATCH] mm/mmu_notifier: mm/rmap.c: Fix a mmu_notifier range bug in try_to_unmap_one Message-ID: <20190110014200.GA4317@redhat.com> References: <20190110005117.18282-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190110005117.18282-1-sean.j.christopherson@intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) 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.27]); Thu, 10 Jan 2019 01:42:09 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 09, 2019 at 04:51:17PM -0800, Sean Christopherson wrote: > 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 Reviewed-by: 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)) { > /* > -- > 2.19.2 >