linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: klourencodev@gmail.com
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: Mon, 22 Dec 2025 09:52:48 -0800	[thread overview]
Message-ID: <20251222095248.18c4c102abcc8fb4f61c7067@linux-foundation.org> (raw)
In-Reply-To: <20251222141817.13335-1-klourencodev@gmail.com>

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 17:52 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 [this message]
2025-12-22 23:38   ` Kevin Lourenco
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=20251222095248.18c4c102abcc8fb4f61c7067@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=k.lourenco@criteo.com \
    --cc=klourencodev@gmail.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