mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Sean Christopherson <seanjc@google.com>
Cc: "Muhammad Usama Anjum" <usama.anjum@collabora.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Andrei Vagin" <avagin@google.com>,
	"Peter Xu" <peterx@redhat.com>, "Hugh Dickins" <hughd@google.com>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Ryan Roberts" <ryan.roberts@arm.com>,
	"Kefeng Wang" <wangkefeng.wang@huawei.com>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	" Michał Mirosław " <mirq-linux@rere.qmqm.pl>,
	"Stephen Rothwell" <sfr@canb.auug.org.au>,
	"Arnd Bergmann" <arnd@arndb.de>,
	kernel@collabora.com,
	syzbot+81227d2bd69e9dedb802@syzkaller.appspotmail.com,
	stable@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] fs/proc/task_mmu: move mmu notification mechanism inside mm lock
Date: Tue, 9 Jan 2024 20:43:56 -0800	[thread overview]
Message-ID: <20240109204356.6c088124a9ba0ce0b5a4bb00@linux-foundation.org> (raw)
In-Reply-To: <ZZ10FqvnVWIbyo-9@google.com>

On Tue, 9 Jan 2024 08:28:06 -0800 Sean Christopherson <seanjc@google.com> wrote:

> > -	/* Protection change for the range is going to happen. */
> > -	if (p.arg.flags & PM_SCAN_WP_MATCHING) {
> > -		mmu_notifier_range_init(&range, MMU_NOTIFY_PROTECTION_VMA, 0,
> > -					mm, p.arg.start, p.arg.end);
> > -		mmu_notifier_invalidate_range_start(&range);
> > -	}
> > -
> >  	for (walk_start = p.arg.start; walk_start < p.arg.end;
> >  			walk_start = p.arg.walk_end) {
> >  		long n_out;
> 
> Nit, might be worth moving
> 
> 		struct mmu_notifier_range range;
> 
> inside the loop to guard against stale usage, but that's definitely optional.

Yes, I think that's nicer.

--- a/fs/proc/task_mmu.c~fs-proc-task_mmu-move-mmu-notification-mechanism-inside-mm-lock-fix
+++ a/fs/proc/task_mmu.c
@@ -2432,7 +2432,6 @@ static long pagemap_scan_flush_buffer(st
 
 static long do_pagemap_scan(struct mm_struct *mm, unsigned long uarg)
 {
-	struct mmu_notifier_range range;
 	struct pagemap_scan_private p = {0};
 	unsigned long walk_start;
 	size_t n_ranges_out = 0;
@@ -2450,6 +2449,7 @@ static long do_pagemap_scan(struct mm_st
 
 	for (walk_start = p.arg.start; walk_start < p.arg.end;
 			walk_start = p.arg.walk_end) {
+		struct mmu_notifier_range range;
 		long n_out;
 
 		if (fatal_signal_pending(current)) {
_


I'm surprised this code doesn't generate a might-be-used-uninitialized
warning.  I guess gcc got smarter.


      reply	other threads:[~2024-01-10  4:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-09 11:24 Muhammad Usama Anjum
2024-01-09 16:28 ` Sean Christopherson
2024-01-10  4:43   ` Andrew Morton [this message]

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=20240109204356.6c088124a9ba0ce0b5a4bb00@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=arnd@arndb.de \
    --cc=avagin@google.com \
    --cc=david@redhat.com \
    --cc=hughd@google.com \
    --cc=kernel@collabora.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=peterx@redhat.com \
    --cc=ryan.roberts@arm.com \
    --cc=seanjc@google.com \
    --cc=sfr@canb.auug.org.au \
    --cc=stable@vger.kernel.org \
    --cc=surenb@google.com \
    --cc=syzbot+81227d2bd69e9dedb802@syzkaller.appspotmail.com \
    --cc=usama.anjum@collabora.com \
    --cc=wangkefeng.wang@huawei.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

all inboxes | Powered by JetHome®