linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Lourenco <klourencodev@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, david@kernel.org,
	 Kevin Lourenco <k.lourenco@criteo.com>
Subject: Re: [PATCH] mm/fadvise: validate offset in generic_fadvise
Date: Tue, 23 Dec 2025 00:38:21 +0100	[thread overview]
Message-ID: <CAFveykPzenGkWKZvZx+f_n2Noy5mNMuF9=GpZVgZ2QWUmauh3A@mail.gmail.com> (raw)
In-Reply-To: <20251222095248.18c4c102abcc8fb4f61c7067@linux-foundation.org>

Thank you, Andrew, for taking a look and for queueing in -next.

I'll keep an eye on it and will adjust the patch if needed.

Kevin

Le lun. 22 déc. 2025 à 18:52, Andrew Morton
<akpm@linux-foundation.org> a écrit :
>
> On Mon, 22 Dec 2025 15:18:17 +0100 klourencodev@gmail.com wrote:
>
> > From: Kevin Lourenco <klourencodev@gmail.com>
> >
> > When converted to (u64) for page calculations, a negative offset
> > can produce extremely large page indices. This may lead to issues in certain advice modes (excessive readahead or
> > cache invalidation)
> >
> > offsets are normally non-negative, but the API does not guarantee this. Since 'len' is already
> > validated, checking 'offset' here is reasonable to prevent potential system instability.
> >
>
> Yeah, seems this code really didn't think about negative offsets.
>
>         fadvise(fd, -20, 40, advice);
>
> does make some sense I guess - equivalent to
>
>         fadvise(fd, 0, 20, advice);
>
> but whether this is how the implementation actually treats -20,40 is
> unclear.  Probably not, and what will filemap_flush_range() make of
> this.
>
> ugh.
>
> I suppose I'll toss this into -next for now, see if it breaks any tests.
> But more thought is needed.
>


  reply	other threads:[~2025-12-22 23:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-22 14:18 klourencodev
2025-12-22 17:52 ` Andrew Morton
2025-12-22 23:38   ` Kevin Lourenco [this message]
2025-12-23  9:45 ` David Hildenbrand (Red Hat)
2025-12-23 16:16   ` Kevin Lourenco

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='CAFveykPzenGkWKZvZx+f_n2Noy5mNMuF9=GpZVgZ2QWUmauh3A@mail.gmail.com' \
    --to=klourencodev@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=k.lourenco@criteo.com \
    --cc=linux-mm@kvack.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: 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