From: Andrew Morton <akpm@linux-foundation.org> To: stable@vger.kernel.org,seanjc@google.com,pbonzini@redhat.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org Subject: [patch 5/9] mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0) Date: Fri, 08 Apr 2022 13:09:04 -0700 [thread overview] Message-ID: <20220408200905.943B7C385A5@smtp.kernel.org> (raw) In-Reply-To: <20220408130819.a89195e527ce58dfbe0700b9@linux-foundation.org> From: Paolo Bonzini <pbonzini@redhat.com> Subject: mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0) If an mremap() syscall with old_size=0 ends up in move_page_tables(), it will call invalidate_range_start()/invalidate_range_end() unnecessarily, i.e. with an empty range. This causes a WARN in KVM's mmu_notifier. In the past, empty ranges have been diagnosed to be off-by-one bugs, hence the WARNing. Given the low (so far) number of unique reports, the benefits of detecting more buggy callers seem to outweigh the cost of having to fix cases such as this one, where userspace is doing something silly. In this particular case, an early return from move_page_tables() is enough to fix the issue. Link: https://lkml.kernel.org/r/20220329173155.172439-1-pbonzini@redhat.com Reported-by: syzbot+6bde52d89cfdf9f61425@syzkaller.appspotmail.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Sean Christopherson <seanjc@google.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- mm/mremap.c | 3 +++ 1 file changed, 3 insertions(+) --- a/mm/mremap.c~mm-avoid-pointless-invalidate_range_start-end-on-mremapold_size=0 +++ a/mm/mremap.c @@ -486,6 +486,9 @@ unsigned long move_page_tables(struct vm pmd_t *old_pmd, *new_pmd; pud_t *old_pud, *new_pud; + if (!len) + return 0; + old_end = old_addr + len; flush_cache_range(vma, old_addr, old_end); _
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org> To: stable@vger.kernel.org, seanjc@google.com, pbonzini@redhat.com, akpm@linux-foundation.org, patches@lists.linux.dev, linux-mm@kvack.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, akpm@linux-foundation.org Subject: [patch 5/9] mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0) Date: Fri, 08 Apr 2022 13:09:04 -0700 [thread overview] Message-ID: <20220408200905.943B7C385A5@smtp.kernel.org> (raw) In-Reply-To: <20220408130819.a89195e527ce58dfbe0700b9@linux-foundation.org> From: Paolo Bonzini <pbonzini@redhat.com> Subject: mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0) If an mremap() syscall with old_size=0 ends up in move_page_tables(), it will call invalidate_range_start()/invalidate_range_end() unnecessarily, i.e. with an empty range. This causes a WARN in KVM's mmu_notifier. In the past, empty ranges have been diagnosed to be off-by-one bugs, hence the WARNing. Given the low (so far) number of unique reports, the benefits of detecting more buggy callers seem to outweigh the cost of having to fix cases such as this one, where userspace is doing something silly. In this particular case, an early return from move_page_tables() is enough to fix the issue. Link: https://lkml.kernel.org/r/20220329173155.172439-1-pbonzini@redhat.com Reported-by: syzbot+6bde52d89cfdf9f61425@syzkaller.appspotmail.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Sean Christopherson <seanjc@google.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- mm/mremap.c | 3 +++ 1 file changed, 3 insertions(+) --- a/mm/mremap.c~mm-avoid-pointless-invalidate_range_start-end-on-mremapold_size=0 +++ a/mm/mremap.c @@ -486,6 +486,9 @@ unsigned long move_page_tables(struct vm pmd_t *old_pmd, *new_pmd; pud_t *old_pud, *new_pud; + if (!len) + return 0; + old_end = old_addr + len; flush_cache_range(vma, old_addr, old_end); _
next prev parent reply other threads:[~2022-04-08 20:09 UTC|newest] Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-08 20:08 incoming Andrew Morton 2022-04-08 20:08 ` [patch 1/9] mm: migrate: use thp_order instead of HPAGE_PMD_ORDER for new page allocation Andrew Morton 2022-04-08 20:08 ` Andrew Morton 2022-04-08 20:10 ` Matthew Wilcox 2022-04-08 20:08 ` [patch 2/9] highmem: fix checks in __kmap_local_sched_{in,out} Andrew Morton 2022-04-08 20:08 ` Andrew Morton 2022-04-08 20:08 ` [patch 3/9] lz4: fix LZ4_decompress_safe_partial read out of bound Andrew Morton 2022-04-08 20:08 ` Andrew Morton 2022-04-08 20:09 ` [patch 4/9] mm/sparsemem: fix 'mem_section' will never be NULL gcc 12 warning Andrew Morton 2022-04-08 20:09 ` Andrew Morton 2022-04-11 9:00 ` Oscar Salvador 2022-04-08 20:09 ` Andrew Morton [this message] 2022-04-08 20:09 ` [patch 5/9] mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0) Andrew Morton 2022-04-08 20:09 ` [patch 6/9] mm/mempolicy: fix mpol_new leak in shared_policy_replace Andrew Morton 2022-04-08 20:09 ` Andrew Morton 2022-04-08 20:09 ` [patch 7/9] mailmap: update Vasily Averin's email address Andrew Morton 2022-04-08 20:09 ` Andrew Morton 2022-04-08 20:09 ` [patch 8/9] mm/list_lru.c: revert "mm/list_lru: optimize memcg_reparent_list_lru_node()" Andrew Morton 2022-04-08 20:09 ` Andrew Morton 2022-04-08 20:09 ` [patch 9/9] MAINTAINERS: add Tom as clang reviewer Andrew Morton 2022-04-08 20:09 ` 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=20220408200905.943B7C385A5@smtp.kernel.org \ --to=akpm@linux-foundation.org \ --cc=linux-mm@kvack.org \ --cc=mm-commits@vger.kernel.org \ --cc=patches@lists.linux.dev \ --cc=pbonzini@redhat.com \ --cc=seanjc@google.com \ --cc=stable@vger.kernel.org \ --cc=torvalds@linux-foundation.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.