[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <pg55elgetdhvjhda36xr63esawc3t6y6lbiesyfxhousmzmil3@rwd54tfm2jh5>
Date: Mon, 6 Oct 2025 17:16:53 +0200
From: Jan Kara <jack@...e.cz>
To: Ryan Roberts <ryan.roberts@....com>
Cc: Jan Kara <jack@...e.cz>, Andrew Morton <akpm@...ux-foundation.org>,
David Hildenbrand <david@...hat.com>, Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>, Vlastimil Babka <vbabka@...e.cz>,
Mike Rapoport <rppt@...nel.org>, Suren Baghdasaryan <surenb@...gle.com>,
Michal Hocko <mhocko@...e.com>, Amir Goldstein <amir73il@...il.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH v1] fsnotify: Pass correct offset to fsnotify_mmap_perm()
On Mon 06-10-25 16:04:23, Ryan Roberts wrote:
> On 06/10/2025 15:55, Jan Kara wrote:
> > On Fri 03-10-25 16:52:36, Ryan Roberts wrote:
> >> fsnotify_mmap_perm() requires a byte offset for the file about to be
> >> mmap'ed. But it is called from vm_mmap_pgoff(), which has a page offset.
> >> Previously the conversion was done incorrectly so let's fix it, being
> >> careful not to overflow on 32-bit platforms.
> >>
> >> Discovered during code review.
> >>
> >> Cc: <stable@...r.kernel.org>
> >> Fixes: 066e053fe208 ("fsnotify: add pre-content hooks on mmap()")
> >> Signed-off-by: Ryan Roberts <ryan.roberts@....com>
> >> ---
> >> Applies against today's mm-unstable (aa05a436eca8).
> >
> > Thanks Ryan! I've added the patch to my tree. As a side note, I know the
> > callsite is in mm/ but since this is clearly impacting fsnotify, it would
> > be good to add to CC relevant people (I'm not following linux-mm nor
> > linux-kernel) and discovered this only because of Kiryl's link...
>
> Ahh good point... Sorry I was sleepwalking through the process on Friday
> afternoon and blindly sent it to the maintainers and reviewers that
> get_maintainer.pl spat out. It didn't even occur to me that this wasn't an mm
> thing. :-|
No harm done really. The change is an obvious fix and it would find its way
to the kernel sooner or later. As I wrote above, this is just a note for
the future to think a bit about patch recipients before hitting send :) It
may help to get the patch merged faster.
Honza
> >> mm/util.c | 3 ++-
> >> 1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/mm/util.c b/mm/util.c
> >> index 6c1d64ed0221..8989d5767528 100644
> >> --- a/mm/util.c
> >> +++ b/mm/util.c
> >> @@ -566,6 +566,7 @@ unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr,
> >> unsigned long len, unsigned long prot,
> >> unsigned long flag, unsigned long pgoff)
> >> {
> >> + loff_t off = (loff_t)pgoff << PAGE_SHIFT;
> >> unsigned long ret;
> >> struct mm_struct *mm = current->mm;
> >> unsigned long populate;
> >> @@ -573,7 +574,7 @@ unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr,
> >>
> >> ret = security_mmap_file(file, prot, flag);
> >> if (!ret)
> >> - ret = fsnotify_mmap_perm(file, prot, pgoff >> PAGE_SHIFT, len);
> >> + ret = fsnotify_mmap_perm(file, prot, off, len);
> >> if (!ret) {
> >> if (mmap_write_lock_killable(mm))
> >> return -EINTR;
> >> --
> >> 2.43.0
> >>
>
--
Jan Kara <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists