linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>,
	David Hildenbrand <david@redhat.com>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	 "Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	 Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	 linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v1] fsnotify: Pass correct offset to fsnotify_mmap_perm()
Date: Tue, 7 Oct 2025 13:08:10 +0200	[thread overview]
Message-ID: <CAOQ4uxh-FJMtpyDrZpRQcWV6ScranQWUia4yz+rb82yQSdjSUQ@mail.gmail.com> (raw)
In-Reply-To: <CAOQ4uxh+Mho71c93FNqcw=crw2H3yEs-uecWf4b6JMKYDTBCWQ@mail.gmail.com>

On Mon, Oct 6, 2025 at 4:40 PM Amir Goldstein <amir73il@gmail.com> wrote:
>
> On Mon, Oct 6, 2025 at 3:53 PM David Hildenbrand <david@redhat.com> wrote:
> >
> > On 06.10.25 14:14, Ryan Roberts wrote:
> > > On 06/10/2025 12:36, David Hildenbrand wrote:
> > >> On 03.10.25 17:52, 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@vger.kernel.org>
> > >>> Fixes: 066e053fe208 ("fsnotify: add pre-content hooks on mmap()")
> > >>> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
> > >>> ---
> > >>> Applies against today's mm-unstable (aa05a436eca8).
> > >>>
> > >>
> > >> Curious: is there some easy way to write a reproducer? Did you look into that?
> > >
> > > I didn't; this was just a drive-by discovery.
> > >
> > > It looks like there are some fanotify tests in the filesystems selftests; I
> > > guess they could be extended to add a regression test?
> > >
> > > But FWIW, I think the kernel is just passing the ofset/length info off to user
> > > space and isn't acting on it itself. So there is no kernel vulnerability here.
> >
> > Right, I'm rather wondering if this could have been caught earlier and
> > how we could have caught it earlier :)
>
> Ha! you would have thought we either have no test for it or we test
> only mmap with offset 0.
>
> But we have LTP test fanotify24 which does mmap with offset page_sz*100
> and indeed it prints the info and info says offset 0, only we do not verify the
> offset info in this test...
>
> Will be fixed.

Jan,

FYI test enhanced and verified the bug and the fix:
https://github.com/amir73il/ltp/commits/fsnotify-fixes/

Will wait with posting the test until you merge the fix to make sure that the
commit id is not changed.

Thanks,
Amir.


  reply	other threads:[~2025-10-07 11:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-03 15:52 Ryan Roberts
2025-10-03 16:00 ` Kiryl Shutsemau
2025-10-03 16:36   ` Ryan Roberts
2025-10-03 16:54     ` Kiryl Shutsemau
2025-10-06 11:36 ` David Hildenbrand
2025-10-06 12:14   ` Ryan Roberts
2025-10-06 13:53     ` David Hildenbrand
2025-10-06 14:40       ` Amir Goldstein
2025-10-07 11:08         ` Amir Goldstein [this message]
2025-10-06 14:55 ` Jan Kara
2025-10-06 15:04   ` Ryan Roberts
2025-10-06 15:16     ` Jan Kara
2025-10-14 13:38 ` Lorenzo Stoakes

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=CAOQ4uxh-FJMtpyDrZpRQcWV6ScranQWUia4yz+rb82yQSdjSUQ@mail.gmail.com \
    --to=amir73il@gmail.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=jack@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=stable@vger.kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    /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