linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ryan Roberts <ryan.roberts@arm.com>
To: Jan Kara <jack@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@redhat.com>,
	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>,
	Amir Goldstein <amir73il@gmail.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: Mon, 6 Oct 2025 16:04:23 +0100	[thread overview]
Message-ID: <ae61f721-3d07-4908-ad31-9c25e8b8119e@arm.com> (raw)
In-Reply-To: <uyh6y4qjuj6vcpsdnexwl2xqf2jnp6ejj7esr3g3hix66ml2zi@pqsbsjtt6apl>

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@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).
> 
> 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. :-|

> 
> 								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
>>



  reply	other threads:[~2025-10-06 15:04 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
2025-10-06 14:55 ` Jan Kara
2025-10-06 15:04   ` Ryan Roberts [this message]
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=ae61f721-3d07-4908-ad31-9c25e8b8119e@arm.com \
    --to=ryan.roberts@arm.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=amir73il@gmail.com \
    --cc=david@redhat.com \
    --cc=jack@suse.cz \
    --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=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