linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: Sean Christopherson <seanjc@google.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	syzbot+4e697fe80a31aa7efe21@syzkaller.appspotmail.com,
	kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] hugetlbfs: Fix off-by-one error in hugetlb_vmdelete_list()
Date: Tue, 28 Dec 2021 19:52:37 -0800	[thread overview]
Message-ID: <7eb2849e-ad6d-11c5-a37d-806a1c62bb3e@oracle.com> (raw)
In-Reply-To: <20211228234257.1926057-1-seanjc@google.com>

+Cc Andrew if he wants to take it though his tree.

On 12/28/21 15:42, Sean Christopherson wrote:
> Pass "end - 1" instead of "end" when walking the interval tree in
> hugetlb_vmdelete_list() to fix an inclusive vs. exclusive bug.  The two
> callers that pass a non-zero "end" treat it as exclusive, whereas the
> interval tree iterator expects an inclusive "last".  E.g. punching a hole
> in a file that precisely matches the size of a single hugepage, with a
> vma starting right on the boundary, will result in unmap_hugepage_range()
> being called twice, with the second call having start==end.
> 
> The off-by-one error doesn't cause functional problems as
> __unmap_hugepage_range() turns into a massive nop due to short-circuiting
> its for-loop on "address < end".  But, the mmu_notifier invocations to
> invalid_range_{start,end}() are passed a bogus zero-sized range, which
> may be unexpected behavior for secondary MMUs.
> 
> The bug was exposed by commit ed922739c919 ("KVM: Use interval tree to do
> fast hva lookup in memslots"), currently queued in the KVM tree for 5.17,
> which added a WARN to detect ranges with start==end.
> 
> Reported-by: syzbot+4e697fe80a31aa7efe21@syzkaller.appspotmail.com
> Fixes: 1bfad99ab425 ("hugetlbfs: hugetlb_vmtruncate_list() needs to take a range to delete")
> Cc: kvm@vger.kernel.org
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Sean Christopherson <seanjc@google.com>

Thanks Sean!

Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>

> ---
> 
> Not sure if this should go to stable@.  It's mostly harmless, and likely
> nothing more than a minor performance blip when it's not harmless.

I am also unsure about the need to send to stable.  It is possible automation
will pick it up and make that decision for us.
-- 
Mike Kravetz


  reply	other threads:[~2021-12-29  3:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-28 23:42 [PATCH] hugetlbfs: Fix off-by-one error in hugetlb_vmdelete_list() Sean Christopherson
2021-12-29  3:52 ` Mike Kravetz [this message]
2021-12-29 23:29   ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7eb2849e-ad6d-11c5-a37d-806a1c62bb3e@oracle.com \
    --to=mike.kravetz@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=syzbot+4e697fe80a31aa7efe21@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).