All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: trondmy@kernel.org, Mike Snitzer <snitzer@kernel.org>,
	linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org
Subject: Re: [PATCH] filemap: Fix bounds checking in filemap_read()
Date: Tue, 17 Sep 2024 07:55:29 +1000	[thread overview]
Message-ID: <ZuipUe6Z2QAF9pZs@dread.disaster.area> (raw)
In-Reply-To: <ZuSCwiSl4kbo3Nar@casper.infradead.org>

On Fri, Sep 13, 2024 at 07:21:54PM +0100, Matthew Wilcox wrote:
> On Fri, Sep 13, 2024 at 01:57:04PM -0400, trondmy@kernel.org wrote:
> > If the caller supplies an iocb->ki_pos value that is close to the
> > filesystem upper limit, and an iterator with a count that causes us to
> > overflow that limit, then filemap_read() enters an infinite loop.
> 
> Are we guaranteed that ki_pos lies in the range [0..s_maxbytes)?
> I'm not too familiar with the upper paths of the VFS and what guarantees
> we can depend on.  If we are guaranteed that, could somebody document
> it (and indeed create kernel-doc for struct kiocb)?

filemap_read() checks this itself before doing anything else:

	if (unlikely(iocb->ki_pos >= inode->i_sb->s_maxbytes))
                return 0;

i.e. there is no guarantee provided by the upper layers, it's first
checked right here in any buffered read path...

-Dave.

-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2024-09-16 21:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-13 17:57 [PATCH] filemap: Fix bounds checking in filemap_read() trondmy
2024-09-13 18:21 ` Matthew Wilcox
2024-09-16 21:55   ` Dave Chinner [this message]
2024-09-26 15:01     ` Mike Snitzer

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=ZuipUe6Z2QAF9pZs@dread.disaster.area \
    --to=david@fromorbit.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=snitzer@kernel.org \
    --cc=trondmy@kernel.org \
    --cc=willy@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.